summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2009-12-03 05:52:14 -0500
committerJason A. Donenfeld <Jason@zx2c4.com>2009-12-03 05:52:14 -0500
commit389331fb00bced53e725e96012eca08dd17c45f1 (patch)
tree41734edf84ca7619abd414d98d380015e675e436
parentBuild on OSX (diff)
downloadEmbeddedBrowserPrototype-389331fb00bced53e725e96012eca08dd17c45f1.tar.xz
EmbeddedBrowserPrototype-389331fb00bced53e725e96012eca08dd17c45f1.zip
Smarter attachment of WinId.
-rw-r--r--BrowserWindow.cpp2
-rw-r--r--DVDPluginWebPage.cpp4
-rw-r--r--Test.html6
-rw-r--r--vlcwrapper/VLCVideoWidget.cpp37
-rw-r--r--vlcwrapper/VLCVideoWidget.h2
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)
{
diff --git a/Test.html b/Test.html
index 3ffd565..d646c61 100644
--- a/Test.html
+++ b/Test.html
@@ -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();