Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vlcj 3.0.0 fails to initialize vlc #226

Closed
krheinwald opened this issue Jan 12, 2014 · 48 comments
Closed

vlcj 3.0.0 fails to initialize vlc #226

krheinwald opened this issue Jan 12, 2014 · 48 comments

Comments

@krheinwald
Copy link

Plain BasicEmbeddedMediaPlayerComponentTest.java with additional NativeDiscovery().discover() at the start.

VLC 2.1.2 installed and found by NativeDiscovery().discover()

Same sample from 2.4.1 works fine.

Output:

jna.library.path: null
java.class.path: C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-4.0.0.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-platform-4.0.0.jar;C:\Users\krheinwald\Development\NB_Projects\vlcj\build\classes

---
vlcj: (Info.java:70)                                 | INFO  | vlcj: <version not available>
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
vlcj: (NativeDiscovery.java:98)                      | DEBUG | discover()
vlcj: (NativeDiscovery.java:101)                     | DEBUG | jnaLibraryPath=null
vlcj: (NativeDiscovery.java:106)                     | DEBUG | discoveryStrategy=uk.co.caprica.vlcj.discovery.linux.DefaultLinuxNativeDiscoveryStrategy@18f1a31
vlcj: (NativeDiscovery.java:109)                     | DEBUG | supported=false
vlcj: (NativeDiscovery.java:106)                     | DEBUG | discoveryStrategy=uk.co.caprica.vlcj.discovery.windows.DefaultWindowsNativeDiscoveryStrategy@c550
vlcj: (NativeDiscovery.java:109)                     | DEBUG | supported=true
vlcj: (AbstractNativeDiscoveryStrategy.java:49)      | DEBUG | discover()
vlcj: (WindowsRuntimeUtil.java:56)                   | DEBUG | getVlcInstallDir()
vlcj: (AbstractNativeDiscoveryStrategy.java:54)      | DEBUG | directoryNames=[., C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common, C:\windows\system32, C:\windows, C:\windows\System32\Wbem, C:\windows\System32\WindowsPowerShell\v1.0\, c:\Program Files\WIDCOMM\Bluetooth Software\, c:\Program Files\WIDCOMM\Bluetooth Software\syswow64, C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\, C:\Program Files (x86)\Common Files\Teleca Shared, C:\Program Files (x86)\Common Files\Acronis\SnapAPI\, C:\Program Files (x86)\Acronis\TrueImageHome\, C:\Program Files (x86)\QuickTime\QTSystem\, C:\Program Files\Intel\WiFi\bin\, C:\Program Files\Common Files\Intel\WirelessCommon\, C:\Program Files (x86)\GnuPG\pub, C:\Program Files (x86)\Atmel\Flip 3.4.3\bin, C:\Program Files\Intel\WiFi\bin\, C:\Program Files\Common Files\Intel\WirelessCommon\, C:\Program Files (x86)\VideoLAN\VLC]
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=.
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\windows\system32
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\windows
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\windows\System32\Wbem
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\windows\System32\WindowsPowerShell\v1.0\
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=c:\Program Files\WIDCOMM\Bluetooth Software\
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=c:\Program Files\WIDCOMM\Bluetooth Software\syswow64
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files (x86)\Common Files\Teleca Shared
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files (x86)\Common Files\Acronis\SnapAPI\
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files (x86)\Acronis\TrueImageHome\
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files (x86)\QuickTime\QTSystem\
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files\Intel\WiFi\bin\
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files\Common Files\Intel\WirelessCommon\
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files (x86)\GnuPG\pub
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files (x86)\Atmel\Flip 3.4.3\bin
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files\Intel\WiFi\bin\
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files\Common Files\Intel\WirelessCommon\
vlcj: (AbstractNativeDiscoveryStrategy.java:95)      | DEBUG | Failed to matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:57)      | DEBUG | directoryName=C:\Program Files (x86)\VideoLAN\VLC
vlcj: (AbstractNativeDiscoveryStrategy.java:85)      | DEBUG | Matched 'libvlc.dll' in 'C:\Program Files (x86)\VideoLAN\VLC'
vlcj: (AbstractNativeDiscoveryStrategy.java:85)      | DEBUG | Matched 'libvlccore.dll' in 'C:\Program Files (x86)\VideoLAN\VLC'
vlcj: (AbstractNativeDiscoveryStrategy.java:88)      | DEBUG | Matched all required files
vlcj: (AbstractNativeDiscoveryStrategy.java:63)      | DEBUG | result=C:\Program Files (x86)\VideoLAN\VLC
vlcj: (NativeDiscovery.java:112)                     | DEBUG | path=C:\Program Files (x86)\VideoLAN\VLC
vlcj: (NativeDiscovery.java:114)                     | INFO  | Discovery found libvlc at 'C:\Program Files (x86)\VideoLAN\VLC'
vlcj: (LibVlcFactory.java:164)                       | INFO  | vlc: 2.1.2 Rincewind, changeset 2.1.2-0-ga4c4876
vlcj: (LibVlcFactory.java:165)                       | INFO  | libvlc: C:\Program Files (x86)\VideoLAN\VLC\libvlc.dll
vlcj: (MediaPlayerFactory.java:259)                  | DEBUG | MediaPlayerFactory(libvlc=Proxy interface to Native Library <C:\Program Files (x86)\VideoLAN\VLC\libvlc.dll@1630535680>,libvlcArgs=[--video-title=vlcj video output, --no-snapshot-preview, --quiet, --quiet-synchro, --sub-filter=logo:marq, --intf=dummy])
vlcj: (MediaPlayerFactory.java:261)                  | DEBUG | jna.library.path=null
vlcj: (MediaPlayerFactory.java:275)                  | DEBUG | instance=null
vlcj: (MediaPlayerFactory.java:277)                  | ERROR | Failed to initialise libvlc
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Failed to initialise libvlc.
@caprica
Copy link
Owner

