Code: Select all
- | QFrame *_videoWidget;
+ | QMacCocoaViewContainer *_videoWidget;
Code: Select all
+ | #undef slots
+ | // yes, otherwise there's a confilct in some framework's header file
+ | // please, suggest a cleaner way to do that.
+ | #import <VLCKit/VLCKit.h>
___________________________________________________________________________
- | 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);
Well, I'd like too, BUTCan add that to the wiki ? (or ifdef it?)
Code: Select all
VLCPlayer::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: Select all
VLCPlayer::~VLCPlayer()
{
_poller->stop();
Stop();
libvlc_media_player_release (_media_player);
libvlc_release (_vlcinstance);
}
Code: Select all
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();
}
Code: Select all
// 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<unsigned int>(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
}
Code: Select all
void VLCPlayer::Play()
{
libvlc_media_player_play( _media_player, &VLCException(this) );
#ifdef Q_WS_MAC
if (_videoWidget) _videoWidget->show();
#endif
_poller->start();
}
Code: Select all
#ifdef Q_WS_MAC && VLC_VERSION_1_0
if (_videoWidget) {
delete _videoWidget;
_videoWidget = NULL;
}
#endif
if (libvlc_media_player_get_media (_media_player, &VLCException(this) ) != NULL && _media_descr != NULL)
{
libvlc_media_player_stop( _media_player, &VLCException(this) );
}
Return to “Development around libVLC”
Users browsing this forum: No registered users and 23 guests