From 8ab9ba77ae4f18fb6c0e4338e347a773a1188e39 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 5 Dec 2011 05:26:58 +0000 Subject: [PATCH] Remove the prohibition against seeking while video is playing and just do Stop; Seek; Play as the slider already did in some cases Originally committed to SVN as r5964. --- aegisub/src/video_context.cpp | 14 ++++++++------ aegisub/src/video_context.h | 3 --- aegisub/src/video_slider.cpp | 24 ++++++------------------ 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index 3183ecebb..b27d8bfe8 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -74,7 +74,6 @@ VideoContext::VideoContext() : playback(this) , startMS(0) , endFrame(0) -, playNextFrame(-1) , nextFrame(-1) , keepAudioSync(true) , frame_n(0) @@ -271,13 +270,17 @@ void VideoContext::OnSubtitlesSave() { void VideoContext::JumpToFrame(int n) { if (!IsLoaded()) return; - // Prevent intervention during playback - if (IsPlaying() && n != playNextFrame) return; + bool was_playing = IsPlaying(); + if (was_playing) + Stop(); frame_n = mid(0, n, GetLength() - 1); GetFrameAsync(frame_n); Seek(frame_n); + + if (was_playing) + Play(); } void VideoContext::JumpToTime(int ms, agi::vfr::Time end) { @@ -402,7 +405,6 @@ void VideoContext::PlayLine() { endFrame = FrameAtTime(context->selectionController->GetActiveLine()->End.GetMS(),agi::vfr::END) + 1; // Jump to start - playNextFrame = startFrame; JumpToFrame(startFrame); // Start timer @@ -436,9 +438,9 @@ void VideoContext::OnPlayTimer(wxTimerEvent &) { } // Jump to next frame - playNextFrame = nextFrame; frame_n = nextFrame; - JumpToFrame(nextFrame); + GetFrameAsync(frame_n); + Seek(frame_n); // Sync audio if (keepAudioSync && nextFrame % 10 == 0 && context->audioController->IsPlaying()) { diff --git a/aegisub/src/video_context.h b/aegisub/src/video_context.h index eefcf7c24..478ad3ba9 100644 --- a/aegisub/src/video_context.h +++ b/aegisub/src/video_context.h @@ -104,9 +104,6 @@ class VideoContext : public wxEvtHandler { /// DOCME int endFrame; - /// DOCME - int playNextFrame; - /// DOCME int nextFrame; diff --git a/aegisub/src/video_slider.cpp b/aegisub/src/video_slider.cpp index b6abee3f4..84eebd738 100644 --- a/aegisub/src/video_slider.cpp +++ b/aegisub/src/video_slider.cpp @@ -113,9 +113,9 @@ BEGIN_EVENT_TABLE(VideoSlider, wxWindow) END_EVENT_TABLE() void VideoSlider::OnMouse(wxMouseEvent &event) { - int x = event.GetX(); + if (event.LeftIsDown()) { + int x = event.GetX(); - if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) { // If the slider didn't already have focus, don't seek if the user // clicked very close to the current location as they were probably // just trying to focus the slider @@ -125,7 +125,7 @@ void VideoSlider::OnMouse(wxMouseEvent &event) { } // Shift click to snap to keyframe - if (event.m_shiftDown) { + if (event.ShiftDown()) { int clickedFrame = GetValueAtX(x); std::vector::const_iterator pos = lower_bound(keyframes.begin(), keyframes.end(), clickedFrame); if (pos == keyframes.end()) @@ -144,23 +144,11 @@ void VideoSlider::OnMouse(wxMouseEvent &event) { SetValue(go); } - if (c->videoController->IsPlaying()) { - c->videoController->Stop(); - c->videoController->JumpToFrame(val); - c->videoController->Play(); - } - else - c->videoController->JumpToFrame(val); - SetFocus(); - return; - } - - if (event.ButtonDown(wxMOUSE_BTN_RIGHT) || event.ButtonDown(wxMOUSE_BTN_MIDDLE)) { + c->videoController->JumpToFrame(val); SetFocus(); } - - else if (!c->videoController->IsPlaying()) - event.Skip(); + else if (event.ButtonDown()) + SetFocus(); } void VideoSlider::OnKeyDown(wxKeyEvent &event) {