caprica commented Jan 12, 2014

What happens if you remove the NativeDiscovery and add this instead?

NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "c:/program files (x86)/videolan/vlc");

?

I can't think of anything I changed in this area.

I notice you are apparently not using an official build of vlcj because of this in the log... ?

vlcj: (Info.java:70)      | INFO  | vlcj: <version not available>

What happens if you use an official build?

@krheinwald
Copy link
Author

Log after applying the change you suggested:

vlcj: (Info.java:70)                                 | INFO  | vlcj: <version not available>
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
vlcj: (LibVlcFactory.java:164)                       | INFO  | vlc: 2.1.2 Rincewind, changeset 2.1.2-0-ga4c4876
vlcj: (LibVlcFactory.java:165)                       | INFO  | libvlc: c:\program files (x86)\videolan\vlc\libvlc.dll
vlcj: (MediaPlayerFactory.java:259)                  | DEBUG | MediaPlayerFactory(libvlc=Proxy interface to Native Library <c:\program files (x86)\videolan\vlc\libvlc.dll@1732575232>,libvlcArgs=[--video-title=vlcj video output, --no-snapshot-preview, --quiet, --quiet-synchro, --sub-filter=logo:marq, --intf=dummy])
vlcj: (MediaPlayerFactory.java:261)                  | DEBUG | jna.library.path=null
vlcj: (MediaPlayerFactory.java:275)                  | DEBUG | instance=null
vlcj: (MediaPlayerFactory.java:277)                  | ERROR | Failed to initialise libvlc

The .jars and test-sources were taken/build straight from http://vlcj.googlecode.com/files/vlcj-3.0.0-dist.tar.gz

Result when I use vlcj-3.0.0.jar from http://vlcj.googlecode.com/files/vlcj-3.0.0-dist.tar.gz instead of the one build from the sources:

vlcj: (Info.java:70)                                 | INFO  | vlcj: 3.0.0
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
vlcj: (LibVlcFactory.java:164)                       | INFO  | vlc: 2.1.2 Rincewind, changeset 2.1.2-0-ga4c4876
vlcj: (LibVlcFactory.java:165)                       | INFO  | libvlc: c:\program files (x86)\videolan\vlc\libvlc.dll
vlcj: (MediaPlayerFactory.java:259)                  | DEBUG | MediaPlayerFactory(libvlc=Proxy interface to Native Library <c:\program files (x86)\videolan\vlc\libvlc.dll@1732575232>,libvlcArgs=[--video-title=vlcj video output, --no-snapshot-preview, --quiet, --quiet-synchro, --sub-filter=logo:marq, --intf=dummy])
vlcj: (MediaPlayerFactory.java:261)                  | DEBUG | jna.library.path=null
vlcj: (MediaPlayerFactory.java:275)                  | DEBUG | instance=null
vlcj: (MediaPlayerFactory.java:277)                  | ERROR | Failed to initialise libvlc

Interesting. How does the version info get lost when compiling from source?

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

What I can see is that the native library is being found correctly but the first call to get a new libvlc instance is what is failing. So I can only assume that something is wrong with the factory arguments that are used to make that call. Which is pretty incredulous if you say it works unchanged with the previous version of vlcj.

There may be some more information available via the native log (usually you just need to pass "-vvv" when you create the factory to get that log).

It's working just fine for me, and I'm pretty sure I changed nothing in that area, so I don't know what's wrong I'm afraid.

As to why the version info gets lost when compiling from source, well if you use Maven it does not get lost - the version information comes from a dynamically tokenised properties file which is populated by Maven using the version from the POM. If you don't use Maven, this tokenisation won't happen.

@krheinwald
Copy link
Author

Ran the sample file from 3.0.0 (with the changes discussed above) against vlcj 2.4.2 and jna-3.5.2 - works fine.

jna.library.path: null
java.class.path: C:\Users\krheinwald\Development\ThirdParty\vlcj-2.4.1\jna-3.5.2.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-2.4.1\jna-platform-3.5.2.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-2.4.1\vlcj-2.4.1.jar;C:\Users\krheinwald\Development\NB_Projects\vlcj\build\classes
vlcj: (Info.java:70)                                 | INFO  | vlcj: 2.4.1
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
vlcj: (LibVlcFactory.java:164)                       | INFO  | vlc: 2.1.2 Rincewind, changeset 2.1.2-0-ga4c4876
vlcj: (LibVlcFactory.java:165)                       | INFO  | libvlc: c:\program files (x86)\videolan\vlc\libvlc.dll
vlcj: (MediaPlayerFactory.java:236)                  | DEBUG | MediaPlayerFactory(libvlc=Proxy interface to Native Library <c:\program files (x86)\videolan\vlc\libvlc.dll@1627389952>,libvlcArgs=[--ignore-config, --video-title=vlcj video output, --no-plugins-cache, --no-video-title-show, --no-snapshot-preview, --quiet, --quiet-synchro, --sub-filter=logo:marq, --intf=dummy])
vlcj: (MediaPlayerFactory.java:238)                  | DEBUG | jna.library.path=null
vlcj: (MediaPlayerFactory.java:261)                  | DEBUG | instance=native@0x500e948 (uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@500e948)
vlcj: (MediaPlayerFactory.java:498)                  | DEBUG | newEmbeddedMediaPlayer(fullScreenStrategy=null)
...

Using Netbeans to build from source...

@krheinwald
Copy link
Author

