]> git.sur5r.net Git - minitube/commitdiff
Workaround for playback not starting on the Mac
authorFlavio Tordini <flavio.tordini@gmail.com>
Wed, 1 Jul 2009 15:56:50 +0000 (17:56 +0200)
committerFlavio Tordini <flavio.tordini@gmail.com>
Wed, 1 Jul 2009 15:56:50 +0000 (17:56 +0200)
Fixed fullscreen window on the Mac

src/MediaView.cpp
src/MediaView.h

index d44bc675080cd213f599ba4a5e5dd95493dcae12..8f0ec4901eb06b12515d94ffa023beb9804663b0 100644 (file)
@@ -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();
+    }
+}
index 705d60c1049fa59486b6b2aba93c6ac08744d1b0..80a60c3c171ba843c43d35bc49e9b1814577a81b 100644 (file)
@@ -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__