From: Flavio Tordini Date: Wed, 1 Jul 2009 15:56:50 +0000 (+0200) Subject: Workaround for playback not starting on the Mac X-Git-Tag: 0.4~14 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1f16c102190a8cba13101aa14d882c9a6e13a95a;p=minitube Workaround for playback not starting on the Mac Fixed fullscreen window on the Mac --- diff --git a/src/MediaView.cpp b/src/MediaView.cpp index d44bc67..8f0ec49 100644 --- a/src/MediaView.cpp +++ b/src/MediaView.cpp @@ -63,19 +63,19 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) { splitter->addWidget(playlistWidget); videoAreaWidget = new VideoAreaWidget(this); + videoAreaWidget->setMinimumSize(320,240); videoWidget = new Phonon::VideoWidget(this); - videoWidget->setMinimumSize(320,240); videoAreaWidget->setVideoWidget(videoWidget); loadingWidget = new LoadingWidget(this); - loadingWidget->setMinimumSize(320,240); videoAreaWidget->setLoadingWidget(loadingWidget); splitter->addWidget(videoAreaWidget); layout->addWidget(splitter); setLayout(layout); + } MediaView::~MediaView() { @@ -112,11 +112,14 @@ void MediaView::search(SearchParams *searchParams) { } void MediaView::disappear() { - + timerPlayFlag = true; } -void MediaView::stateChanged(Phonon::State newState, Phonon::State /* oldState */) +void MediaView::stateChanged(Phonon::State newState, Phonon::State oldState) { + + qDebug() << "Phonon state: " << newState << oldState; + switch (newState) { case Phonon::ErrorState: @@ -135,6 +138,9 @@ void MediaView::stateChanged(Phonon::State newState, Phonon::State /* oldState * // play() has already been called when setting the source // but Phonon on Linux needs a little more help to start playback mediaObject->play(); + if (!timerPlayFlag) { + QTimer::singleShot(1000, this, SLOT(timerPlay())); + } break; case Phonon::PausedState: @@ -172,9 +178,10 @@ void MediaView::fullscreen() { } void MediaView::exitFullscreen() { - videoAreaWidget->setParent(this); + // videoAreaWidget->setParent(this); splitter->addWidget(videoAreaWidget); - videoAreaWidget->show(); + // Just calling show() on the Mac won't work + videoAreaWidget->showNormal(); splitter->restoreState(splitterState); } @@ -191,11 +198,14 @@ void MediaView::activeRowChanged(int row) { // immediately show the loading widget videoAreaWidget->showLoading(video); - mediaObject->pause(); + // mediaObject->pause(); connect(video, SIGNAL(gotStreamUrl(QUrl)), SLOT(gotStreamUrl(QUrl))); video->loadStreamUrl(); + // reset the timer flag + timerPlayFlag = false; + // see you in gotStreamUrl... } @@ -305,6 +315,14 @@ void MediaView::searchMostViewed() { } void MediaView::setPlaylistVisible(bool visible) { - playlistWidget->setVisible(visible); + playlistWidget->setVisible(visible); } +void MediaView::timerPlay() { + qDebug() << mediaObject->currentTime(); + // Workaround Phonon bug on Mac OSX + if (mediaObject->currentTime() <= 0 && mediaObject->state() == Phonon::PlayingState) { + mediaObject->pause(); + mediaObject->play(); + } +} diff --git a/src/MediaView.h b/src/MediaView.h index 705d60c..80a60c3 100644 --- a/src/MediaView.h +++ b/src/MediaView.h @@ -65,6 +65,8 @@ private slots: void searchMostRelevant(); void searchMostRecent(); void searchMostViewed(); + // timer + void timerPlay(); private: @@ -91,6 +93,8 @@ private: VideoAreaWidget *videoAreaWidget; LoadingWidget *loadingWidget; + bool timerPlayFlag; + }; #endif // __MEDIAVIEW_H__