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 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 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 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 } }
void TestVideo::scrapit() { qDebug() << "Cleaning everything"; libvlc_media_player_stop(mp); libvlc_media_player_set_nsobject(mp, NULL); libvlc_media_player_release(mp); mp = 0; libvlc_release(ins); ins = 0; this->parentWidget()->layout()->removeWidget(this); this->destroy(true, true); }
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(); } }
TestVideo::TestVideo(QWidget *parent) : QWidget(parent) { QString path = QString::fromAscii("file:///Volumes/UltraFat/Ted_Bundy.avi"); const char * const vlcArgs[] = { "--intf", "macosx" }; qDebug() << this->winId(); ins = libvlc_new(sizeof(vlcArgs) / sizeof(*vlcArgs), vlcArgs); mp = libvlc_media_player_new(ins); libvlc_media_player_set_nsobject( mp, (void *) this->winId()); libvlc_media_player_set_media(mp, libvlc_media_new_path(ins, path.toLocal8Bit())); libvlc_media_player_play(mp); // Kill the stuff in 5 seconds timer = new QTimer(this); timer->setInterval(10000); connect(timer,SIGNAL(timeout()),this,SLOT(scrapit())); timer->start(); }
int __stdcall show_vlc(void *data) { libvlc_instance_t * inst; libvlc_media_player_t *mp; libvlc_media_t *m; int rc; HANDLE w; WNDCLASSEX wc; /* Load the VLC engine */ inst = libvlc_new (0, NULL); /* Create a new item */ m = libvlc_media_new_path (inst, "C:\\Temp\\[001_1-01] Broken Bow (Part 1).mpg"); /* Create a media player playing environement */ mp = libvlc_media_player_new_from_media (m); /* No need to keep the media now */ libvlc_media_release (m); //Step 1: Registering the Window Class wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInst; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = L"myclassstuff"; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if(!RegisterClassEx(&wc)) { MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK); return 0; } w = CreateWindow(L"myclassstuff", L"VLC Window", WS_OVERLAPPEDWINDOW, 50, 50, 400, 400, NULL, NULL, hInst, NULL); if (!w) { DWORD d = GetLastError(); printf ("===================== %08x ==============\n", d); } // libvlc_media_player_set_hwnd (mp, w); // ShowWindow(w, SW_SHOW); // UpdateWindow(w); #if 0 /* This is a non working code that show how to hooks into a window, * if we have a window around */ libvlc_media_player_set_xdrawable (mp, xdrawable); /* or on windows */ /* or on mac os */ libvlc_media_player_set_nsobject (mp, view); #endif /* play the media_player */ rc = libvlc_media_player_play (mp); Sleep (60000); /* Let it play a bit */ /* Stop playing */ libvlc_media_player_stop (mp); /* Free the media_player */ libvlc_media_player_release (mp); libvlc_release (inst); return 0; }