From 2937bbe3bca5da7b7fbdbab6262b72babb861083 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 24 Nov 2013 22:20:06 +0100 Subject: [PATCH] MediaPlayer: Move winding code into its own function. --- src/apps/mediaplayer/MainWin.cpp | 52 ++++++++++++++++++-------------- src/apps/mediaplayer/MainWin.h | 2 ++ 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp index 1a43cb1d26..6c2b4580a9 100644 --- a/src/apps/mediaplayer/MainWin.cpp +++ b/src/apps/mediaplayer/MainWin.cpp @@ -844,9 +844,6 @@ MainWin::MessageReceived(BMessage* msg) case M_WIND: { - if (!fAllowWinding) - break; - bigtime_t howMuch; int64 frames; if (msg->FindInt64("how much", &howMuch) != B_OK @@ -854,25 +851,7 @@ MainWin::MessageReceived(BMessage* msg) break; } - if (fController->Lock()) { - if (fHasVideo && !fController->IsPlaying()) { - int64 newFrame = fController->CurrentFrame() + frames; - fController->SetFramePosition(newFrame); - } else { - bigtime_t seekTime = fController->TimePosition() + howMuch; - if (seekTime < 0) { - fInitialSeekPosition = seekTime; - PostMessage(M_SKIP_PREV); - } else if (seekTime > fController->TimeDuration()) { - fInitialSeekPosition = 0; - PostMessage(M_SKIP_NEXT); - } else - fController->SetTimePosition(seekTime); - } - fController->Unlock(); - - fAllowWinding = false; - } + _Wind(howMuch, frames); break; } @@ -2400,6 +2379,35 @@ MainWin::_ShowFullscreenControls(bool show, bool animate) // #pragma mark - +void +MainWin::_Wind(bigtime_t howMuch, int64 frames) +{ + if (!fAllowWinding || !fController->Lock()) + return; + + if (frames != 0 && fHasVideo && !fController->IsPlaying()) { + int64 newFrame = fController->CurrentFrame() + frames; + fController->SetFramePosition(newFrame); + } else { + bigtime_t seekTime = fController->TimePosition() + howMuch; + if (seekTime < 0) { + fInitialSeekPosition = seekTime; + PostMessage(M_SKIP_PREV); + } else if (seekTime > fController->TimeDuration()) { + fInitialSeekPosition = 0; + PostMessage(M_SKIP_NEXT); + } else + fController->SetTimePosition(seekTime); + } + + fController->Unlock(); + fAllowWinding = false; +} + + +// #pragma mark - + + void MainWin::_UpdatePlaylistItemFile() { diff --git a/src/apps/mediaplayer/MainWin.h b/src/apps/mediaplayer/MainWin.h index 8994b132f3..c2b2de815f 100644 --- a/src/apps/mediaplayer/MainWin.h +++ b/src/apps/mediaplayer/MainWin.h @@ -121,6 +121,8 @@ private: void _ShowFullscreenControls(bool show, bool animate = true); + void _Wind(bigtime_t howMuch, int64 frames); + void _UpdatePlaylistItemFile(); void _UpdateAttributesMenu(const BNode& node); void _SetRating(int32 rating);