From 3a58a48e1aa97105f77cbd4588d70cd2c8e8dfad Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Wed, 17 Feb 2010 19:04:41 +0000 Subject: [PATCH] Move the logic to play the audio on stepping through video into video_context so that the VideoSlider's Next/PrevFrame can behave consistently regardless of where they're called from. Originally committed to SVN as r4121. --- aegisub/src/video_context.cpp | 31 +++++++++++++++++++++++++++++++ aegisub/src/video_context.h | 2 ++ aegisub/src/video_slider.cpp | 4 ++-- 3 files changed, 35 insertions(+), 2 deletions(-) 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(); }