Media player in JavaFX -


I am trying to load a video in JavaFX. When I click to load a video that contains a video, I get the error: java.net.urisyntaxException: Invalid character in the opaque part in index 5: File: \ C: \ Users \ Lynsey \ Documents \ My CamStudio Videos \ 1.flv

I use the code to use the media

  Media media = new media ("file: \\ C: \" \ Users \\ Linsee \\ Documents \\ My CamStudio Video \\ 1.flv "); Media Player Player = New Media Player (Media); Mediaview view = new mediaview (player); . VideoPane.getChildren () add (see); Player.play ();    

You may not have white space in the URL.

"quick and dirty" fixed (i think)

  media media = new media ("file: \\ c: \\ user \\ linsee \\ document \\ My% 20CamStudio% 20Videos \\ 1.flv ");   

A better fix is ​​

  file file = new file ("C: \\ user \\ LINES \\ DOCUMENT \\ MY CAMStudio video \\ 1.flv "); // check file exists: if (file.exists ()) {media media = new media (file.toURI (.) ToURL () .toExternalForm ()); } Else {System.out.println ("File does not exist"); }   

If you want, you can use java.nio.path instead of java.io.file . I just do it with JavaFX to use the FileChooser return file s and not path s with the file

If the file exists and it still fails, then the video format may not be compatible. Currently lists supported formats.

Comments

Popular posts from this blog

How can I add a seperate action listener to all 14 of my buttons at once that can determine player turn?(java) -

php - Sorting an multidimension array using usort fails -

Simple file compression in C -