diff --git a/aegisub/src/command/video.cpp b/aegisub/src/command/video.cpp index 08cdf1cd7..5d32a3b17 100644 --- a/aegisub/src/command/video.cpp +++ b/aegisub/src/command/video.cpp @@ -250,7 +250,7 @@ struct video_frame_next : public Command { STR_HELP("Seek to the next frame.") void operator()(agi::Context *c) { - c->videoBox->videoSlider->NextFrame(); + c->videoContext->NextFrame(); } }; @@ -276,7 +276,7 @@ struct video_frame_prev : public Command { STR_HELP("Seek to the previous frame.") void operator()(agi::Context *c) { - c->videoBox->videoSlider->PrevFrame(); + c->videoContext->PrevFrame(); } }; diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index 368bd6295..4c5799bba 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -303,31 +303,29 @@ void VideoContext::GetScriptSize(int &sw,int &sh) { grid->ass->GetResolution(sw,sh); } -void VideoContext::PlayNextFrame() { - if (isPlaying) +void VideoContext::NextFrame() { + if (!videoProvider.get() || isPlaying || frame_n == videoProvider->GetFrameCount()) return; - int thisFrame = frame_n; JumpToFrame(frame_n + 1); // Start playing audio if (playAudioOnStep->GetBool()) { audio->PlayRange(SampleRange( - audio->SamplesFromMilliseconds(TimeAtFrame(thisFrame)), - audio->SamplesFromMilliseconds(TimeAtFrame(thisFrame + 1)))); + audio->SamplesFromMilliseconds(TimeAtFrame(frame_n - 1)), + audio->SamplesFromMilliseconds(TimeAtFrame(frame_n)))); } } -void VideoContext::PlayPrevFrame() { - if (isPlaying) +void VideoContext::PrevFrame() { + if (!videoProvider.get() || isPlaying || frame_n == 0) return; - int thisFrame = frame_n; - JumpToFrame(frame_n -1); + JumpToFrame(frame_n - 1); // Start playing audio if (playAudioOnStep->GetBool()) { audio->PlayRange(SampleRange( - audio->SamplesFromMilliseconds(TimeAtFrame(thisFrame - 1)), - audio->SamplesFromMilliseconds(TimeAtFrame(thisFrame)))); + audio->SamplesFromMilliseconds(TimeAtFrame(frame_n)), + audio->SamplesFromMilliseconds(TimeAtFrame(frame_n + 1)))); } } diff --git a/aegisub/src/video_context.h b/aegisub/src/video_context.h index 7da07d7b4..f86fb5f54 100644 --- a/aegisub/src/video_context.h +++ b/aegisub/src/video_context.h @@ -246,9 +246,9 @@ public: /// Starting playing the video void Play(); /// Play the next frame then stop - void PlayNextFrame(); + void NextFrame(); /// Play the previous frame then stop - void PlayPrevFrame(); + void PrevFrame(); /// Seek to the beginning of the current line, then play to the end of it void PlayLine(); /// Stop playing diff --git a/aegisub/src/video_slider.cpp b/aegisub/src/video_slider.cpp index 6828af349..81dc01454 100644 --- a/aegisub/src/video_slider.cpp +++ b/aegisub/src/video_slider.cpp @@ -138,34 +138,6 @@ int VideoSlider::GetXAtValue(int value) { return (int64_t)value*(int64_t)(w-10)/(int64_t)max+5; } - - -/// @brief Next frame hotkey -/// @return -/// -void VideoSlider::NextFrame() { - if (VideoContext::Get()->IsPlaying()) return; - - //don't request out of range frames - if (val < max) VideoContext::Get()->PlayNextFrame(); - Refresh(false); - Update(); -} - - - -/// @brief Previous frame hotkey -/// @return -/// -void VideoSlider::PrevFrame() { - if (VideoContext::Get()->IsPlaying()) return; - - //don't request out of range frames - if (val > 0) VideoContext::Get()->PlayPrevFrame(); - Refresh(false); - Update(); -} - BEGIN_EVENT_TABLE(VideoSlider, wxWindow) EVT_MOUSE_EVENTS(VideoSlider::OnMouse) EVT_KEY_DOWN(VideoSlider::OnKeyDown) @@ -276,8 +248,8 @@ void VideoSlider::OnKeyDown(wxKeyEvent &event) { if (direction) { // Standard move if (!ctrl && !shift && !alt) { - if (direction == 1) NextFrame(); - else PrevFrame(); + if (direction == 1) VideoContext::Get()->NextFrame(); + else VideoContext::Get()->PrevFrame(); return; } diff --git a/aegisub/src/video_slider.h b/aegisub/src/video_slider.h index ec9f0545d..10c46a4a8 100644 --- a/aegisub/src/video_slider.h +++ b/aegisub/src/video_slider.h @@ -83,8 +83,5 @@ public: VideoSlider(wxWindow* parent, wxWindowID id); ~VideoSlider(); - void NextFrame(); - void PrevFrame(); - DECLARE_EVENT_TABLE() };