// Initialization bool MediaPlayer::initialize( const std::string &url ) { LDEBUG( "vlc", "Initialize: url=%s", url.c_str() ); // Create media from url libvlc_media_t *m=libvlc_media_new_path( instance(), url.c_str() ); if (!m) { LERROR( "vlc", "Cannot initialize new media from url: url=%s", url.c_str() ); return false; } // Add common parameters libvlc_media_add_option( m, "verbose=1000" ); libvlc_media_add_option( m, "no-osd" ); libvlc_media_add_option( m, "ffmpeg-hw" ); // Create a media player playing environement _mp = libvlc_media_player_new_from_media(m); if (!_mp) { libvlc_media_release (m); LERROR( "vlc", "Cannot create media player from url: url=%s", url.c_str() ); return false; } // No need to keep the media now libvlc_media_release (m); { // Set WindowID VideoDescription desc; if (getVideoDescription( desc )) { #ifndef _WIN32 libvlc_media_player_set_xwindow( _mp, desc.winID ); #else libvlc_media_player_set_hwnd( _mp, desc ); #endif } } { // Attach to stop asyn events libvlc_event_manager_t *mgr=libvlc_media_player_event_manager( _mp ); libvlc_event_attach( mgr, libvlc_MediaPlayerEndReached, vlcCallback, this ); } return true; }
void Mwindow::openFile() { /* The basic file-select box */ QString fileOpen = QFileDialog::getOpenFileName(this, tr("Load a file"), "~"); /* Stop if something is playing */ if (vlcPlayer && libvlc_media_player_is_playing(vlcPlayer)) stop(); /* Create a new Media */ libvlc_media_t *vlcMedia = libvlc_media_new_path(vlcInstance, qtu(fileOpen)); if (!vlcMedia) return; /* Create a new libvlc player */ vlcPlayer = libvlc_media_player_new_from_media (vlcMedia); /* Release the media */ libvlc_media_release(vlcMedia); /* Integrate the video in the interface */ #if defined(Q_OS_MAC) libvlc_media_player_set_nsobject(vlcPlayer, (void *)videoWidget->winId()); #elif defined(Q_OS_UNIX) libvlc_media_player_set_xwindow(vlcPlayer, videoWidget->winId()); #elif defined(Q_OS_WIN) libvlc_media_player_set_hwnd(vlcPlayer, videoWidget->winId()); #endif /* And start playback */ libvlc_media_player_play (vlcPlayer); /* Update playback button */ playBut->setText("Pause"); }
void Player::playFile(QString ofile) { /*the file has to be in one of the following formats /perhaps a little bit outdated) [file://]filename Plain media file http://ip:port/file HTTP URL ftp://ip:port/file FTP URL mms://ip:port/file MMS URL screen:// Screen capture [dvd://][device][@raw_device] DVD device [vcd://][device] VCD device [cdda://][device] Audio CD device udp:[[<source address>]@[<bind address>][:<bind port>]] */ /*Prevent path problems*/ QString file = ofile.replace('/','\\'); /* Create a new LibVLC media descriptor */ media = libvlc_media_new_path(vlcInstance, file.toLatin1()); libvlc_media_player_set_media (mediaPlayer, media); libvlc_media_player_set_xwindow (mediaPlayer, reinterpret_cast<unsigned int>(videoWidget->winId())); /* Play */ libvlc_media_player_play (mediaPlayer); isPlaying=true; }
void MainWindow::initVLC() { #ifdef __WXGTK__ libvlc_media_player_set_xwindow(media_player, GET_XID(this->player_widget)); #else libvlc_media_player_set_hwnd(media_player, this->player_widget->GetHandle()); #endif }
void VLCMainwindow::openFile() { /* Just the basic file-select box */ QString fileOpen = QFileDialog::getOpenFileName(this,tr("Load a file"), "~"); fileOpen.replace("/", "\\"); /* Stop if something is playing */ if( vlcPlayer && libvlc_media_player_is_playing(vlcPlayer) ) stop(); /* New Media */ libvlc_media_t *vlcMedia = libvlc_media_new_path(vlcObject,qtu(fileOpen)); if( !vlcMedia ) return; vlcPlayer = libvlc_media_player_new_from_media (vlcMedia); libvlc_media_release(vlcMedia); /* Integrate the video in the interface */ #if defined(Q_OS_MAC) libvlc_media_player_set_nsobject(vlcPlayer, videoWidget->winId()); #elif defined(Q_OS_UNIX) libvlc_media_player_set_xwindow(vlcPlayer, videoWidget->winId()); #elif defined(Q_OS_WIN) libvlc_media_player_set_hwnd(vlcPlayer, videoWidget->winId()); #endif //int windid = videoWidget->winId(); //libvlc_media_player_set_xwindow (vlcPlayer, windid ); /* And play */ libvlc_media_player_play (vlcPlayer); //Set vars and text correctly playBut->setText("Pause"); }
void VlcMediaPlayer::play() { if (!_vlcMediaPlayer) return; if (_videoWidget) { _currentWId = _videoWidget->request(); } else { _currentWId = 0; } /* Get our media instance to use our window */ if (_currentWId) { #if defined(Q_OS_WIN32) libvlc_media_player_set_hwnd(_vlcMediaPlayer, _currentWId); #elif defined(Q_OS_MAC) libvlc_media_player_set_nsobject(_vlcMediaPlayer, (void *)_currentWId); #elif defined(Q_OS_UNIX) libvlc_media_player_set_xwindow(_vlcMediaPlayer, _currentWId); #endif } libvlc_media_player_play(_vlcMediaPlayer); VlcError::errmsg(); }
void Player::playFile(QString file) { //the file has to be in one of the following formats /perhaps a little bit outdated) /* [file://]filename Plain media file http://ip:port/file HTTP URL ftp://ip:port/file FTP URL mms://ip:port/file MMS URL screen:// Screen capture [dvd://][device][@raw_device] DVD device [vcd://][device] VCD device [cdda://][device] Audio CD device udp:[[<source address>]@[<bind address>][:<bind port>]] */ /* Create a new LibVLC media descriptor */ _m = libvlc_media_new_path(_vlcinstance, file.toAscii()); //_m = libvlc_media_new (_vlcinstance, file.toAscii(), &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. libvlc_media_player_set_media (_mp, _m); //libvlc_media_player_set_media (_mp, _m, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. // /!\ Please note /!\ // // passing the widget to the lib shows vlc at which position it should show up // vlc automatically resizes the video to the given size of the widget // and it even resizes it, if the size changes at the playing /* Get our media instance to use our window */ #if defined(Q_OS_WIN) libvlc_media_player_set_drawable(_mp, reinterpret_cast<unsigned int>(_videoWidget->winId())); //libvlc_media_player_set_drawable(_mp, reinterpret_cast<unsigned int>(_videoWidget->winId()), &_vlcexcep ); // [20101215 JG] Used for versions prior to VLC 1.2.0. //libvlc_media_player_set_hwnd(_mp, _videoWidget->winId(), &_vlcexcep ); // for vlc 1.0 #elif defined(Q_OS_MAC) libvlc_media_player_set_drawable(_mp, _videoWidget->winId()); //libvlc_media_player_set_drawable(_mp, _videoWidget->winId(), &_vlcexcep ); // [20101215 JG] Used for versions prior to VLC 1.2.0. //libvlc_media_player_set_agl (_mp, _videoWidget->winId(), &_vlcexcep); // for vlc 1.0 #else //Linux //[20101201 Ondrej Spilka] obsolete call on libVLC >=1.1.5 //libvlc_media_player_set_drawable(_mp, _videoWidget->winId(), &_vlcexcep ); //libvlc_media_player_set_xwindow(_mp, _videoWidget->winId(), &_vlcexcep ); // for vlc 1.0 /* again note X11 handle on Linux is needed winID() returns X11 handle when QX11EmbedContainer us used */ int windid = _videoWidget->winId(); libvlc_media_player_set_xwindow (_mp, windid ); #endif //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. /* Play */ libvlc_media_player_play (_mp); //libvlc_media_player_play (_mp, &_vlcexcep ); // [20101215 JG] Used for versions prior to VLC 1.2.0. //raise(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. _isPlaying=true; }
bool VlcMediaWidget::init() { const char *arguments[] = { "--no-video-title-show" }; vlcInstance = libvlc_new(sizeof(arguments) / sizeof(arguments[0]), arguments); if (vlcInstance == NULL) { Log("VlcMediaWidget::init: cannot create vlc instance") << QLatin1String(libvlc_errmsg()); return false; } vlcMediaPlayer = libvlc_media_player_new(vlcInstance); if (vlcMediaPlayer == NULL) { Log("VlcMediaWidget::init: cannot create vlc media player") << QLatin1String(libvlc_errmsg()); return false; } libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(vlcMediaPlayer); libvlc_event_e eventTypes[] = { libvlc_MediaPlayerEncounteredError, libvlc_MediaPlayerEndReached, libvlc_MediaPlayerLengthChanged, libvlc_MediaPlayerSeekableChanged, libvlc_MediaPlayerStopped, libvlc_MediaPlayerTimeChanged }; for (uint i = 0; i < (sizeof(eventTypes) / sizeof(eventTypes[0])); ++i) { if (libvlc_event_attach(eventManager, eventTypes[i], vlcEventHandler, this) != 0) { Log("VlcMediaWidget::init: cannot attach event handler") << eventTypes[i]; return false; } } libvlc_media_player_set_xwindow(vlcMediaPlayer, quint32(winId())); setAttribute(Qt::WA_NativeWindow); setAttribute(Qt::WA_PaintOnScreen); return true; }
static void widget_on_realize(GtkWidget *widget, gpointer user_data) { GtkVlcPlayer *player = GTK_VLC_PLAYER(user_data); GdkWindow *window = gtk_widget_get_window(widget); libvlc_media_player_set_xwindow(player->priv->media_player, GDK_WINDOW_XID(window)); }
void LiveWidget::setupRenderTarget(bool windowMode) { #if defined(Q_OS_WIN) libvlc_media_player_set_hwnd(this->vlcMediaPlayer, (windowMode == true) ? this->liveDialog->getRenderTarget()->winId() : this->labelLive->winId()); #elif defined(Q_OS_MAC) libvlc_media_player_set_nsobject(this->vlcMediaPlayer, (windowMode == true) ? (void*)this->liveDialog->getRenderTarget()->winId() : (void*)this->labelLive->winId()); #elif defined(Q_OS_LINUX) libvlc_media_player_set_xwindow(this->vlcMediaPlayer, (windowMode == true) ? this->liveDialog->getRenderTarget()->winId() : this->labelLive->winId()); #endif }
void VLCVideoWidgetDelegator::attachVLCRenderContext( QWidget * parent){ if( m_player != Nullptr && m_widgetInstance == Nullptr ){ m_widgetInstance = new QWidget( parent ); #if defined(Q_OS_MAC) libvlc_media_player_set_nsobject(m_player, m_widgetInstance->winId()); #elif defined(Q_OS_UNIX) libvlc_media_player_set_xwindow(m_player, m_widgetInstance->winId()); #elif defined(Q_OS_WIN) libvlc_media_player_set_hwnd(m_player, m_widgetInstance->winId()); #endif } }
int mediacontrol_set_visual( mediacontrol_Instance *self, WINDOWHANDLE visual_id, mediacontrol_Exception *exception ) { mediacontrol_exception_init( exception ); #ifdef WIN32 libvlc_media_player_set_hwnd( self->p_media_player, visual_id ); #else libvlc_media_player_set_xwindow( self->p_media_player, visual_id ); #endif return true; }
void VLCWrapper::setWindow (WId winId) { libvlc_media_player_t *m = Player_.get (); int time = libvlc_media_player_get_time (m); libvlc_media_player_stop (m); #ifdef Q_OS_WIN32 libvlc_media_player_set_hwnd (m, winId); #endif #ifdef Q_WS_X11 libvlc_media_player_set_xwindow (m, winId); #endif libvlc_media_player_play (m); libvlc_media_player_set_time (m, time); }
/***************************************************************************** * VlcPlugin playlist replacement methods *****************************************************************************/ void VlcPlugin::set_player_window( libvlc_exception_t *ex ) { #ifdef XP_UNIX libvlc_media_player_set_xwindow(libvlc_media_player, (libvlc_drawable_t)getVideoWindow(), ex); #endif #ifdef XP_MACOSX // XXX FIXME insert appropriate call here #endif #ifdef XP_WIN libvlc_media_player_set_hwnd(libvlc_media_player, getWindow().window, ex); #endif }
void VlcMediaPlayer::setVideoWidgetId(const WId &id) { _widgetId = id; /* Get our media instance to use our window */ if (_vlcMediaPlayer) { #if defined(Q_WS_WIN) libvlc_media_player_set_hwnd(_vlcMediaPlayer, _widgetId); #elif defined(Q_WS_MAC) libvlc_media_player_set_nsobject(_vlcMediaPlayer, (void *)_widgetId); #else // Q_WS_X11 libvlc_media_player_set_xwindow(_vlcMediaPlayer, _widgetId); #endif // Q_WS_* VlcError::errmsg(); } }
void PlayerEngine_vlc::set_winID(gulong player_window_id) { libvlc_media_player_set_xwindow(vlcPlayer,player_window_id); }
VideoWindow::VideoWindow(Context *context, const QDir &home) : GcWindow(context), home(home), context(context), m_MediaChanged(false) { setControls(NULL); setProperty("color", QColor(Qt::black)); QHBoxLayout *layout = new QHBoxLayout(); setLayout(layout); init = true; // assume initialisation was ok ... #ifdef GC_VIDEO_VLC // // USE VLC VIDEOPLAYER // #if QT_VERSION >= 0x050000 #warning "WARNING: Please ensure the VLC QT4 plugin (gui/libqt4_plugin) is NOT available as it will cause GC to crash." #endif // config paramaters to libvlc const char * const vlc_args[] = { "-I", "dummy", /* Don't use any interface */ "--ignore-config", /* Don't use VLC's config */ "--disable-screensaver", /* disable screensaver during playback */ #ifdef Q_OS_LINUX "--no-xlib", // avoid xlib thread error messages #endif //"--verbose=-1", // -1 = no output at all //"--quiet" }; /* create an exception handler */ //libvlc_exception_init(&exceptions); //vlc_exceptions(&exceptions); /* Load the VLC engine */ inst = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args); //vlc_exceptions(&exceptions); /* Create a new item */ if (inst) { // if vlc doesn't initialise don't even try! m = NULL; //vlc_exceptions(&exceptions); /* Create a media player playing environement */ mp = libvlc_media_player_new (inst); //vlc_exceptions(&exceptions); //vlc_exceptions(&exceptions); /* This is a non working code that show how to hooks into a window, * if we have a window around */ #ifdef Q_OS_LINUX #if QT_VERSION > 0x50000 x11Container = new QWidget(this); //XXX PORT TO 5.1 BROKEN CODE XXX #else x11Container = new QX11EmbedContainer(this); #endif layout->addWidget(x11Container); libvlc_media_player_set_xwindow (mp, x11Container->winId()); #endif #ifdef WIN32 container = new QWidget(this); layout->addWidget(container); libvlc_media_player_set_hwnd (mp, (HWND)(container->winId())); #endif } else { // something went wrong ! init = false; } #endif #ifdef GC_VIDEO_QT5 // USE QT VIDEO PLAYER wd = new QVideoWidget(this); wd->show(); mp = new QMediaPlayer(this); mp->setVideoOutput(wd); layout->addWidget(wd); #endif if (init) { connect(context, SIGNAL(stop()), this, SLOT(stopPlayback())); connect(context, SIGNAL(start()), this, SLOT(startPlayback())); connect(context, SIGNAL(pause()), this, SLOT(pausePlayback())); connect(context, SIGNAL(seek(long)), this, SLOT(seekPlayback(long))); connect(context, SIGNAL(unpause()), this, SLOT(resumePlayback())); connect(context, SIGNAL(mediaSelected(QString)), this, SLOT(mediaSelected(QString))); } }
bool VLCVideoWrapper::open(const std::string& ThePath, Window* const TheWindow) { bool errorOpening(false); //BoostPath PluginsDirPath("/Applications/VLC.app/Contents/MacOS/modules"); BoostPath PluginsDirPath("/Applications/VLC-1.1.7.app/Contents/MacOS/modules"); std::vector<std::string> VLCArguments; VLCArguments.push_back("-I"); VLCArguments.push_back("dummy"); /* no interface */ VLCArguments.push_back(std::string("--plugin-path=") + PluginsDirPath.string()); //VLCArguments.push_back("--no-audio"); [> we don't want audio <] VLCArguments.push_back("--verbose=0"); /* show only errors */ VLCArguments.push_back("--no-media-library");/* don't want that */ VLCArguments.push_back("--services-discovery=");/* don't want that */ VLCArguments.push_back("--no-video-title-show");/* don't want that */ VLCArguments.push_back("--no-stats");/* don't want that */ VLCArguments.push_back("--ignore-config"); /* don't use/overwrite the config */ VLCArguments.push_back("--no-sub-autodetect");/* don't want subtitles */ VLCArguments.push_back("--control=");/* don't want interface (again) */ VLCArguments.push_back("--no-disable-screensaver");/* don't want that */ // libvlc settings const char** args = new const char*[VLCArguments.size()]; for(UInt32 i(0) ; i<VLCArguments.size() ; ++i) { args[i] = VLCArguments[i].c_str(); } /* * Initialise libVLC */ UInt32 nargs = VLCArguments.size(); _VLCInstance = libvlc_new( nargs, args ); if(_VLCInstance == NULL) { checkVLCError("creating new vlc instance"); return false; } delete [] args; // creates vlc struct holding data to the video file libvlc_media_t *TheMedia = libvlc_media_new_path( _VLCInstance, ThePath.c_str() ); checkVLCError("initializing media file"); // initialize a temporary media player so we can get height and width before // adding the vmem options to TheMedia libvlc_media_player_t * tempMediaPlayer = libvlc_media_player_new_from_media( TheMedia ); unsigned Width(200), Height(200); libvlc_video_set_callbacks(tempMediaPlayer, lock, unlock, display, &_VideoMemContext); _VideoMemContext._pixels = ( UInt8* )malloc( ( sizeof( *( _VideoMemContext._pixels ) ) * Width * Height ) * 4 ); libvlc_video_set_format(tempMediaPlayer, "RV24", Width, Height, Width * 3); //Release the media file libvlc_media_release( TheMedia ); libvlc_media_player_play( tempMediaPlayer ); checkVLCError("playing the media"); libvlc_state_t currentState; do { currentState = libvlc_media_player_get_state(tempMediaPlayer); checkVLCError("getting state"); } while(currentState != libvlc_Playing); int VLCResult; do { VLCResult = libvlc_video_get_size(tempMediaPlayer, 0, &Width, &Height); } while(VLCResult != 0); checkVLCError("getting size"); libvlc_media_player_stop( tempMediaPlayer ); libvlc_media_player_release(tempMediaPlayer);// releases media currently in use //Now that we have the size initialize the media again TheMedia = libvlc_media_new_path( _VLCInstance, ThePath.c_str() ); checkVLCError("initializing media file"); // initialize the media player _MediaPlayer = libvlc_media_player_new_from_media( TheMedia ); checkVLCError("initializing media player"); //Release the media file libvlc_media_release( TheMedia ); #ifdef __APPLE__ //set agl handle (if TheWindow is pointing to a carbon window) if (TheWindow->getType().isDerivedFrom(CarbonWindow::getClassType())) { HIWindowRef windowRef = aglGetWindowRef(dynamic_cast<CarbonWindow* const>(TheWindow)->getContext()); HIViewRef contentView = 0; GetRootControl(windowRef, &contentView); //uint32_t aglHandler = CarbonWindowPtr::dcast(TheWindow)->winId(); libvlc_media_player_set_agl (_MediaPlayer, reinterpret_cast<uint32_t>(contentView) ); checkVLCError("attaching media player to carbon window"); } #endif #ifdef WIN32 if (TheWindow->getType().isDerivedFrom(WIN32Window::getClassType())) { libvlc_media_player_set_hwnd (_MediaPlayer, dynamic_cast<WIN32Window* const>(TheWindow)->getHwnd() ); checkVLCError("attaching media player to WIN32 window"); } #endif #ifdef __linux if (TheWindow->getType().isDerivedFrom(XWindow::getClassType())) { libvlc_media_player_set_xwindow (_MediaPlayer, dynamic_cast<XWindow* const>(TheWindow)->getDisplay() ); checkVLCError("attaching media player to Xwindow"); } #endif libvlc_video_set_callbacks(_MediaPlayer, lock, unlock, display, &_VideoMemContext); _VideoMemContext._pixels = ( UInt8* )malloc( ( sizeof( *( _VideoMemContext._pixels ) ) * Width * Height ) * 4 ); libvlc_video_set_format(_MediaPlayer, "RV24", Width, Height, Width * 3); //Start playing the video libvlc_media_player_play( _MediaPlayer ); checkVLCError("playing the media"); do { currentState = libvlc_media_player_get_state(_MediaPlayer); checkVLCError("getting state"); } while(currentState != libvlc_Playing); clock_t endwait; endwait = clock () + 2 * CLOCKS_PER_SEC ; while (clock() < endwait) {} _Initialized = true; // check if the player can be paused if(libvlc_media_player_can_pause(_MediaPlayer)) { // can pause it? do it libvlc_media_player_pause(_MediaPlayer); // error checking of course checkVLCError("pausing media player"); libvlc_media_player_set_position( _MediaPlayer, 0.0f ); checkVLCError("setting position during player initialization"); } return errorOpening; }
VideoWindow::VideoWindow(Context *context) : GcWindow(context), context(context), m_MediaChanged(false) { setControls(NULL); setProperty("color", QColor(Qt::black)); QHBoxLayout *layout = new QHBoxLayout(); setLayout(layout); init = true; // assume initialisation was ok ... #ifdef GC_VIDEO_VLC // // USE VLC VIDEOPLAYER // #if QT_VERSION >= 0x050000 #warning "WARNING: Please ensure the VLC QT4 plugin (gui/libqt4_plugin) is NOT available as it will cause GC to crash." #endif // config parameters to libvlc const char * const vlc_args[] = { "-I", "dummy", /* Don't use any interface */ "--ignore-config", /* Don't use VLC's config */ "--disable-screensaver", /* disable screensaver during playback */ #ifdef Q_OS_LINUX "--no-xlib", // avoid xlib thread error messages #endif //"--verbose=-1", // -1 = no output at all //"--quiet" }; /* create an exception handler */ //libvlc_exception_init(&exceptions); //vlc_exceptions(&exceptions); /* Load the VLC engine */ inst = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args); //vlc_exceptions(&exceptions); /* Create a new item */ if (inst) { // if vlc doesn't initialise don't even try! m = NULL; //vlc_exceptions(&exceptions); /* Create a media player playing environement */ mp = libvlc_media_player_new (inst); //vlc_exceptions(&exceptions); //vlc_exceptions(&exceptions); /* This is a non working code that show how to hooks into a window, * if we have a window around */ #ifdef Q_OS_LINUX #if QT_VERSION > 0x50000 x11Container = new QWidget(this); //XXX PORT TO 5.1 BROKEN CODE XXX #else x11Container = new QX11EmbedContainer(this); #endif layout->addWidget(x11Container); libvlc_media_player_set_xwindow (mp, x11Container->winId()); #endif #ifdef WIN32 container = new QWidget(this); layout->addWidget(container); libvlc_media_player_set_hwnd (mp, (HWND)(container->winId())); QString filename = context->athlete->home->config().canonicalPath() + "/" + "video-layout.xml"; QFileInfo finfo(filename); if (finfo.exists()) { QFile file(filename); // clean previous layout foreach(MeterWidget* p_meterWidget, m_metersWidget) { m_metersWidget.removeAll(p_meterWidget); delete p_meterWidget; } VideoLayoutParser handler(&m_metersWidget, container); QXmlInputSource source (&file); QXmlSimpleReader reader; reader.setContentHandler (&handler); reader.parse (source); }
VideoWindow::VideoWindow(Context *context, const QDir &home) : GcWindow(context), home(home), context(context), m_MediaChanged(false) { setControls(NULL); setInstanceName("Video Window"); setProperty("color", Qt::black); QHBoxLayout *layout = new QHBoxLayout(); setLayout(layout); // config paramaters to libvlc const char * const vlc_args[] = { "-I", "dummy", /* Don't use any interface */ "--ignore-config", /* Don't use VLC's config */ "--disable-screensaver", /* disable screensaver during playback */ #ifdef Q_OS_LINUX "--no-xlib", // avoid xlib thread error messages #endif "--verbose=-1", // -1 = no output at all "--quiet" }; /* create an exception handler */ //libvlc_exception_init(&exceptions); //vlc_exceptions(&exceptions); /* Load the VLC engine */ inst = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args); //vlc_exceptions(&exceptions); /* Create a new item */ m = NULL; //vlc_exceptions(&exceptions); /* Create a media player playing environement */ mp = libvlc_media_player_new (inst); //vlc_exceptions(&exceptions); //vlc_exceptions(&exceptions); /* This is a non working code that show how to hooks into a window, * if we have a window around */ #ifdef Q_OS_LINUX x11Container = new QX11EmbedContainer(this); layout->addWidget(x11Container); libvlc_media_player_set_xwindow (mp, x11Container->winId()); #endif #ifdef WIN32 container = new QWidget(this); layout->addWidget(container); libvlc_media_player_set_hwnd (mp, container->winId()); #endif connect(context, SIGNAL(stop()), this, SLOT(stopPlayback())); connect(context, SIGNAL(start()), this, SLOT(startPlayback())); connect(context, SIGNAL(pause()), this, SLOT(pausePlayback())); connect(context, SIGNAL(seek(long)), this, SLOT(seekPlayback(long))); connect(context, SIGNAL(unpause()), this, SLOT(resumePlayback())); connect(context, SIGNAL(mediaSelected(QString)), this, SLOT(mediaSelected(QString))); }