Nothing has been changed in terms of parameters in the example BasicEmbeddedMediaPlayerComponentTest.java.

As far as I can see, the EmbeddedMediaPlayerComponent constructor used in BasicEmbeddedMediaPlayerComponentTest does not even allow to specifiy extra parameters?

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

Maybe something going wrong with the change from JNA 3.5.2 to JNA 4.0.0, maybe in relation to String handling. I really don't know right now.

I'm pretty sure I changed nothing in vlcj related to this.

@krheinwald
Copy link
Author

There is difference in the vlc parameters in EmbeddedMediaPlayerComponent from 2.4.1 vs. 3.0.0:

2.4.1:

        "--ignore-config",
        "--video-title=vlcj video output",
        "--no-plugins-cache",
        "--no-video-title-show",
        "--no-snapshot-preview",
        "--quiet",
        "--quiet-synchro",
        "--sub-filter=logo:marq",
        "--intf=dummy"

3.0.0:

        "--video-title=vlcj video output",
        "--no-snapshot-preview",
        "--quiet",
        "--quiet-synchro",
        "--sub-filter=logo:marq",
        "--intf=dummy"```

coudl that be the culprit? Should I add "-vvv' there?

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

What happens if you run:

uk.co.caprica.vlcj.test.factory.ApplicationIdTest
uk.co.caprica.vlcj.test.factory.FilterTest

@krheinwald
Copy link
Author

That hint on jna did it: vlcj-3.0.0 + jna-3.5.2 works!

java.class.path: C:\Users\krheinwald\Development\ThirdParty\vlcj-2.4.1\jna-3.5.2.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-2.4.1\jna-platform-3.5.2.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\vlcj-3.0.0.jar;C:\Users\krheinwald\Development\NB_Projects\vlcj\build\classes
vlcj: (Info.java:70)                                 | INFO  | vlcj: 3.0.0
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
vlcj: (LibVlcFactory.java:164)                       | INFO  | vlc: 2.1.2 Rincewind, changeset 2.1.2-0-ga4c4876
vlcj: (LibVlcFactory.java:165)                       | INFO  | libvlc: c:\program files (x86)\videolan\vlc\libvlc.dll
vlcj: (MediaPlayerFactory.java:259)                  | DEBUG | MediaPlayerFactory(libvlc=Proxy interface to Native Library <c:\program files (x86)\videolan\vlc\libvlc.dll@1682309120>,libvlcArgs=[--video-title=vlcj video output, --no-snapshot-preview, --quiet, --quiet-synchro, --sub-filter=logo:marq, --intf=dummy])
vlcj: (MediaPlayerFactory.java:261)                  | DEBUG | jna.library.path=null
vlcj: (MediaPlayerFactory.java:275)                  | DEBUG | instance=native@0x528e8f8 (uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@528e8f8)
vlcj: (MediaPlayerFactory.java:283)                  | DEBUG | equalizerAvailable=false
vlcj: (MediaPlayerFactory.java:656)                  | DEBUG | newEmbeddedMediaPlayer(fullScreenStrategy=null)

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

I would be interested to know if you add those "missing" factory arguments one-at-a-time with JNA 4.0.0 if it starts working or not. Those factory arguments were removed because they were apparently the defaults.

Leaving that aside, the fact that it fails with JNA 4.0.0 is quite worrying and will likely be a PITA to track down.

@krheinwald
Copy link
Author

Both tests work with vlcj-3.0.0 and jna-3.5.2, but not with jna-4.0.0.

@krheinwald
Copy link
Author

So as a workaround, should I continue to use jna-3.5.2 with vlcj-3.0.0?

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

Well if it works, I suppose. I don't know if something else will break or not.

If you don't mind one more test...

uk.co.caprica.vlcj.test.bare.BareBonesTest

For the record, JNA 4.0.0 is working just fine for me, but I don't use Win7.

@krheinwald
Copy link
Author

uk.co.caprica.vlcj.test.bare.BareBonesTest fails with both jna-3.5.2 and jna-4.0.0. VLC was re-installed minutes before.

Using jna-3.5.2:

java.class.path: C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\vlcj-3.0.0.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-3.5.2.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-platform-3.5.2.jar;C:\Users\krheinwald\Development\NB_Projects\vlcj\build\classes
vlcj: (Info.java:70)                                 | INFO  | vlcj: 3.0.0
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
vlcj: (NativeDiscovery.java:114)                     | INFO  | Discovery found libvlc at 'C:\Program Files (x86)\VideoLAN\VLC'
[0529dcf4] main libvlc error: No plugins found! Check your VLC installation.
Exception in thread "main" java.lang.Error: Invalid memory access
    at com.sun.jna.Native.invokePointer(Native Method)
    at com.sun.jna.Function.invokePointer(Function.java:470)
    at com.sun.jna.Function.invoke(Function.java:404)
    at com.sun.jna.Function.invoke(Function.java:315)
    at com.sun.jna.Library$Handler.invoke(Library.java:212)
    at com.sun.proxy.$Proxy1.libvlc_media_player_new(Unknown Source)
    at uk.co.caprica.vlcj.test.bare.BareBonesTest.main(BareBonesTest.java:49)
Java Result: 1

Using jna-4.0.0:

java.class.path: C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\vlcj-3.0.0.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-4.0.0.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-platform-4.0.0.jar;C:\Users\krheinwald\Development\NB_Projects\vlcj\build\classes
vlcj: (Info.java:70)                                 | INFO  | vlcj: 3.0.0
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
vlcj: (NativeDiscovery.java:114)                     | INFO  | Discovery found libvlc at 'C:\Program Files (x86)\VideoLAN\VLC'
[0507dcf4] main libvlc error: No plugins found! Check your VLC installation.
Exception in thread "main" java.lang.Error: Invalid memory access
    at com.sun.jna.Native.invokePointer(Native Method)
    at com.sun.jna.Function.invokePointer(Function.java:470)
    at com.sun.jna.Function.invoke(Function.java:404)
    at com.sun.jna.Function.invoke(Function.java:315)
    at com.sun.jna.Library$Handler.invoke(Library.java:212)
    at com.sun.proxy.$Proxy1.libvlc_media_player_new(Unknown Source)
    at uk.co.caprica.vlcj.test.bare.BareBonesTest.main(BareBonesTest.java:49)
Java Result: 1```

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

