From: Flavio Tordini Date: Mon, 3 Aug 2015 13:45:19 +0000 (+0200) Subject: Get a new stream url after long pause X-Git-Tag: 2.5~49 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=99400437850d0b13d84a6e42552934410167505e;p=minitube Get a new stream url after long pause --- diff --git a/src/mediaview.cpp b/src/mediaview.cpp index 08798bf..a2c4587 100644 --- a/src/mediaview.cpp +++ b/src/mediaview.cpp @@ -70,6 +70,7 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) #ifdef APP_SNAPSHOT , snapshotSettings(0) #endif + , pauseTime(0) { } void MediaView::initialize() { @@ -322,9 +323,13 @@ void MediaView::handleError(const QString &message) { #ifdef APP_PHONON void MediaView::stateChanged(Phonon::State newState, Phonon::State /*oldState*/) { - if (newState == Phonon::PlayingState) + if (pauseTime > 0 && (newState == Phonon::PlayingState || newState == Phonon::BufferingState)) { + mediaObject->seek(pauseTime); + pauseTime = 0; + } + if (newState == Phonon::PlayingState) { videoAreaWidget->showVideo(); - else if (newState == Phonon::ErrorState) { + } else if (newState == Phonon::ErrorState) { qWarning() << "Phonon error:" << mediaObject->errorString() << mediaObject->errorType(); if (mediaObject->errorType() == Phonon::FatalError) handleError(mediaObject->errorString()); @@ -337,9 +342,14 @@ void MediaView::pause() { switch( mediaObject->state() ) { case Phonon::PlayingState: mediaObject->pause(); + pauseTimer.start(); break; default: - mediaObject->play(); + if (pauseTimer.hasExpired(60000)) { + pauseTimer.invalidate(); + connect(playlistModel->activeVideo(), SIGNAL(gotStreamUrl(QUrl)), SLOT(resumeWithNewStreamUrl(QUrl))); + playlistModel->activeVideo()->loadStreamUrl(); + } else mediaObject->play(); break; } #endif @@ -905,6 +915,19 @@ void MediaView::startDownloading() { downloadItem->start(); } +void MediaView::resumeWithNewStreamUrl(const QUrl &streamUrl) { + pauseTime = mediaObject->currentTime(); + mediaObject->setCurrentSource(streamUrl); + mediaObject->play(); + + Video *video = static_cast