Page 1 of 1

Using libVLC on Mac OS X + Qt5

Posted: 13 May 2016 11:57
by lanamelach
I've been developing a cross-platform app which can be run on windows and mac. It is based on Qt 5.6 and libVLC v2.2.3. On Windows it works fine, but on Mac it doesn't display video, though the sound from the movie can be heard. I believe the issue is related to this function:

Code: Select all

libvlc_media_player_set_nsobject(vlcPlayer, (void*)videoWidget->winId()); // videoWidget is QFrame *
It seems winId() works very different in Qt4 and Qt5, therefore the code, which worked fine in Qt4, ceased to work in Qt5. I read about QMacCocoaViewContainer. Probably in Qt5 it must be used instead of a simple QWidget or QFrame, but I still haven't managed to make it work as QMacCocoaViewContainer crashes when setting a cocoa view instance:

Code: Select all

QMacCocoaViewContainer container(0); // Many Cocoa objects create temporary autorelease objects, // so create a pool to catch them. NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // Create the NSView, set it on the QCocoaViewContainer. NSView *view = [[NSView alloc] init]; container.setCocoaView(view); // here it crashes saying EXC_BAD_ACCESS // Release our reference, since our super class takes ownership and we // don't need it anymore. [view release]; // Clean up our pool as we no longer need it. [pool release]; container.show(); .... libvlc_media_player_set_nsobject(vlcPlayer, (void*)container->cocoaView());
Does anyone know how to fix this?

Re: Using libVLC on Mac OS X + Qt5

Posted: 28 Jun 2016 10:12
by Jean-Baptiste Kempf
Qt5 changes the handling of Windows. You need to use the extra part of Qt5 for that.