Unable to embed VLC in Qt-Widget MacOS

>> Thursday 28 June 2012

Unable to embed VLC in Qt-Widget MacOS
I am currently looking to integrate VLC into the custom application which should be portable between Mac and Windows. I have used the Alexander Maringer in the Wiki and I have successfully embedded VLC through Qt-application on the Windows. However I have tried to do the same with the Mac but it did not working. The App is seems to crash every time when I am trying the same. Let me know if you are having any suggestion to meet the requirement of mine. Thanks a lot in advance.
Reply With Quote
#2
Old 17-04-2011
void void is offline
Member

Join Date: Nov 2008
Posts: 1,193
Re: Unable to embed VLC in Qt-Widget MacOS
Well according to me one should remove the macosx-plugin from the computer and one should try with the 1.0.0 release candidate. QuickTime 4.5 is now having QMacCocoaViewContainer which is wrapping Cocoa NSView into the QWidget. Another one thing you can try libvlc_media_player_set_nsobject apart from the pointer not just to the NSView to render and not the instance of the VLCOpenGLVoutView which is located at the /modules/minimal_macosx/VLCOpenGLVoutView.h location.
Reply With Quote
#3
Old 17-04-2011
Badrunath Badrunath is offline
Member

Join Date: Jun 2009
Posts: 1,519
Re: Unable to embed VLC in Qt-Widget MacOS
I am suggesting the following thing which you can use to fix the problem of yours. You need to put libvlc headers and Qt headers in to folder and run the same.
Code:

qmake -project

Now you should edit the .pro file and add the following things.
Code:

LIBS += -L*path to vlc lib* #if you are at windows os
LIBS += -lvlc

Now run the File.
Code:

Qmake

Finally use the following thing on the terminal.
Code:

make or mingw32-make under a Windows OS

Reply With Quote
#4
Old 17-04-2011
MahaGuru's Avatar
MahaGuru MahaGuru is offline
Member

Join Date: Nov 2008
Posts: 1,526
Re: Unable to embed VLC in Qt-Widget MacOS
I am having particular solution which you can use to fix the problem of yours.
You should do the following changes into main.cpp
Code:

- | QFrame *_videoWidget;

+ | QMacCocoaViewContainer *_videoWidget;

Now do the following changes into vlc_on_qt.mm.
Code:

+ | #undef slots
+ | // yes, otherwise there's a confilct in some framework's header file
+ | // please, suggest a cleaner way to do that.

+ | #import
___________________________________________________________________________
- | libvlc_media_player_set_agl (_mp, _videoWidget->winId(), &_vlcexcep); // for vlc 1.0

+ | VLCVideoView *videoView = [[VLCVideoView alloc] init];
+ | _videoWidget->setCocoaView(videoView);
+ | [videoView setAutoresizingMask: NSViewHeightSizable|NSViewWidthSizable];
+ | libvlc_media_player_set_nsobject(_mp, videoView, &_vlcexcep);

I am hoping that it will help you out to solve the problem of yours.
Reply With Quote
#5
Old 17-04-2011
GeforceUser GeforceUser is offline
Member

Join Date: Mar 2009
Posts: 1,364
Re: Unable to embed VLC in Qt-Widget MacOS
Well after using the above mentioned solution you will see that the VLC would be hanging. You can solve the matter by simply creating the symbolic link between lib and modules to the respective directories into the /Contents/Frameworks/Versions/Current/. Rather than duplicating libraries of the bundle. I am hoping that the solution which would be helpful to solve the problem of yours.
Reply With Quote
#6
Old 20-04-2011
Bull50's Avatar
Bull50 Bull50 is offline
Member

Join Date: Nov 2008
Posts: 1,262
Re: Unable to embed VLC in Qt-Widget MacOS
I am providing some code of the libvlc wrapper over here which would be helpful to you.
Code:

Constructor
LCPlayer::VLCPlayer()
: QWidget()
{
const char * const vlc_args[] = {
"-I", "dummy" // Don't use any interface
,"--ignore-config" // Don't use VLC's config
,"--verbose=-1"
,"--quiet"
#ifdef Q_WS_MAC
, "--vout=minimal_macosx"
, "--opengl-provider=minimal_macosx"
#endif
};


int argc = sizeof(vlc_args) / sizeof(vlc_args[0]);

_vlcinstance = libvlc_new( argc, vlc_args, &VLCException(this) );
_media_player = libvlc_media_player_new( _vlcinstance, &VLCException(this) );
_media_descr = NULL;

#ifdef Q_WS_MAC && VLC_VERSION_1_0
_videoWidget = NULL;
_wrapperLayout = new QVBoxLayout;
_wrapperLayout->setContentsMargins(0,0,0,0);
setLayout(_wrapperLayout);
#endif

// Create a timer to poll player state. That way it works. Using vlc's event manager caused some problems with threads.

// That's it. Window will be attached once we actually start playing.
}

Code:

Destructor
VLCPlayer::~VLCPlayer()
{
_poller->stop();
Stop();
libvlc_media_player_release (_media_player);
libvlc_release (_vlcinstance);
}

Load
Code:

void VLCPlayer::Load( IN QString & url)
{
Stop();

if (_media_descr) libvlc_media_release( _media_descr );
_media_descr = libvlc_media_new (_vlcinstance, url.toAscii(), &VLCException(this) );

// Creating parameter string 'options'

libvlc_media_add_option ( _media_descr, options, &VLCException(this) );
libvlc_media_player_set_media ( _media_player, _media_descr, &VLCException(this) );

attachPlayerToWnd();
}

attachPlayerToWnd()
Code:

// Tell LibVLC to render video into our widget
void VLCPlayer::attachPlayerToWnd()
{
#if defined(Q_WS_WIN)
#if defined( VLC_VERSION_0_9 )
libvlc_media_player_set_drawable(_media_player, reinterpret_cast(winId()), &VLCException(this) );
#elif defined ( VLC_VERSION 1_0 )
libvlc_media_player_set_hwnd(_media_player, winId(), &VLCException(this) );
#endif
#elif defined(Q_WS_MAC)
#if defined( VLC_VERSION_0_9 )
libvlc_media_player_set_drawable(_media_player, winId(), &VLCException(this) );
#elif defined( VLC_VERSION_1_0 )

_videoWidget = new QMacCocoaViewContainer(0);
_wrapperLayout->addWidget(_videoWidget);

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

VLCVideoView *videoView = [[VLCVideoView alloc] init];
_videoWidget->setCocoaView(videoView);

libvlc_media_player_set_nsobject(_media_player, videoView, &VLCException(this) );
[videoView release];

[pool release];

//@
_videoWidget->hide();
#endif
#elif defined( Q_WS_X11 )
#if defined( VLC_VERSION_0_9 )
libvlc_media_player_set_drawable(_media_player, winId(), &VLCException(this) );
#elif defined( VLC_VERSION_1_0 )
libvlc_media_player_set_xwindow(_media_player, winId(), &VLCException(this) );
#endif
#endif
}

Finally code for the Play and stop options of the VLC.
void VLCPlayer::Play()
{
libvlc_media_player_play( _media_player, &VLCException(this) );

0 comments:

Post a Comment

Read - Share - Comment

About This Blog

Share and Save

About Author