vlcJ java application under MacOS - Exception

This forum is about all development around libVLC.
geostein8888
Cone that earned his stripes
Cone that earned his stripes
Posts: 142
Joined: 15 Dec 2010 11:32

vlcJ java application under MacOS - Exception

Postby geostein8888 » 13 Feb 2011 20:22

Hello,
now when i thought i solved already every problem i cna get, a freind of mine bought a mac book.
and of course my application will not start on it.

VLC Player is installed under Applications/VLC.app
the libvlc and libvlccore dylib's are also copied to the applications start directory

in all case i could'nt find something helpful in this forum

i'll get the following error:

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Unable to load library 'vlc': dlopen(libvlc.dylib, 9): Library not loaded: @loader_path/../lib/libvlccore.4.dylib
Referenced from: /Volumes/NO NAME/msm/libvlc.dylib
Reason: image not found
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:379)
at com.sun.jna.Native.loadLibrary(Native.java:364)
at uk.co.caprica.vlcj.binding.LibVlc.<clinit>(LibVlc.java:83)
at MsmPlayer.MSMPlayer.<init>(MSMPlayer.java:880)
at manestreammedia.MsmManager.startMediaManager(MsmManager.java:207)
at manestreammedia.MsmManager.access$2500(MsmManager.java:32)
at manestreammedia.MsmManager$26.run(MsmManager.java:1149)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:633)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

with regards
Georg

geostein8888
Cone that earned his stripes
Cone that earned his stripes
Posts: 142
Joined: 15 Dec 2010 11:32

Re: vlcJ java application under MacOS - Exception

Postby geostein8888 » 14 Feb 2011 21:36

Hello,
i got now the application running but now i get a new error when i'll play a videofile:

the solution of the first error was to start the jar with the

-Dlna.library.path=/Applications/VLC.app/Contents/MacOS/lib

Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Send patches!
at uk.co.caprica.vlcj.player.embedded.mac.MacEmbeddedMediaPlayer.nativeSetVideoSurface(MacEmbeddedMediaPlayer.java:50)
at uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer.onBeforePlay(EmbeddedMediaPlayer.java:364)
at uk.co.caprica.vlcj.player.MediaPlayer.play(MediaPlayer.java:730)
at uk.co.caprica.vlcj.player.MediaPlayer.playMedia(MediaPlayer.java:290)
at uk.co.caprica.vlcj.player.MediaPlayer.playMedia(MediaPlayer.java:272)
at MsmPlayer.MSMPlayer.playStream(MSMPlayer.java:519)
at MsmPlayer.MSMPlayer.startPlaying(MSMPlayer.java:1950)
at MsmPlayer.MSMPlayer$3.valueChanged(MSMPlayer.java:1102)
at javax.swing.JList.fireSelectionValueChanged(JList.java:1795)
at javax.swing.JList$ListSelectionHandler.valueChanged(JList.java:1809)
at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:167)
at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:147)
at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:194)
at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:388)
at javax.swing.DefaultListSelectionModel.changeSelection(DefaultListSelectionModel.java:398)
at javax.swing.DefaultListSelectionModel.setSelectionInterval(DefaultListSelectionModel.java:442)
at javax.swing.JList.setSelectionInterval(JList.java:2065)
at javax.swing.plaf.basic.BasicListUI$Handler.adjustSelection(BasicListUI.java:2727)
at javax.swing.plaf.basic.BasicListUI$Handler.mousePressed(BasicListUI.java:2683)
at javax.swing.plaf.basic.BasicListUI$MouseInputHandler.mousePressed(BasicListUI.java:1497)
at com.apple.laf.AquaListUI$MouseInputHandler.mousePressed(AquaListUI.java:109)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:263)
at java.awt.Component.processMouseEvent(Component.java:6349)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6117)
at java.awt.Container.processEvent(Container.java:2085)
at java.awt.Component.dispatchEventImpl(Component.java:4714)
at java.awt.Container.dispatchEventImpl(Container.java:2143)
at java.awt.Component.dispatchEvent(Component.java:4544)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4621)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4279)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
at java.awt.Container.dispatchEventImpl(Container.java:2129)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4544)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


Georg

gnosygnu
Blank Cone
Blank Cone
Posts: 45
Joined: 06 Jun 2010 16:06

Re: vlcJ java application under MacOS - Exception

Postby gnosygnu » 15 Feb 2011 00:30

Back in 2010-07, sherington said he didn't have access to a MacOS machine. viewtopic.php?f=32&t=56939&start=140#p257334. I don't think the situation has changed....

