VLCJ - playing a video from the "res" folder works great in eclipse, but not from the executable JAR file

Samer Massad

i have an .MP4 video placed in the "res/media" folder inside my project. I can easily play this video in my application from eclipse using this piece of code:

String url = getClass().getResource("/media/video.mp4").getFile();
url = new File(url).getPath();
showMedia(url);       //the method that plays the video

i had to use this code because using only URL url = getClass().getResource("/media/video.mp4"); makes VLCJ can't access the video using this URL.

When creating the executable JAR file, i get these errors in the console:

libdvdnav: Using dvdnav version 5.0.0
libdvdread: Could not open D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4 with libdvdcss.
libdvdread: Can't open D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4 for reading
libdvdnav: vm: failed to open/read the DVD
[1644d0ac] filesystem access error: cannot open file D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4 (Invalid argument)
[1644d0ac] main access error: File reading failed
[1644d0ac] main access error: VLC could not open the file "D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4" (Invalid argument).
[1645643c] main input error: open of `file:///D:/Desktop/file%3A/D%3A/Desktop/app.jar%21/media/video.mp4' failed
[1645643c] main input error: Your input can't be opened
[1645643c] main input error: VLC is unable to open the MRL 'file:///D:/Desktop/file%3A/D%3A/Desktop/app.jar%21/media/video.mp4'. Check the log for details.

The libraries are being successfully loaded, and i can even play any video that is outside my JAR file.

Any suggestions?

And thanks in advance.

caprica

A Media Resource Locator (MRL) is not the same as a URL.

The log you posted shows what VLC is trying to open. The informative part is:

[1644d0ac] filesystem access error: cannot open file D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4 (Invalid argument)

"D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4" is clearly not a valid filename?

So this code is flawed:

String url = getClass().getResource("/media/video.mp4").getFile();

This type of thing, without the .getFile(), is usually used to load resources from the application classpath. That's not the case here though when you try and get the file name.

You should just do something like:

String mrl = new File("res/media/video.mp4").getAbsolutePath();

But that of course depends on what is the "current" directory for your application, and won't work inside a jar file.

On the other hand, VLC can play media contained inside zip (and therefore jar) files, with an MRL that looks a little bit like what you posted. Something like:

zip://file.jar!/res/media/video.mp4

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

VLCJ - playing a video from the "res" folder works great in eclipse, but not from the executable JAR file

From Dev

Extracting files from res folder in Executable JAR (txt files to be specific)

From Dev

Export an executable Jar from Eclipse

From Dev

Playing a video from res/raw on Android Wear

From Dev

Playing a video from res/raw on Android Wear

From Dev

Read text file from inside Java eclipse executable jar

From Dev

Compiling Jar file from src and res folder in makefile

From Dev

vlcj play video from url

From Dev

why eclipse not detect the jar file from lib folder

From Dev

Music not playing from file, but works fine in IDLE

From Dev

Playing a video file from a server in Swift

From Dev

Android not playing the video file from a given url

From Dev

Make jar file from folder

From Dev

Recursively read images from an executable JAR file

From Dev

Playing a video from IsolatedStorage

From Dev

Playing video from internet

From Dev

Playing Video From UITableView

From Dev

Video from file on computer not playing with <video> HTML5

From Dev

Export as Executable Jar File in Eclipse

From Dev

Hosting executable .jar files in BitBucket repo or automate packaging executable .jar files from git into local folder

From Dev

Get file from res/raw folder

From Dev

Executable Scala Jar from Eclipse using Java main class

From Dev

Eclipse Executable from terminal

From Dev

Android VideoView playing video from url file extension required?

From Dev

Copying images from JAR file to a folder outside

From Dev

Playing video from within app?

From Dev

Playing Video from RAM in Android

From Dev

Playing Video from Online URL works but from Local Path doesn't

From Dev

making file executable works only from GUI, not Terminal

Related Related

  1. 1

    VLCJ - playing a video from the "res" folder works great in eclipse, but not from the executable JAR file

  2. 2

    Extracting files from res folder in Executable JAR (txt files to be specific)

  3. 3

    Export an executable Jar from Eclipse

  4. 4

    Playing a video from res/raw on Android Wear

  5. 5

    Playing a video from res/raw on Android Wear

  6. 6

    Read text file from inside Java eclipse executable jar

  7. 7

    Compiling Jar file from src and res folder in makefile

  8. 8

    vlcj play video from url

  9. 9

    why eclipse not detect the jar file from lib folder

  10. 10

    Music not playing from file, but works fine in IDLE

  11. 11

    Playing a video file from a server in Swift

  12. 12

    Android not playing the video file from a given url

  13. 13

    Make jar file from folder

  14. 14

    Recursively read images from an executable JAR file

  15. 15

    Playing a video from IsolatedStorage

  16. 16

    Playing video from internet

  17. 17

    Playing Video From UITableView

  18. 18

    Video from file on computer not playing with <video> HTML5

  19. 19

    Export as Executable Jar File in Eclipse

  20. 20

    Hosting executable .jar files in BitBucket repo or automate packaging executable .jar files from git into local folder

  21. 21

    Get file from res/raw folder

  22. 22

    Executable Scala Jar from Eclipse using Java main class

  23. 23

    Eclipse Executable from terminal

  24. 24

    Android VideoView playing video from url file extension required?

  25. 25

    Copying images from JAR file to a folder outside

  26. 26

    Playing video from within app?

  27. 27

    Playing Video from RAM in Android

  28. 28

    Playing Video from Online URL works but from Local Path doesn't

  29. 29

    making file executable works only from GUI, not Terminal

HotTag

Archive