I'm trying to get a simple mp3 to run while my program runs, through this:
Media med = new Media("file://C:/Users/hariklia-elsa/workspace/PokerApp/src/intro.mp3");
MediaPlayer mPlayer = new MediaPlayer(med);
mPlayer.play();
But I'm running into problems. Running the program terminates with exception Exception in thread "main" MediaException: MEDIA_INACCESSIBLE : C
, with reference to the first line of the code segment above, the one calling the Media() constructor.
I've had no previous experience with javafx or playing media in code, would anyone have any idea on why it would deem the file inaccessible? Am I doing anything simple incorrectly?
The file is, of course, fine. I can open it in a myriad different media players and it's fine.
This way it will work:
Media med = new Media("file:///C:/Users/hariklia-elsa/workspace/PokerApp/src/intro.mp3");
Note 3 slashes after file:
.
Here is why: https://superuser.com/questions/352133/what-is-the-reason-that-file-urls-start-with-three-slashes-file-etc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With