That 'bare bones' test is failing because "instance" is null, i.e. the same problem that you originally described.

However this time we also see a "no plugins found" error in the native log... usually the fix for that is to specify -DVLC_PLUGIN_PATH=/directory-that-contains/vlc/plugins.

That should not be necessary because libvlc is supposed to be able to find its plugins automatically, e.g. by looking in the [directory-that-contains-libvlc.dll]/vlc/plugins, but nevertheless sometimes it is necessary (usually on Windows but rarely on Linux).

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

By the way, the native log is being suppressed in the other tests because of the use of "--quiet" in the factory args.

@krheinwald
Copy link
Author

That should not be necessary because libvlc is supposed to be able to find its plugins automatically, e.g. by looking in the [directory-that-contains-libvlc.dll]/vlc/plugins.

This workaround would be rather impractical when vlcj is distributed with an application - anything I can do to help to debug vlcj not finding the plugin directory?

Removed '-quiet' from the parameters:

jna-3.5.2 (works):

jna.library.path: null
java.class.path: C:\Users\krheinwald\Development\NB_Projects\vlcj\build\classes;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-3.5.2.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-platform-3.5.2.jar
vlcj: (Info.java:70)                                 | INFO  | vlcj: <version not available>
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
vlcj: (LibVlcFactory.java:164)                       | INFO  | vlc: 2.1.2 Rincewind, changeset 2.1.2-0-ga4c4876
vlcj: (LibVlcFactory.java:165)                       | INFO  | libvlc: c:\program files (x86)\videolan\vlc\libvlc.dll
vlcj: (MediaPlayerFactory.java:259)                  | DEBUG | MediaPlayerFactory(libvlc=Proxy interface to Native Library <c:\program files (x86)\videolan\vlc\libvlc.dll@1682309120>,libvlcArgs=[--video-title=vlcj video output, --no-snapshot-preview, --sub-filter=logo:marq, --intf=dummy])
vlcj: (MediaPlayerFactory.java:261)                  | DEBUG | jna.library.path=null
vlcj: (MediaPlayerFactory.java:275)                  | DEBUG | instance=native@0x309eb0 (uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@309eb0)
vlcj: (MediaPlayerFactory.java:283)                  | DEBUG | equalizerAvailable=false
vlcj: (MediaPlayerFactory.java:656)                  | DEBUG | newEmbeddedMediaPlayer(fullScreenStrategy=null)
vlcj: (DefaultMediaPlayer.java:186)                  | DEBUG | DefaultMediaPlayer(libvlc=Proxy interface to Native Library <c:\program files (x86)\videolan\vlc\libvlc.dll@1682309120>, instance=native@0x309eb0 (uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@309eb0))
vlcj: (DefaultMediaPlayer.java:1641)                 | DEBUG | createInstance()

jna-4.0.0 (not):

jna.library.path: null
java.class.path: C:\Users\krheinwald\Development\NB_Projects\vlcj\build\classes;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-4.0.0.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-platform-4.0.0.jar
vlcj: (Info.java:70)                                 | INFO  | vlcj: <version not available>
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
vlcj: (LibVlcFactory.java:164)                       | INFO  | vlc: 2.1.2 Rincewind, changeset 2.1.2-0-ga4c4876
vlcj: (LibVlcFactory.java:165)                       | INFO  | libvlc: c:\program files (x86)\videolan\vlc\libvlc.dll
vlcj: (MediaPlayerFactory.java:259)                  | DEBUG | MediaPlayerFactory(libvlc=Proxy interface to Native Library <c:\program files (x86)\videolan\vlc\libvlc.dll@1732575232>,libvlcArgs=[--video-title=vlcj video output, --no-snapshot-preview, --sub-filter=logo:marq, --intf=dummy])
vlcj: (MediaPlayerFactory.java:261)                  | DEBUG | jna.library.path=null
[051dea5c] main libvlc error: No plugins found! Check your VLC installation.
vlcj: (MediaPlayerFactory.java:275)                  | DEBUG | instance=null
vlcj: (MediaPlayerFactory.java:277)                  | ERROR | Failed to initialise libvlc
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Failed to initialise libvlc.

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

This is the critical piece of information:

[051dea5c] main libvlc error: No plugins found! Check your VLC installation.

There is no reasonable explanation that I can see why this would be different with vlcj 3.0.0, nor with JNA 4.0.0.

I thought it might be related to the plugins cache, but you said adding that switch back in still failed.

In terms of how practical the system property solution is, well I suppose NativeDiscovery could be extended to set that system property programmatically once it found the correct plugins directory.

I still think there's something else amiss here.

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

Also confusing the picture is that when you quote this in your log:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Failed to initialise libvlc.

Where is the rest of the message and the stack trace? There should be a long message describing precisely the plugin-path issue and what can be done to resolve it.

@krheinwald
Copy link
Author

Uninstalled VLC. Installed VLC 2.1.2 fresh, selecting 'Delete Settings and Cache'.

