Reputation: 95
I want to know if there is a way of opening mp3 files using either Windows Media Player and VLC Media Player. I have the path of the file saved as a String and was wondering if I can use this to open the file on either of the applications mentioned above. I understand one method of doing this is by using the Desktop class but this opens the file using the default application, which is Windows Media Player in my case. How would I open the file in VLC media player?
Upvotes: 1
Views: 1960
Reputation: 5094
Judging by the Desktop.open
apidoc and
Desktop tutorial it looks like the open method can only open the file in their default associated program.
So, you have (maybe) two options here:
file
scheme is the only acceptable solution, and that will most probably open in the default program. There is a mms
scheme but it is used for video-streaming, and again, it will most probably open in the default program.Here is a link to the Runtime.exec
solution for windows, linux and osx variant.
Upvotes: 1
Reputation: 4907
You should know the path to the VLC
and/or WMP
. Then you can use Runtime
class for this.
Process p = Runtime.getRuntime().exec("c:/vlc/vlc.exe " + mp3FileName);
Upvotes: 0
Reputation: 22233
try
Runtime.getRuntime().exec("<your vlc path> <your file>");
I.E.
Runtime.getRuntime().exec("\"C:\\Program Files (x86)\\VideoLAN\VLC\\vlc.exe\" abc.mp3");
Tried and it works
Upvotes: 2