diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2009-12-03 05:52:14 -0500 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2009-12-03 05:52:14 -0500 |
commit | 389331fb00bced53e725e96012eca08dd17c45f1 (patch) | |
tree | 41734edf84ca7619abd414d98d380015e675e436 | |
parent | Build on OSX (diff) | |
download | EmbeddedBrowserPrototype-389331fb00bced53e725e96012eca08dd17c45f1.tar.xz EmbeddedBrowserPrototype-389331fb00bced53e725e96012eca08dd17c45f1.zip |
Smarter attachment of WinId.
-rw-r--r-- | BrowserWindow.cpp | 2 | ||||
-rw-r--r-- | DVDPluginWebPage.cpp | 4 | ||||
-rw-r--r-- | Test.html | 6 | ||||
-rw-r--r-- | vlcwrapper/VLCVideoWidget.cpp | 37 | ||||
-rw-r--r-- | 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<QObject*>(QMetaType::construct(QMetaType::type(classid.toLatin1()))); - qDebug() << obj; - return obj; + return static_cast<QObject*>(QMetaType::construct(QMetaType::type(classid.toLatin1()))); } void DVDPluginWebPage::javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID) { @@ -4,11 +4,11 @@ </head> <body> <h2> - <img src="http://anyclip.com/images/anyclip-logo.png" /><br /> - Framed! + <img src="http://anyclip.com/images/anyclip-logo.png" /><br /> + Framed! </h2> <object type="application/x-qt-plugin" classid="RandomFrameWidget" name="framed" width="640" height="480"></object> - <script language="javascript">framed.showSource("D:\\");</script> + <script language="javascript">framed.showSource("/dev/dvd");</script> <br /><button onclick="framed.moveToRandomTime()">Next Random Frame</button> </body> </html> 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:[[<source address>]@[<bind address>][:<bind port>]] + [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>]] */ 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(); |