From 1e9670afd05b513f6845a2f70e9a4b08a13b8d25 Mon Sep 17 00:00:00 2001 From: Flavio Tordini Date: Wed, 2 Sep 2009 10:48:34 +0200 Subject: [PATCH] Fixed loading of empty url when stopping videos --- src/MediaView.cpp | 22 +++++++++++++++++++--- src/MediaView.h | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/MediaView.cpp b/src/MediaView.cpp index f5b256f..c4ed91e 100644 --- a/src/MediaView.cpp +++ b/src/MediaView.cpp @@ -79,7 +79,14 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) { videoAreaWidget = new VideoAreaWidget(this); videoAreaWidget->setMinimumSize(320,240); + +#ifdef Q_WS_MAC + // mouse autohide does not work on the Mac (no mouseMoveEvent) + videoWidget = new Phonon::VideoWidget(this); +#else videoWidget = new VideoWidget(this); +#endif + videoAreaWidget->setVideoWidget(videoWidget); videoAreaWidget->setListModel(listModel); @@ -96,6 +103,11 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) { errorTimer->setInterval(3000); connect(errorTimer, SIGNAL(timeout()), SLOT(skipVideo())); + workaroundTimer = new QTimer(this); + workaroundTimer->setSingleShot(true); + workaroundTimer->setInterval(1000); + connect(workaroundTimer, SIGNAL(timeout()), SLOT(timerPlay())); + } MediaView::~MediaView() { @@ -173,7 +185,7 @@ void MediaView::stateChanged(Phonon::State newState, Phonon::State /*oldState*/) // Workaround for Mac playback start problem if (!timerPlayFlag) { - QTimer::singleShot(1000, this, SLOT(timerPlay())); + workaroundTimer->start(); } break; @@ -211,10 +223,13 @@ void MediaView::stop() { listModel->abortSearch(); reallyStopped = true; mediaObject->stop(); - // mediaObject->clear(); + workaroundTimer->stop(); + errorTimer->stop(); } void MediaView::activeRowChanged(int row) { + if (reallyStopped) return; + Video *video = listModel->videoAt(row); if (!video) return; @@ -240,6 +255,7 @@ void MediaView::activeRowChanged(int row) { } void MediaView::gotStreamUrl(QUrl streamUrl) { + if (reallyStopped) return; // go! mediaObject->setCurrentSource(streamUrl); @@ -276,7 +292,7 @@ void MediaView::aboutToFinish() { } void MediaView::currentSourceChanged(const Phonon::MediaSource source) { - qDebug() << "Source changed:" << source.url(); + qDebug() << source.url().toString(); } diff --git a/src/MediaView.h b/src/MediaView.h index 5344cc6..616ad3e 100644 --- a/src/MediaView.h +++ b/src/MediaView.h @@ -95,6 +95,7 @@ private: bool reallyStopped; QTimer *errorTimer; + QTimer *workaroundTimer; Video *skippedVideo; }; -- 2.39.5