I am trying to make an application in **Netbeans IDE (Java)**which views videos. I don't want to create a media player to view the videos. I just want to use the default media player.my default media player is Windows media player.
You can use the below code for opening your videos using java but this will work only on ubuntu or may be some other linux.You can also check your OS and change the command. For Windows it is just absolute path of the filename.
public class Main
{
public static void main(String[] args)
{
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("xdg-open <path+yourfilename>");
} catch (IOException e) {
e.printStackTrace();
}
}
}
for windows
public class Main
{
public static void main(String[] args)
{
Runtime runtime = Runtime.getRuntime();
try {
String[] command = {"cmd.exe", "/k", "Start", "<path+yourfilename>"};
Process p = runtime.exec(command);
} catch (IOException e) {
e.printStackTrace();
}
}
}