Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Loading mp4 files

colin-javaJan 31 2013 — edited Feb 5 2013
Hi, I have a javafx program.

It has an mp4 file located at Slider/src/slider/universe.mp4

where slider is the main package of the project, in which all the classes are.

When running file from within netbeans 7.2.1,
I am able to load the mp4 file using:

media = new Media(new File("src/slider/universe.mp4").toURI().toURL().toExternalForm().toString());

This works well, and the movie repeats over and over due to:

MediaPlayer player = new MediaPlayer(media);
player.setCycleCount(MediaPlayer.INDEFINITE);

So my problem is: When building the project, I get a jar file, but when running the jar file, it has a problem finding the file.
Basically with the code above, with the jar on my desktop, it gives the exception:

Caused by: MediaException: MEDIA_UNAVAILABLE : C:\Users\colin\Desktop\src\slider\universe.mp4 (The system cannot find the path specified)

And that obviously isn't right.

Can anyone help me get it to work, also I'd like it so the movie repeats, I managed to get it to play through jar file using
media = new Media(this.getClass().getResource("src\slider\universe.mp4").toExternalForm()); But it doesn't repeat using this.

Thanks for any help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 5 2013
Added on Jan 31 2013
10 comments
1,550 views