If you're feeling adventurous, you can try implementing it yourself. The code for the Windows and Linux implementations of nativeSetVideoSurface are fairly similiar...

Code: Select all

// Windows @Override protected void nativeSetVideoSurface(libvlc_media_player_t mediaPlayerInstance, Canvas videoSurface) { Logger.debug("nativeSetVideoSurface(mediaPlayerInstance={},videoSurface={})", mediaPlayerInstance, videoSurface); // The video surface component must be realised (visible and laid out etc) // at this point long drawable = Native.getComponentID(videoSurface); Logger.debug("drawable={}", drawable); Pointer ptr = Pointer.createConstant(drawable); libvlc.libvlc_media_player_set_hwnd(mediaPlayerInstance, ptr); } // Linux @Override protected void nativeSetVideoSurface(libvlc_media_player_t mediaPlayerInstance, Canvas videoSurface) { Logger.debug("nativeSetVideoSurface(mediaPlayerInstance={},videoSurface={})", mediaPlayerInstance, videoSurface); // The video surface component must be realised (visible and laid out etc) // at this point long drawable = Native.getComponentID(videoSurface); Logger.debug("drawable={}", drawable); libvlc.libvlc_media_player_set_xwindow(mediaPlayerInstance, (int)drawable); } // Mac @Override protected void nativeSetVideoSurface(libvlc_media_player_t mediaPlayerInstance, Canvas videoSurface) { Logger.debug("nativeSetVideoSurface(mediaPlayerInstance={},videoSurface={})", mediaPlayerInstance, videoSurface); // FIXME how? throw new UnsupportedOperationException("Send patches!"); }

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: vlcJ java application under MacOS - Exception

Postby sherington » 15 Feb 2011 09:26

Back in 2010-07, sherington said he didn't have access to a MacOS machine. viewtopic.php?f=32&t=56939&start=140#p257334. I don't think the situation has changed....
That is correct.

A MacOS user tried to help with some code for this a while ago, but he admitted defeat because he couldn't get it working.

geostein8888
Cone that earned his stripes
Cone that earned his stripes
Posts: 142
Joined: 15 Dec 2010 11:32

Re: vlcJ java application under MacOS - Exception

Postby geostein8888 » 15 Feb 2011 09:42

Hello,
is it possible to send me this code so i can try my luck with it

Georg

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: vlcJ java application under MacOS - Exception

Postby sherington » 15 Feb 2011 10:31

Hello,
is it possible to send me this code so i can try my luck with it
Georg
There's not much to go on, but it was posted here: http://code.google.com/p/vlcj/wiki/Usage - look for the post dated 7th December.

Also, in libvlc_media_player.h is the following hint:

Code: Select all

/** * Set the NSView handler where the media player should render its video output. * * Use the vout called "macosx". * * The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding * protocol: * * @begincode * \@protocol VLCOpenGLVideoViewEmbedding <NSObject> * - (void)addVoutSubview:(NSView *)view; * - (void)removeVoutSubview:(NSView *)view; * \@end * @endcode * * Or it can be an NSView object. * * If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then * the following code should work: * @begincode * { * NSView *video = [[NSView alloc] init]; * QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); * libvlc_media_player_set_nsobject(mp, video); * [video release]; * } * @endcode * * You can find a live example in VLCVideoView in VLCKit.framework. * * \param p_mi the Media Player * \param drawable the drawable that is either an NSView or an object following * the VLCOpenGLVideoViewEmbedding protocol. */
I don't know how to do that in Java.

geostein8888
Cone that earned his stripes
Cone that earned his stripes
Posts: 142
Joined: 15 Dec 2010 11:32

Re: vlcJ java application under MacOS - Exception

Postby geostein8888 » 16 Feb 2011 17:06

Hello,
i'm gat now the thing to show me a Videoscreen who is not connected to the Frame, and the sound also plays, i think this is the same situation i saw somewhere for the Linux version of the canvas, is there already a fix for the linux version i can learn from?

Georg

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: vlcJ java application under MacOS - Exception

Postby sherington » 16 Feb 2011 18:01

There was no fix for the Linux implementation, it has always worked correctly on Linux.

geostein8888
Cone that earned his stripes
Cone that earned his stripes
Posts: 142
Joined: 15 Dec 2010 11:32

Re: vlcJ java application under MacOS - Exception

Postby geostein8888 » 20 Feb 2011 08:13

Hello,
finally i organized now a mac mini to work on this. I have still the problem that the audio is playing but the video does not appear.

