JavaFX MediaPlayer does not play unc network files
I want to play movie files using the MediaPlayer of JavaFX (Java Version 1.8.0_05) under Windows 7. I used the FileChooser class, so in my application local files and UNC network files can be selected during runtime.
Excerpt from my code:
String textPath = ... Path fileOnDisk = Paths.get(textPath); ... Media media= new Media(fileOnDisk.toUri().toString()); ... MediaPlayer mediaPlayer = new MediaPlayer(media);
If a local file has been selected then everythings works fine. As an example the Media object contains then the following URL (read out in the debugger):
media.url = "file:/D:/_Medien/Photo/Familie/2014_06_26%20Sensapolis%20Geburtstag%2010%20Adrian/56%20Holzgerüst%20klettern_AxelLeanderSteffen.MP4";
...and the mediaPlayer can be built without any problems.
I have copied this file to my NAS drive. Now if the same file has been selected from the NAS (using UNC syntax) then the Media object could also be built and contains the following url attribute:
media.url = "file://VERBATIMNAS/public/Photo/Familie/2014_06_26%20Sensapolis%20Geburtstag%2010%20Adrian/56%20Holzgerüst%20klettern_AxelLeanderSteffen.MP4";
But as soon as the MediaPlayer is built with the Media pointing to a UNC then I get the following exception:
Exception in thread "JavaFX Application Thread" MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player! at javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:146) at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:511) at javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:414) at de.kissphoto.view.mediaViewers.MovieViewer.setMedia(MovieViewer.java:216)
What do I do wrong to play media with UNC paths.. or is this a bug in JavaFX?
Note: both file paths were not entered manually but by using JavaFX's FileChooser in my application.
I do this
media = new Media(file.toURI().toURL().toExternalForm()); System.out.println("media "+media.getSource());
and get this (same file going through file tree and network, my Downloads folder is shared by name on the computer named Amd (no imagination here:) )
and it works. I don't understand why you have .jpg files. Can you open them with media player? I can't.