Added

NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "c:/program files (x86)/videolan/vlc");
System.setProperty("VLC_PLUGIN_PATH", "c:\program files (x86)\videolan\vlc\plugins");

to BareBonesTest.java.

Fails both with vlcj-3.0.0 and jna-3.5.2 or 4.0.0:

jna.library.path: null
VLC_PLUGIN_PATH: c:\program files (x86)\videolan\vlc\plugins
java.class.path: C:\Users\krheinwald\Development\NB_Projects\vlcj\build\classes;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-4.0.0.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-platform-4.0.0.jar
[version information missing as the sources were recompiled locally after removing -quiet parameter] vlcj: (Info.java:70)                                 | INFO  | vlcj: <version not available>
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
[00939ee4] main libvlc error: No plugins found! Check your VLC installation.
Exception in thread "main" java.lang.Error: Invalid memory access

Works fine with vlcj2.4.1, even without setting VLC_PLUGIN_PATH:

jna.library.path: null
VLC_PLUGIN_PATH: null
java.class.path: C:\Users\krheinwald\Development\ThirdParty\vlcj-2.4.1\jna-3.5.2.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-2.4.1\jna-platform-3.5.2.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-2.4.1\vlcj-2.4.1.jar;C:\Users\krheinwald\Development\NB_Projects\vlcj\build\classes
vlcj: (Info.java:70)                                 | INFO  | vlcj: 2.4.1
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
[This line was displayed, after the video played] BUILD SUCCESSFUL (total time: 10 seconds)

@krheinwald
Copy link
Author

Full stacktrace for EmbeddedMediaPlayerComponent.java, vlcj-3.0.0.jar (without -quiet) and jna-4.0.0:

jna.library.path: null
VLC_PLUGIN_PATH: c:\program files (x86)\videolan\vlc\plugins
java.class.path: C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-4.0.0.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-platform-4.0.0.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\vlcj-3.0.0.jar;C:\Users\krheinwald\Development\NB_Projects\vlcj\build\classes
vlcj: (Info.java:70)                                 | INFO  | vlcj: 3.0.0
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
vlcj: (LibVlcFactory.java:164)                       | INFO  | vlc: 2.1.2 Rincewind, changeset 2.1.2-0-ga4c4876
vlcj: (LibVlcFactory.java:165)                       | INFO  | libvlc: c:\program files (x86)\videolan\vlc\libvlc.dll
vlcj: (MediaPlayerFactory.java:259)                  | DEBUG | MediaPlayerFactory(libvlc=Proxy interface to Native Library <c:\program files (x86)\videolan\vlc\libvlc.dll@1627389952>,libvlcArgs=[--video-title=vlcj video output, --no-snapshot-preview, --quiet, --quiet-synchro, --sub-filter=logo:marq, --intf=dummy])
vlcj: (MediaPlayerFactory.java:261)                  | DEBUG | jna.library.path=null
vlcj: (MediaPlayerFactory.java:271)                  | DEBUG | VLC_PLUGIN_PATH=c:\program files (x86)\videolan\vlc\plugins
vlcj: (MediaPlayerFactory.java:275)                  | DEBUG | instance=null
vlcj: (MediaPlayerFactory.java:277)                  | ERROR | Failed to initialise libvlc
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Failed to initialise libvlc.

This is most often caused either by an invalid vlc option begin passed when creating a MediaPlayerFactory or by libvlc being unable to locate the required plugins.

If libvlc is unable to locate the required plugins the instructions below may help:

In the text below <libvlc-path> represents the name of the directory containing "libvlc.dll" and "libvlccore.dll" and <plugins-path> represents the name of the directory containing the vlc plugins...

For libvlc to function correctly the vlc plugins must be available, there are a number of different ways to achieve this:
 1. Make sure the plugins are installed in the "<libvlc-path>/plugins" directory, this should be the case with a normal vlc installation.
 2. Set the VLC_PLUGIN_PATH operating system environment variable to point to "<plugins-path>".

More information may be available in the log, specify -Dvlcj.log=DEBUG on the command-line when starting your application.


    at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:279)
    at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:236)
    at uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent.onGetMediaPlayerFactory(EmbeddedMediaPlayerComponent.java:278)
    at uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent.<init>(EmbeddedMediaPlayerComponent.java:168)
    at uk.co.caprica.vlcj.test.component.BasicEmbeddedMediaPlayerComponentTest.<init>(BasicEmbeddedMediaPlayerComponentTest.java:84)
    at uk.co.caprica.vlcj.test.component.BasicEmbeddedMediaPlayerComponentTest.<init>(BasicEmbeddedMediaPlayerComponentTest.java:37)
    at uk.co.caprica.vlcj.test.component.BasicEmbeddedMediaPlayerComponentTest$1.run(BasicEmbeddedMediaPlayerComponentTest.java:73)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

@krheinwald
Copy link
Author

Cloned the github repo and build through maven. Even after setting NATIVE_LIBRARY_SEARCH_PATH path in VlcjTest.java, the test fails:

--- maven-surefire-plugin:2.10:test (default-test) @ vlcj ---
Surefire report directory: C:\Users\krheinwald\Development\NB_Projects\vlcj-github\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
vlcj: (VlcjTest.java:79)                             | INFO  | Explicitly adding JNA native library search path: 'c:/program files (x86)/videolan/vlc'
vlcj: (Info.java:70)                                 | INFO  | vlcj: 3.0.1-SNAPSHOT
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
vlcj: (LibVlcFactory.java:164)                       | INFO  | vlc: 2.1.2 Rincewind, changeset 2.1.2-0-ga4c4876
vlcj: (LibVlcFactory.java:165)                       | INFO  | libvlc: c:\program files (x86)\videolan\vlc\libvlc.dll
[0056a664] main libvlc error: No plugins found! Check your VLC installation.
vlcj: (MediaPlayerFactory.java:277)                  | ERROR | Failed to initialise libvlc
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
    at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
    at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: java.lang.RuntimeException: Failed to initialise libvlc.