the problem seems to be the pointer to the video surface:

protected void nativeSetVideoSurface(libvlc_media_player_t mediaPlayerInstance, Canvas videoSurface) {

try {
Logger.debug("nativeSetVideoSurface(mediaPlayerInstance={},videoSurface={})", mediaPlayerInstance, videoSurface);
Pointer ptr = Pointer.createConstant(drawable);

libvlc.libvlc_media_player_set_nsobject(mediaPlayerInstance, ptr);
} catch (Exception ex) {
System.out.println("----- Exception nativeSetVideoSurface: " + ex.getStackTrace());
}
}

with this code i don't get a exception but no video. when i give a wong pointer to the nsobject, i get an exception but a video apperas in the middle of the screen who is not connected to the application frame.

nomally i thought when i have a application (JFrame -> mainframe) with a Canvas(Videosurface) added to the frame and this surface defined as videosurface for the mediaplayer it should work, when i give the componentID of this videosurface as a pointer to the native library. Why does the videosurface dissapear when i give his adress to the native library?

Georg

Meckie
New Cone
New Cone
Posts: 2
Joined: 03 Mar 2011 14:39

Re: vlcJ java application under MacOS - Exception

Postby Meckie » 03 Mar 2011 14:46

I found this http://developer.apple.com/library/mac/ ... SView.html. I am not so familiar with objective c. Is it possible to load this with java and add a new coercion that converts a generated "MacCanvas", that implements the VLCOpenGLVideoViewEmbedding protocol, to NSView?

Or something like this?
http://developer.apple.com/library/mac/ ... lementID_3

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: vlcJ java application under MacOS - Exception

Postby sherington » 14 Mar 2011 20:49

Code: Select all

Pointer ptr = Pointer.createConstant(drawable); libvlc.libvlc_media_player_set_nsobject(mediaPlayerInstance, ptr);
What happens if instead of Pointer.createConstant(drawable), you do this:

Code: Select all

Pointer ptr = Native.getComponentPointer(drawable); libvlc.libvlc_media_player_set_nsobject(mediaPlayerInstance, ptr);

geostein8888
Cone that earned his stripes
Cone that earned his stripes
Posts: 142
Joined: 15 Dec 2010 11:32

Re: vlcJ java application under MacOS - Exception

Postby geostein8888 » 15 Mar 2011 05:20

Hello,
when i change this, i get the same result, the audio plays but no videoscreen.

Georg

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: vlcJ java application under MacOS - Exception

Postby sherington » 15 Mar 2011 08:54

Hello,
when i change this, i get the same result, the audio plays but no videoscreen.

Georg
I do not know if this is a correct statement or not, as I do not have a Mac so I can't test it, but it looks like Java on MacOS may be using 64 bit window handles, whereas the libvlc API expects 32-bit window handles.

If you do this...

Code: Select all

long drawable = Native.getComponentID(canvas); System.out.println("bad value: " + (drawable < Integer.MIN_VALUE || drawable > Integer.MAX_VALUE));
Maybe that's the problem, I don't know.

Rémi Denis-Courmont
Developer
Developer
Posts: 15184
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: vlcJ java application under MacOS - Exception

Postby Rémi Denis-Courmont » 15 Mar 2011 17:37

That's not true. LibVLC expects NSObjects pointers.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: vlcJ java application under MacOS - Exception

Postby sherington » 15 Mar 2011 18:01

That's not true. LibVLC expects NSObjects pointers.
So we can't use this?

src/control/media_player.c

Code: Select all

