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.

Answers


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:) )

media file:/D:/Downloads/oow2010-2.flv

media file:////Amd/Downloads/oow2010-2.flv

and it works. I don't understand why you have .jpg files. Can you open them with media player? I can't.


Need Your Help

Finding x,y position of a datagrid / adavancedDataGrid row in Flex

flex datagrid flex3 row advanceddatagrid

I have flex advancedDataGrid (could use dataGrid if that works better, though i like my meta-column headers), and i want to have a component popup on top of a selected row.

Sort a list into tuples

function sorting haskell

I’m new to Haskell and am trying to sort a list of tuples using their first element, using the sort function. So if I had ["a", "b", "a", "c", "c"] I would get something like [(1,"b"), (2,"a"), (2,...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.