diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index 4e1ede5e1..0674e5a2f 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -468,6 +468,34 @@ void VideoContext::GetScriptSize(int &sw,int &sh) { grid->ass->GetResolution(sw,sh); } +/// @brief Play the next frame, possibly with audio +/// @return +/// +void VideoContext::PlayNextFrame() { + if (isPlaying) + return; + + int thisFrame = frame_n; + JumpToFrame(frame_n + 1); + // Start playing audio + if (Options.AsBool(_T("Audio Plays When Stepping Video"))) + audio->Play(VFR_Output.GetTimeAtFrame(thisFrame),VFR_Output.GetTimeAtFrame(thisFrame + 1)); +} + +/// @brief Play the previous frame, possibly with audio +/// @return +/// +void VideoContext::PlayPrevFrame() { + if (isPlaying) + return; + + int thisFrame = frame_n; + JumpToFrame(frame_n -1); + // Start playing audio + if (Options.AsBool(_T("Audio Plays When Stepping Video"))) + audio->Play(VFR_Output.GetTimeAtFrame(thisFrame - 1),VFR_Output.GetTimeAtFrame(thisFrame)); +} + /// @brief Play /// @return /// @@ -494,6 +522,9 @@ void VideoContext::Play() { playback.Start(10); } + + + /// @brief Play line /// @return /// diff --git a/aegisub/src/video_context.h b/aegisub/src/video_context.h index c55f5711c..6491a0899 100644 --- a/aegisub/src/video_context.h +++ b/aegisub/src/video_context.h @@ -271,6 +271,8 @@ public: wxString GetTempWorkFile (); void Play(); + void PlayNextFrame(); + void PlayPrevFrame(); void PlayLine(); void Stop(); diff --git a/aegisub/src/video_slider.cpp b/aegisub/src/video_slider.cpp index f175d4da2..5983fb11d 100644 --- a/aegisub/src/video_slider.cpp +++ b/aegisub/src/video_slider.cpp @@ -154,7 +154,7 @@ void VideoSlider::NextFrame() { if (VideoContext::Get()->IsPlaying()) return; //don't request out of range frames - if (GetValue() < max) VideoContext::Get()->JumpToFrame(GetValue()+1); + if (GetValue() < max) VideoContext::Get()->PlayNextFrame(); Refresh(false); Update(); } @@ -168,7 +168,7 @@ void VideoSlider::PrevFrame() { if (VideoContext::Get()->IsPlaying()) return; //don't request out of range frames - if (GetValue() > min) VideoContext::Get()->JumpToFrame(GetValue()-1); + if (GetValue() > min) VideoContext::Get()->PlayPrevFrame(); Refresh(false); Update(); }