void libvlc_media_player_set_agl( libvlc_media_player_t *p_mi, uint32_t drawable ) { #ifdef __APPLE__ var_SetInteger (p_mi, "drawable-agl", drawable); #else (void) p_mi; (void)drawable; #endif }
So if instead we are supposed to use libvlc_media_player_set_nsobject() it would be great if any Java Mac developer out there could let me know how to get an NSObject pointer for a Canvas so I can support Mac in the Java bindings.

Rémi Denis-Courmont
Developer
Developer
Posts: 15184
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: vlcJ java application under MacOS - Exception

Postby Rémi Denis-Courmont » 15 Mar 2011 22:33

Oh, if you want to use AGL, then it's a 32-bits handle. But insofar as it is a handle (not a pointer), I don't see how 32-bits would be a problem.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: vlcJ java application under MacOS - Exception

Postby sherington » 16 Mar 2011 08:56

Oh, if you want to use AGL, then it's a 32-bits handle. But insofar as it is a handle (not a pointer), I don't see how 32-bits would be a problem.
Hi, one problem is that the handle does indeed seem to contain a 64-bit value on MacOS. According to the documentation of the toolkit I'm using, there is no reason why the native window handle can't be 64-bit.

However, this 32-bit vs 64-bit discussion may be a red herring because with a confirmed 32-bit window handle on 32-bit MacOS, media_player_set_agl() still doesn't set the drawable properly, so presumably the handle is wrong in some other way.

I'm totally hamstrung at the moment and I am relying on third party assistance and reports since I have no Mac platform myself.

Right now I'm looking at how to get an NSView pointer in Java to try media_player_set_nsobject() but it's not clear at all what needs to be done. This was so simple on Linux and Windows!

Meckie
New Cone
New Cone
Posts: 2
Joined: 03 Mar 2011 14:39

Re: vlcJ java application under MacOS - Exception

Postby Meckie » 17 Mar 2011 16:36

I have a Question.
When I start a file without this line.

Code: Select all

libvlc.libvlc_media_player_set_nsobject(mediaPlayer.mediaPlayerInstance(), Native.getComponentPointer(osxCanvas));
I get a new Window where everything is fine.
But all Methods

Code: Select all

libvlc.libvlc_media_player_get_nsobject(...) , libvlc.libvlc_media_player_get_agl(...), ....
They all return null. But there is a window. Why couldn't i get the Pointer of this object?

I try this because i found a Class which makes a CocoaComponent from the NSView pointer. I am not sure if this works. i am just trying everthing...

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: vlcJ java application under MacOS - Exception

Postby sherington » 18 Mar 2011 09:20

This is my current understanding of why it's not (yet) working on Mac from Java. Caveat: I am not a Mac developer.

The libvlc_media_player.h header file for libvlc_media_player_set_nsobject() is quite clear on this:

Code: Select all

* The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding * protocol: * * @begincode * \@protocol VLCOpenGLVideoViewEmbedding <NSObject> * - (void)addVoutSubview:(NSView *)view; * - (void)removeVoutSubview:(NSView *)view; * \@end * @endcode * * Or it can be an NSView object. * * If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then * the following code should work: * @begincode * { * NSView *video = [[NSView alloc] init]; * QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); * libvlc_media_player_set_nsobject(mp, video); * [video release]; * } * @endcode * * You can find a live example in VLCVideoView in VLCKit.framework.
If you use a regular java.awt.Canvas in your Java application, you use JNA's Native.componentID(canvas) or Native.getComponentPointer(canvas) method to give you a window handle for the Canvas peer NSView object. In principle, you pass this window handle to libvlc_media_player_set_nsobject().

The problem is that since this is an ordinary java.awt.Canvas, it of course knows absolutely nothing about vlc, so the following condition can not be satisfied:

Code: Select all

* The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding * protocol:
In fact, if you pass an ordinary java.awt.Canvas handle to libvlc_media_player_set_nsobject you get the following error message in the log:

Code: Select all

java[3411:80f] *** -[NSViewAWT addVoutSubview:]: unrecognized selector sent to instance 0x1b491f80
This error means that the "addVoutSubview" method does not exist on the NSViewAWT object instance - which is to be expected since as previously stated a regular java.awt.Canvas knows nothing about vlc.

So how to get this working on Mac?

1. Instead of embedding a regular java.awt.Canvas, your Mac Java application must embed a native view component that "follow[s] the VLCOpenGLVideoViewEmbedding protocol".
2. Change the Java bindings to get the component ID/pointer of this native view component (rather than a java.awt.Canvas).

For #1, the libvlc_media_player.h header file refers to an example in the vlc source code "/projects/macosx/framework/Sources/VLCVideoView.m". This could be one part of the solution. The other part of the solution is to get an instance of that view object embedded inside your Java application. Presumably MacOS provides some native tricks/hacks/bridges to enable this to happen.

For #2, this should be quite simple once someone tells me how #1 is solved.

So the impact on the end-user Mac Java applications is quite large, and the impact on the Java bindings is quite small.

Hopefully this information is correct, and that it can prompt an experienced Mac Java developer to share a solution.

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: vlcJ java application under MacOS - Exception

Postby sherington » 19 Mar 2011 08:33

Some additional research on this topic and a suggestion for how to proceed has been posted on the vlcj google group here:
https://groups.google.com/d/msg/vlcj/wP ... d_7eS4QVgJ

Hopefully it can help someone.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 6 guests