From: Flavio Date: Sat, 29 Jan 2011 21:12:05 +0000 (+0100) Subject: Handle invalid finished signals from Phonon X-Git-Tag: 1.4~27 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9335bc1ce586999324e4240d293e1768893b69b2;p=minitube Handle invalid finished signals from Phonon --- diff --git a/src/MediaView.cpp b/src/MediaView.cpp index 44e7078..0fd49b2 100644 --- a/src/MediaView.cpp +++ b/src/MediaView.cpp @@ -140,12 +140,12 @@ void MediaView::initialize() { void MediaView::setMediaObject(Phonon::MediaObject *mediaObject) { this->mediaObject = mediaObject; Phonon::createPath(this->mediaObject, videoWidget); - connect(mediaObject, SIGNAL(finished()), this, SLOT(skip())); + connect(mediaObject, SIGNAL(finished()), this, SLOT(playbackFinished())); connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(stateChanged(Phonon::State, Phonon::State))); connect(mediaObject, SIGNAL(currentSourceChanged(Phonon::MediaSource)), this, SLOT(currentSourceChanged(Phonon::MediaSource))); - connect(mediaObject, SIGNAL(bufferStatus(int)), loadingWidget, SLOT(bufferStatus(int))); + // connect(mediaObject, SIGNAL(bufferStatus(int)), loadingWidget, SLOT(bufferStatus(int))); } void MediaView::search(SearchParams *searchParams) { @@ -214,12 +214,12 @@ void MediaView::stateChanged(Phonon::State newState, Phonon::State /*oldState*/) break; case Phonon::PlayingState: - qDebug("playing"); + // qDebug("playing"); videoAreaWidget->showVideo(); break; case Phonon::StoppedState: - qDebug("stopped"); + // qDebug("stopped"); // play() has already been called when setting the source // but Phonon on Linux needs a little more help to start playback // if (!reallyStopped) mediaObject->play(); @@ -342,7 +342,10 @@ void MediaView::gotStreamUrl(QUrl streamUrl) { downloadItem = new DownloadItem(videoCopy, streamUrl, tempFile, this); connect(downloadItem, SIGNAL(statusChanged()), SLOT(downloadStatusChanged())); // connect(downloadItem, SIGNAL(progress(int)), SLOT(downloadProgress(int))); + connect(downloadItem, SIGNAL(bufferProgress(int)), loadingWidget, SLOT(bufferStatus(int))); // connect(downloadItem, SIGNAL(finished()), SLOT(itemFinished())); + connect(video, SIGNAL(errorStreamUrl(QString)), SLOT(handleError(QString))); + connect(downloadItem, SIGNAL(error(QString)), SLOT(handleError(QString))); downloadItem->start(); } @@ -381,15 +384,16 @@ void MediaView::downloadStatusChanged() { startPlaying(); break; case Starting: - qDebug() << "Starting"; + // qDebug() << "Starting"; break; case Finished: - qDebug() << "Finished"; + // qDebug() << "Finished" << mediaObject->state(); + // if (mediaObject->state() == Phonon::StoppedState) startPlaying(); break; case Failed: - qDebug() << "Failed"; + // qDebug() << "Failed"; case Idle: - qDebug() << "Idle"; + // qDebug() << "Idle"; break; } } @@ -451,6 +455,18 @@ void MediaView::skip() { listModel->setActiveRow(nextRow); } +void MediaView::playbackFinished() { + if (mediaObject->currentTime() < mediaObject->totalTime()) { + // mediaObject->seek(mediaObject->currentTime()); + QTimer::singleShot(3000, this, SLOT(playbackResume())); + } else skip(); +} + +void MediaView::playbackResume() { + mediaObject->seek(mediaObject->currentTime()); + mediaObject->play(); +} + void MediaView::openWebPage() { Video* video = listModel->activeVideo(); if (!video) return; diff --git a/src/MediaView.h b/src/MediaView.h index f61799a..a4016be 100644 --- a/src/MediaView.h +++ b/src/MediaView.h @@ -83,6 +83,8 @@ private slots: #endif void startPlaying(); void downloadStatusChanged(); + void playbackFinished(); + void playbackResume(); /* void downloadProgress(int percent);