GUIDE: Programmatic Access to VLC from Java in Windows

Microsoft Windows specific usage questions
Forum rules
Please post only Windows specific questions in this forum category. If you don't know where to post, please read the different forums' rules. Thanks.
marcsto
Blank Cone
Blank Cone
Posts: 13
Joined: 01 Sep 2008 15:27

GUIDE: Programmatic Access to VLC from Java in Windows

Postby marcsto » 01 Sep 2008 16:12

Hello,

I have successfully setup a java application that has programmatic access to VLC on a windows machine using Java. This was done using the java binding called JVLC. During this process, I encountered several difficulties and noticed that several other posts had similar problems with often no solution posted. I would therefore like to share the correct steps for setting up this project:

1. Start by downloading the JVLC jar file from the following link (at the time of this post, the version was "0.9.0-test3 date: 2008-07-27" and the file was called jvlc-core-0.9.0-SNAPSHOT-20080727.jar):
http://trac.videolan.org/jvlc/wiki/download

2. Download the matching VLC build from the nightly builds folder (it doesn't have to be this exact build but this can help avoid issues):
http://nightlies.videolan.org/build/win ... -win32.zip

3. Create a new Eclipse Java project.

4. Add a 'lib' folder to your Eclipse project.

5. Put the JVLC jar file in this folder (the file that was downloaded in step 1. It should be called jvlc-core-0.9.0-SNAPSHOT-20080727.jar).

6. Create a '3rd_party' folder.

7. Extract the vlc-0.9.0-test3-20080727-0004-win32.zip file into this folder. You should now have a project structure that looks like this:
  • MyProjectName
    • src
      • my package 1
        etc..
      3rd_party
      lib
8. In eclipse, right-click on the lib/jvlc-core-0.9.0-SNAPSHOT-20080727.jar and select 'Build Path', 'Add to build path' (if you can't see the lib folder or the jar file, right click on your project and select 'refresh').

9. Create a new class called VlcDemo.

10. Add the following code to the class:

Code: Select all

public static void main(String[] args) throws InterruptedException { String[] param = new String[] { "-vvv", "--plugin-path=.\\3rd_party\\vlc-0.9.0-test3-20080727-0004\\plugins", "--no-plugins-cache" }; JVLC jvlc = new JVLC(param); jvlc.play("C:\\SomeMoviePath\\AMovieName.avi"); Thread.sleep(10000) // Sleep for 10 seconds to let the movie play for a bit. }
11. Add a PATH variable to the run configuration of this class. To do this, perform the following steps:
Select 'run', 'run configuration...'
Double click 'Java Application'
Select the 'Environment' tab
Click 'new' and enter the following information:
- Name: PATH
- Value: .\3rd_party\vlc-0.9.0-test3-20080727-0004

12. Run your project. If everything went well, you should see the movie you specified in step 10 play for about 10 seconds.


Errors I encountered that can be resolved by simply following the steps above. This hould make it easier for people who encounter these errors to find this post:

UnsatisfiedLinkError: Error looking up function 'libvlc_media_new'

- This can be solved by following the steps mentioned above. Also, if you have have been trying different solutions to this problem and other problems before reading this post, you'll want to make sure to delete any libvlc.dll that might be laying around. This was a huge problem for me as I had previously encountered several EXCEPTION_ACCESS_VIOLATIONand had read on a post that I should copy the dll file to where my app was running in order to get this to work.

- Also, if you may have read that you need to set the -Djava.library.path="path to vlc" jvm flag in order for this to work properly. I did not have to use this flag when following the steps mentioned above.

Main interface error: no interface module matched "hotkeys,none"
- Can be solved by following the above steps.

java.lang.UnsatisfiedLinkError jvlc.dll: Can't find dependent libraries
- Can be solved by following the above steps.

EXCEPTION_ACCESS_VIOLATION
- Can be solved by following the above steps.

Cheers,
Marc Stogaitis

JeffM-35
New Cone
New Cone
Posts: 4
Joined: 13 Dec 2007 15:08

Re: GUIDE: Programmatic Access to VLC from Java in Windows

Postby JeffM-35 » 08 Sep 2008 02:50

Marc -

I haven't had time to try this yet, but assuming it works, I wanted to say THANK YOU!! :mrgreen: I've been pulling my hair out for the last week trying to get this to work! :x

I tend to prefer NetBeans, so I'll use your tips and provide feedback on any steps that are of note that might be NetBeans specific.

uhilger
Blank Cone
Blank Cone
Posts: 10
Joined: 20 Jan 2009 19:07
Operating System: Windows Vista
Location: Frankfurt, Germany
Contact:

Re: GUIDE: Programmatic Access to VLC from Java in Windows

Postby uhilger » 29 Jan 2009 13:58

Thank you very much for this guide, it was very helpful for me to find out the basics of VLC invocation using JVLC.

I use Netbeans and with Netbeans it works pretty much the same as in your Eclipse example. The only thing that is different is that inside Netbens it is necessary to set a working directory that points to the directory where VLC lives. To do this, in Netbeans right click on your project, select 'Properties' and in the dialog that comes up click on 'Run'. There you can set the working directory with a file chooser button. With the example in your guide the working directory would be set to '3rd_party'.

When your Netbeans project is configured like this, it can run directly out of Netbeans using the above example.

The final application supposedly is an executable JAR file. To run this JAR 'standalone', put everything from the VLC program folder into the root directory of your application together with your executable JAR file. The distribution directory of your application would look something like this:

/myapp_root/myapp.jar
/myapp_root/[all files and directories from the VLC application directory]
/myapp_root/lib/[jvlc jar file]

With Netbeans any libraries such as the jvlc library jar file are put into the lib directory during build by default. This can be customised inside Netbeans too or a myapp_root directory such as the above can be built manually.
Last edited by uhilger on 29 Jan 2009 15:56, edited 2 times in total.

raaaa
New Cone
New Cone
Posts: 8
Joined: 13 Jan 2009 11:33

Re: GUIDE: Programmatic Access to VLC from Java in Windows

Postby raaaa » 29 Jan 2009 14:05

I've been succesfull in integrating vlc in java using the same jvlc binaries. The steps i took are identical.
I am using the latest release of vlc (0.9.8a) right now, all seems to be running quite well.
I'm wondering whether new jvlc releases will be released? It seems quite silent at their website.

waqasdaar
New Cone
New Cone
Posts: 2
Joined: 18 Feb 2009 01:51

Re: GUIDE: Programmatic Access to VLC from Java in Windows

Postby waqasdaar » 18 Feb 2009 01:54

Hi,

I am not able to download this package

http://nightlies.videolan.org/build/win ... -win32.zip

does any one have then please mail me at this address.

waqasdaar@gmail.com

I will be very thankful to you.

Cheers

waqasdaar
New Cone
New Cone
Posts: 2
Joined: 18 Feb 2009 01:51

Re: GUIDE: Programmatic Access to VLC from Java in Windows

Postby waqasdaar » 18 Feb 2009 15:37

Hi Guys,

Problem is solved now. Can you tell me If I want to recieve RTSP streaming using JVLC. How Can I dot that any pointer would be highly appreciated.

Thanks

godotvt
New Cone
New Cone
Posts: 9
Joined: 03 Mar 2009 17:19

Re: GUIDE: Programmatic Access to VLC from Java in Windows

Postby godotvt » 06 Mar 2009 12:13

If use this pass when i press run i have this proble:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jvlc in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at org.videolan.jvlc.JVLC.<clinit>(JVLC.java:37)
at OpenProgramTest.VlcDemo.main(VlcDemo.java:16)
I try this solution

Code: Select all

NativeLibrary.addSearchPath("libvlc", "C:\\Documents and Settings\\gianpaolot\\Desktop\\vlcinstaller\\vlc\\vlc-0.9.2"); JVLC jvlc; Video video; Audio audio; MediaPlayer mp; MediaDescriptor ds; Canvas jvcanvas; JPanel jvcc; String[] p=new String[3]; p[0]="--vvv"; p[1]=pathplugin; p[2]="--no-plugins-cache"; //p[1]="--help"; jvlc= new JVLC(p); jvlc.play("c:/virgola_Il_Gattino.mp3"); ds = new MediaDescriptor(jvlc, "c:/virgola_Il_Gattino.mp3"); mp = ds.getMediaPlayer();

But if use vlc 0.9.x during the run don't find libvcl else i use 0.8.x after the run the problem is new_lib_media!

why it's so difficult tu use this library!

I must create a class with several method to controll vlc play but these have to use from controller of web application!

I write any post but nobody tell me solution or help

Thank you
Gianpaolo


Return to “VLC media player for Windows Troubleshooting”

Who is online

Users browsing this forum: No registered users and 37 guests