Move NextFrame and PrevFrame from VideoSlider to VideoContext

Originally committed to SVN as r5200.
This commit is contained in:
Thomas Goyne 2011-01-16 07:15:53 +00:00
parent 08ec92046f
commit 64ebce6c0f
5 changed files with 15 additions and 48 deletions

View File

@ -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();
}
};

View File

@ -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))));
}
}

View File

@ -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

View File

@ -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;
}

View File

@ -83,8 +83,5 @@ public:
VideoSlider(wxWindow* parent, wxWindowID id);
~VideoSlider();
void NextFrame();
void PrevFrame();
DECLARE_EVENT_TABLE()
};