This is most often caused either by an invalid vlc option being passed when creating a MediaPlayerFactory or by libvlc being unable to locate the required plugins.
If libvlc is unable to locate the required plugins the instructions below may help:
In the text below <libvlc-path> represents the name of the directory containing "libvlc.dll" and "libvlccore.dll" and <plugins-path> represents the name of the directory containing the vlc plugins...
For libvlc to function correctly the vlc plugins must be available, there are a number of different ways to achieve this:
 1. Make sure the plugins are installed in the "<libvlc-path>/plugins" directory, this should be the case with a normal vlc installation.
 2. Set the VLC_PLUGIN_PATH operating system environment variable to point to "<plugins-path>".
More information may be available in the log, specify -Dvlcj.log=DEBUG on the command-line when starting your application.
    at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:279)
    at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:236)
    at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:216)
    at uk.co.caprica.vlcj.test.aspect.AspectTest.<init>(AspectTest.java:123)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:374)
    at org.apache.maven.surefire.junit.PojoTestSet.<init>(PojoTestSet.java:64)
    at org.apache.maven.surefire.junit.JUnit3Provider.createTestSet(JUnit3Provider.java:103)
    at org.apache.maven.surefire.junit.JUnit3Provider.invoke(JUnit3Provider.java:93)
    ... 9 more

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

The particular fix here is to set the VLC_PLUGIN_PATH environment variable, not Java system property. Usually this would be done in a shell-script I suppose.

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

Anyway, I too can conclusively confirm that using JNA 4.0.0 rather than 3.5.2 is what is causing the problem here.

I have no idea why that might be the case, but it's 100% repeatable if you swap the different versions of the JNA jar files in and out.

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

@krheinwald
Copy link
Author

VLC_PLUGIN_PATH environment variable

Difficult from inside an IDE... You suggested in an earlier comment:

usually the fix for that is to specify -DVLC_PLUGIN_PATH=/directory-that-contains/vlc/plugins.

This is the same as using

System.setProperty("VLC_PLUGIN_PATH", "/directory-that-contains/vlc/plugins");

inside the java code...

I just checked out tag 2.4.1 and it build ok after setting NATIVE_LIBRARY_SEARCH_PATH, but I guess this is not surprise after your bug report against jna?

--- maven-surefire-plugin:2.10:test (default-test) @ vlcj ---
Surefire report directory: C:\Users\krheinwald\Development\NB_Projects\vlcj-github\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
vlcj: (VlcjTest.java:79)                             | INFO  | Explicitly adding JNA native library search path: 'c:/program files (x86)/videolan/vlc'
vlcj: (Info.java:70)                                 | INFO  | vlcj: 2.4.1
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
vlcj: (LibVlcFactory.java:164)                       | INFO  | vlc: 2.1.2 Rincewind, changeset 2.1.2-0-ga4c4876
vlcj: (LibVlcFactory.java:165)                       | INFO  | libvlc: c:\program files (x86)\videolan\vlc\libvlc.dll
Running uk.co.caprica.vlcj.test.aspect.AspectTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec

@krheinwald
Copy link
Author

Are you sure it's jna-4.0.0?

BareBonesTest.java failed above with vlcj-3.0.0 and both jna-3.5.2 or 4.0.0.

It works with vlcj-2.4.1 and both jna-3.5.2 and 4.0.0, though!?!

jna.library.path: null
java.class.path: C:\Users\krheinwald\Development\ThirdParty\vlcj-2.4.1\vlcj-2.4.1.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-4.0.0.jar;C:\Users\krheinwald\Development\ThirdParty\vlcj-3.0.0\jna-platform-4.0.0.jar;C:\Users\krheinwald\Development\NB_Projects\vlcj-test\build\classes
vlcj: (Info.java:70)                                 | INFO  | vlcj: 2.4.1
vlcj: (Info.java:71)                                 | INFO  | java: 1.7.0_45 Oracle Corporation
vlcj: (Info.java:72)                                 | INFO  | java home: C:\Program Files (x86)\Java\jdk1.7.0_45\jre
vlcj: (Info.java:73)                                 | INFO  | os: Windows 7 6.1 x86
[Displayed after 10s of video played] BUILD SUCCESSFUL (total time: 10 seconds)

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

To address a few of your comments...

There is too much going on in this issue that might be the same thing or might not...

I have a 100% repeatable before and after test case where the only thing I change is to go from JNA 3.5.2 to JNA 4.0.0 and back again. That's also what you observed earlier. So it looks to me like there is some problem that may be related to JNA somehow. That's not an unreasonable conclusion based on what I've observed.

public class DiscoveryTest {

    public static void main(String[] args) {
        new NativeDiscovery().discover();

        LibVlc libvlc = LibVlc.INSTANCE;
        System.out.println("libvlc=" + libvlc);
        libvlc_instance_t instance = libvlc.libvlc_new(args.length, args);
        System.out.println("Instance=" + instance);

        System.out.println("FINISHED!");
    }
}

Yes, VLC_PLUGIN_PATH needs to be set as an environment variable, not a system property. I was wrong in my earlier comment. But then again I was in a state of confusion about the whole thing because it makes not much sense to me...

If it is really true like you say that vlcj 2.4.1 works with JNA 4.0.0, then as far as I can see it can only be related to the use of the plugin-cache switch on the factory, and I assumed you checked that already based on the earlier comments in this ticket.

