From 389331fb00bced53e725e96012eca08dd17c45f1 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 3 Dec 2009 05:52:14 -0500 Subject: Smarter attachment of WinId. --- BrowserWindow.cpp | 2 +- DVDPluginWebPage.cpp | 4 +--- Test.html | 6 +++--- vlcwrapper/VLCVideoWidget.cpp | 37 +++++++++++++++++++++---------------- vlcwrapper/VLCVideoWidget.h | 2 ++ 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/BrowserWindow.cpp b/BrowserWindow.cpp index 2939864..fe2ff32 100644 --- a/BrowserWindow.cpp +++ b/BrowserWindow.cpp @@ -17,7 +17,7 @@ BrowserWindow::BrowserWindow(QWidget *parent) : connect(m_browser, SIGNAL(urlChanged(QUrl)), this, SLOT(updateUrlBox(QUrl))); connect(m_urlBox, SIGNAL(returnPressed()), this, SLOT(navigateToPage())); m_browser->setPage(new DVDPluginWebPage(m_browser)); - m_browser->load(QString("http://www.anyclip.com")); + m_browser->load(QString("/home/zx2c4/Projects/AnyClipBrowser/Test.html")); } void BrowserWindow::updateUrlBox(const QUrl &url) { diff --git a/DVDPluginWebPage.cpp b/DVDPluginWebPage.cpp index 6e1392b..487456d 100644 --- a/DVDPluginWebPage.cpp +++ b/DVDPluginWebPage.cpp @@ -13,9 +13,7 @@ QObject* DVDPluginWebPage::createPlugin(const QString &classid, const QUrl &url, Q_UNUSED(paramNames); Q_UNUSED(paramValues); qDebug() << "asked to create" << classid; - QObject *obj = static_cast(QMetaType::construct(QMetaType::type(classid.toLatin1()))); - qDebug() << obj; - return obj; + return static_cast(QMetaType::construct(QMetaType::type(classid.toLatin1()))); } void DVDPluginWebPage::javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID) { diff --git a/Test.html b/Test.html index 3ffd565..d646c61 100644 --- a/Test.html +++ b/Test.html @@ -4,11 +4,11 @@

-
- Framed! +
+ Framed!

- +
diff --git a/vlcwrapper/VLCVideoWidget.cpp b/vlcwrapper/VLCVideoWidget.cpp index 69d111c..04f1a3c 100644 --- a/vlcwrapper/VLCVideoWidget.cpp +++ b/vlcwrapper/VLCVideoWidget.cpp @@ -41,7 +41,7 @@ VLCVideoWidget::~VLCVideoWidget() libvlc_event_detach(m_eventManager, libvlc_MediaPlayerTimeChanged, vlcCallbacks, this, VLCLoader::instance()->exception()); libvlc_event_detach(m_eventManager, libvlc_MediaPlayerPositionChanged, vlcCallbacks, this, VLCLoader::instance()->exception()); libvlc_event_detach(m_eventManager, libvlc_MediaPlayerSeekableChanged, vlcCallbacks, this, VLCLoader::instance()->exception()); - libvlc_event_detach(m_eventManager, libvlc_MediaPlayerPausableChanged, vlcCallbacks, this, VLCLoader::instance()->exception()); + libvlc_event_detach(m_eventManager, libvlc_MediaPlayerPausableChanged, vlcCallbacks, this, VLCLoader::instance()->exception()); libvlc_event_detach(m_eventManager, libvlc_MediaPlayerTitleChanged, vlcCallbacks, this, VLCLoader::instance()->exception()); libvlc_event_detach(m_eventManager, libvlc_MediaPlayerSnapshotTaken, vlcCallbacks, this, VLCLoader::instance()->exception()); libvlc_media_player_stop(m_mediaPlayer, VLCLoader::instance()->exception()); @@ -105,15 +105,15 @@ void VLCVideoWidget::vlcCallbacks(const libvlc_event_t* event, void* ptr) /* the file has to be in one of the following formats: - [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:[[]@[][:]] + [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:[[]@[][:]] */ bool VLCVideoWidget::setSource(const QString &source) { @@ -134,16 +134,21 @@ QString VLCVideoWidget::source() const } bool VLCVideoWidget::play() { + attachVideoDisplay(); + libvlc_media_player_play(m_mediaPlayer, VLCLoader::instance()->exception()); + return VLCLoader::instance()->checkError(); +} +bool VLCVideoWidget::attachVideoDisplay() +{ + if (!effectiveWinId()) + return false; #if defined(Q_WS_WIN) - libvlc_media_player_set_hwnd(m_mediaPlayer, winId(), VLCLoader::instance()->exception()); + libvlc_media_player_set_hwnd(m_mediaPlayer, effectiveWinId(), VLCLoader::instance()->exception()); #elif defined(Q_WS_MAC) - libvlc_media_player_set_agl(m_mediaPlayer, winId(), VLCLoader::instance()->exception()); + libvlc_media_player_set_agl(m_mediaPlayer, effectiveWinId(), VLCLoader::instance()->exception()); #elif defined(Q_WS_X11) - libvlc_media_player_set_xwindow(m_mediaPlayer, winId(), VLCLoader::instance()->exception()); + libvlc_media_player_set_xwindow(m_mediaPlayer, effectiveWinId(), VLCLoader::instance()->exception()); #endif - if(!VLCLoader::instance()->checkError()) - return false; - libvlc_media_player_play(m_mediaPlayer, VLCLoader::instance()->exception()); return VLCLoader::instance()->checkError(); } bool VLCVideoWidget::pause() diff --git a/vlcwrapper/VLCVideoWidget.h b/vlcwrapper/VLCVideoWidget.h index 790e123..a270a17 100644 --- a/vlcwrapper/VLCVideoWidget.h +++ b/vlcwrapper/VLCVideoWidget.h @@ -45,6 +45,8 @@ private: libvlc_media_t *m_media; libvlc_event_manager_t *m_eventManager; static void vlcCallbacks(const libvlc_event_t* event, void* ptr); +private slots: + bool attachVideoDisplay(); signals: void opening(); void buffering(); -- cgit v1.2.3-59-g8ed1b