From 3f45e1e6ef520ad189ba680fef0460bc19fe48fa Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 6 Aug 2018 20:13:13 +0200 Subject: [PATCH] Do not play/pause files nedlessly. The Controller would always pause and resume playing, even if it found out there was no position or volume to restore. Since pausing on http streams appears to be broken, this is not a good idea. Just check if we have something to restore, and leave the function if not. Fixes #14326 --- src/apps/mediaplayer/Controller.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/apps/mediaplayer/Controller.cpp b/src/apps/mediaplayer/Controller.cpp index bdfee11465..2138e62f1c 100644 --- a/src/apps/mediaplayer/Controller.cpp +++ b/src/apps/mediaplayer/Controller.cpp @@ -723,13 +723,20 @@ Controller::RestoreState() if (item == NULL) return; + int lastFrame = item->LastFrame(); + float lastVolume = item->LastVolume(); + + // Don't Pause()/Play() if we have nothing to do. + if (lastFrame <= 0 && lastVolume < 0) + return; + Pause(); - if (item->LastFrame() > 0) { + if (lastFrame > 0) { bool resume = fResume == mpSettings::RESUME_ALWAYS; if (fResume == mpSettings::RESUME_ASK) { BString label; - int32 time = (int32)((float)item->LastFrame() * TimeDuration() + int32 time = (int32)((float)lastFrame * TimeDuration() / (1000000 * _FrameDuration())); label.SetToFormat(B_TRANSLATE("Do you want to resume %s at %dm%ds?"), item->Name().String(), time / 60, time % 60); @@ -739,10 +746,9 @@ Controller::RestoreState() } if (resume) - SetFramePosition(item->LastFrame()); + SetFramePosition(lastFrame); } - float lastVolume = item->LastVolume(); if (lastVolume >= 0) SetVolume(lastVolume);