MediaPlayer: Move winding code into its own function.

This commit is contained in:
Michael Lotz
2013-11-24 22:37:27 +01:00
parent dcc56bf748
commit 2937bbe3bc
2 changed files with 32 additions and 22 deletions
+30 -22
View File
@@ -844,9 +844,6 @@ MainWin::MessageReceived(BMessage* msg)
case M_WIND: case M_WIND:
{ {
if (!fAllowWinding)
break;
bigtime_t howMuch; bigtime_t howMuch;
int64 frames; int64 frames;
if (msg->FindInt64("how much", &howMuch) != B_OK if (msg->FindInt64("how much", &howMuch) != B_OK
@@ -854,25 +851,7 @@ MainWin::MessageReceived(BMessage* msg)
break; break;
} }
if (fController->Lock()) { _Wind(howMuch, frames);
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;
}
break; break;
} }
@@ -2400,6 +2379,35 @@ MainWin::_ShowFullscreenControls(bool show, bool animate)
// #pragma mark - // #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 void
MainWin::_UpdatePlaylistItemFile() MainWin::_UpdatePlaylistItemFile()
{ {
+2
View File
@@ -121,6 +121,8 @@ private:
void _ShowFullscreenControls(bool show, void _ShowFullscreenControls(bool show,
bool animate = true); bool animate = true);
void _Wind(bigtime_t howMuch, int64 frames);
void _UpdatePlaylistItemFile(); void _UpdatePlaylistItemFile();
void _UpdateAttributesMenu(const BNode& node); void _UpdateAttributesMenu(const BNode& node);
void _SetRating(int32 rating); void _SetRating(int32 rating);