Finally, you say it's "difficult" to set the environment property inside an IDE, that's not true at least if you use Eclipse - it's very easy to set. Presumably NetBeans has equivalent functionality?

@krheinwald
Copy link
Author

... set the environment property inside an IDE [...] Presumably NetBeans has equivalent functionality?

Unfortunately not.

public class DiscoveryTest {...}

When playing around with this class, I got confusing results from combinations of vlcj and jna working or not.

So i started from scratch, pulled all jars from the distribution zips before the test and did a re-install of VLC 2.1.2 with 'Clear Settings and Cache' in between runs. Turned out the order of vlcj and jna in the classpath matters as well!

Not sure whether this helps or not, but there are combination where jna-3.5.2 fails and jna-4.0.0.jar works, only vlcj 3.0.0 and jna-4.0.0 together don't work, no matter the order.

Summary:

vlcj-2.4.1.jar;jna-3.5.2.jar: +
jna-3.5.2.jar;vlcj-2.4.1.jar: +

vlcj-2.4.1.jar;jna-4.0.0.jar: +
jna-4.0.0.jar;vlcj-2.4.1.jar: -

vlcj-3.0.0.jar;jna-3.5.2.jar: -
jna-3.5.2.jar;vlcj-3.0.0.jar: +

vlcj-3.0.0.jar;jna-4.0.0.jar: -
jna-4.0.0.jar;vlcj-3.0.0.jar: -

[Test output, shortened for readability]

java.class.path: D:\vlcj-2.4.1.jar;D:\jna-3.5.2.jar;...
Instance=native@0x3c1790 (uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@3c1790)

java.class.path: D:\jna-3.5.2.jar;D:\vlcj-2.4.1.jar;...
Instance=native@0x791790 (uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@791790)

java.class.path: D:\vlcj-2.4.1.jar;D:\jna-4.0.0.jar;
Instance=native@0x5c1790 (uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@5c1790)

java.class.path: D:\jna-4.0.0.jar;D:\vlcj-2.4.1.jar;...
[0515dd24] main libvlc error: No plugins found! Check your VLC installation.
Instance=null

java.class.path: D:\vlcj-3.0.0.jar;D:\jna-3.5.2.jar;
[0530dcf4] main libvlc error: No plugins found! Check your VLC installation.
Instance=null

java.class.path: D:\jna-3.5.2.jar;D:\vlcj-3.0.0.jar
Instance=native@0x489dc0 (uk.co.caprica.vlcj.binding.internal.libvlc_instance_t@489dc0)

java.class.path: D:\vlcj-3.0.0.jar;D:\jna-4.0.0.jar;
[0516dcf4] main libvlc error: No plugins found! Check your VLC installation.
Instance=null

java.class.path: D:\jna-4.0.0.jar;D:\vlcj-3.0.0.jar;...
[0516dcf4] main libvlc error: No plugins found! Check your VLC installation.
Instance=null

Please let me know if I can be of any help with more information.

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

If you don't mind... in that test code please remove the native discoverer and instead add some hard-coded path like this:

    NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "c:/program files/videolan/vlc");

This should totally eliminate the various versions of vlcj as contributing to this problem.

@ghost ghost assigned caprica Jan 12, 2014
@krheinwald
Copy link
Author

Unchanged:

vlcj-2.4.1.jar;jna-3.5.2.jar: +
jna-3.5.2.jar;vlcj-2.4.1.jar: +

vlcj-2.4.1.jar;jna-4.0.0.jar: +
jna-4.0.0.jar;vlcj-2.4.1.jar: -

vlcj-3.0.0.jar;jna-3.5.2.jar: -
jna-3.5.2.jar;vlcj-3.0.0.jar: +

vlcj-3.0.0.jar;jna-4.0.0.jar: -
jna-4.0.0.jar;vlcj-3.0.0.jar: -

@caprica
Copy link
Owner

caprica commented Jan 12, 2014

So how can a different version of vlcj make a difference... there is no version-specific code here...

    NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "c:/program files/videolan/vlc");
    LibVlc libvlc = LibVlc.INSTANCE;
    libvlc_instance_t instance = libvlc.libvlc_new(args.length, args);

That makes no sense to me at all.

@krheinwald
Copy link
Author

Glad it doesn't make sense to you either. That's the code I have - plus 3 printlns.

Maybe a class from jna is duplicated in vlcj with a different implementaion? Just guessing...

Sorry, can't solve the mystery, only report observations.

@krheinwald
Copy link
Author

Or is it rather the classpath set in the manifest in vlcj-2.4.1.jar pulling in the correct jna-3.5.2.jar - which is still in the same folder - when it is first on the classpath and jna-4.0.0.jar is ignored as all dependencies are resolved? And vice versa for vlcj-3.0.0.jar. Which would basically support your hypothesis of jna-4.0.0.jar being the culprit.

Will check by removing the .jar not mentioned on the classpath...

@krheinwald
Copy link
Author

Yep. The version specific code is the classpath in the manifest.

vlcj-2.4.1.jar;jna-4.0.0.jar: fails when jna-3.5.2.jar is not in the same directory as vlcj-2.4.1.jar
vlcj-2.4.1.jar;jna-4.0.0.jar: succeeds when jna-3.5.2.jar is in the same directory as vlcj-2.4.1.jar

vlcj-3.0.0.jar;jna-3.5.2.jar: fails when jna-4.0.0.jar is in the same directory as vlcj-3.0.0.jar
vlcj-3.0.0.jar;jna-3.5.2.jar: succeeds when jna-4.0.0.jar is not in the same directory as vlcj-3.0.0.jar

Mistery solved. jna-4.0.0.jar it is.

@caprica
Copy link
Owner

caprica commented Jan 13, 2014

I am thinking about reverting back to JNA 3.5.2 for the official build.

@caprica
Copy link
Owner

caprica commented Jan 13, 2014

By the way, thanks for all the testing you did on this.

@caprica
Copy link
Owner

caprica commented Jan 14, 2014

Made vlcj release 3.0.1 built against JNA 3.5.2.

I am unsure how to proceed with JNA 4.0.0, as getting a Win32 build of vlc with more debug statements in it is rather difficult.

@caprica caprica closed this as completed Jan 14, 2014
@Abu-Abdullah
Copy link

the same goes here, with JNA 4, i got the same issue. with 3.5.2 it is working fine. i believe the documentation should be update with this since it is saying JNA 4

I'm using windows 7 64bit. Java8 32 bit.

@caprica
Copy link
Owner

caprica commented Feb 21, 2015

JNA has still not made a new release, it has been almost one year since the last JNA release.

Which documentation are you reading that still says JNA 4?

@caprica
Copy link
Owner

caprica commented Feb 21, 2015

Tracked under #258.

@Abu-Abdullah
Copy link

this page:
http://caprica.github.io/vlcj/

"Version 3.0.0+ of vlcj requires version 4.0.0+ of JNA."

@caprica
Copy link
Owner

caprica commented Feb 21, 2015

Thanks, it is easy to forget to update that page on a different branch when changing the README in the master branch.

@seannybgoode
Copy link

seannybgoode commented May 25, 2016

I'm still getting a plugin error after you guys did the upgrade to JNA 4.1.0.

This is the init code (from the YouTubePlayer.java), slightly modified to point to my vlc dll files:

`public static void main(String[] args) throws Exception
 {
        NativeLibrary.addSearchPath("libvlc", "lib/");
        setLookAndFeel();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                new YouTubePlayer().start();
            }
        });
    }`

This is my stack trace:

[00ad9864] core libvlc error: No plugins found! Check your VLC installation.
82 [AWT-EventQueue-0] DEBUG uk.co.caprica.vlcj.player.MediaPlayerFactory - instance=null
82 [AWT-EventQueue-0] ERROR uk.co.caprica.vlcj.player.MediaPlayerFactory - Failed to initialise libvlc
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Failed to initialise libvlc.

This is most often caused either by an invalid vlc option being passed when creating a MediaPlayerFactory or by libvlc being unable to locate the required plugins.

If libvlc is unable to locate the required plugins the instructions below may help:

In the text below represents the name of the directory containing "libvlc.dll" and "libvlccore.dll" and represents the name of the directory containing the vlc plugins...

For libvlc to function correctly the vlc plugins must be available, there are a number of different ways to achieve this:

  1. Make sure the plugins are installed in the "/plugins" directory, this should be the case with a normal vlc installation.
  2. Set the VLC_PLUGIN_PATH operating system environment variable to point to "".

More information may be available in the log.

at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:300)
at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:259)
at uk.co.caprica.vlcj.player.MediaPlayerFactory.<init>(MediaPlayerFactory.java:239)
at uk.co.caprica.vlcj.test.youtube.YouTubePlayer.<init>(YouTubePlayer.java:150)
at uk.co.caprica.vlcj.test.youtube.YouTubePlayer$1.run(YouTubePlayer.java:90)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

@Abu-Abdullah
Copy link

this is solved by JNA 4.2.0

@dreamw4lker
Copy link

For everyone who experiencing same issue on versions 3.0.0, 3.10.0 or 3.10.1:
There is two ways to solve this problem:

  1. Upgrade/Downgrade to vlcj 3.9.0 which uses JNA 3.5.2
  2. Include latest JNA version into your project and exclude JNA from vlcj, for example, this way:
<dependency>
    <groupId>uk.co.caprica</groupId>
    <artifactId>vlcj</artifactId>
    <version>3.10.1</version>
    <exclusions>
        <exclusion>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
        </exclusion>
        <exclusion>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna-platform</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>net.java.dev.jna</groupId>
    <artifactId>jna</artifactId>
    <version>5.0.0</version>
</dependency>
<dependency>
    <groupId>net.java.dev.jna</groupId>
    <artifactId>jna-platform</artifactId>
    <version>5.0.0</version>
</dependency>

Tested on Windows 10 x64 with VLC 3.0.4 (x64) and Linux Mint 19 x64 with VLC 3.0.3.

@caprica
Copy link
Owner

caprica commented Oct 25, 2018

Interesting that JNA 5.x supposedly mitigates this, but what about #639?

@dreamw4lker
Copy link

Interesting that JNA 5.x supposedly mitigates this, but what about #639?

I have no such problem on JNA 5.0.0, but I use following construction on initialize:

if (isWindows) {
    if (is64bit && isJVM64bit) {
        NativeLibrary.addSearchPath(
                RuntimeUtil.getLibVlcLibraryName(), "C:/Program Files/VideoLAN/VLC/");
    } else {
        NativeLibrary.addSearchPath(
                RuntimeUtil.getLibVlcLibraryName(), "C:/Program Files (x86)/VideoLAN/VLC/");
    }
}

Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);

According to JNA docs, loadLibrary method is now deprecated in JNA 5.0.0, but it's possible to use JNA 4.5.2 instead of 5.0.0 without "fails to initialize vlc" error.

I just want to say that the latest release version of vlcj (3.10.1) contains JNA 4.1.0. In my case, it's OK on Mint 19, but leads to "fails to initialize vlc" error on Windows 10 x64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants