mirror of https://github.com/odrling/Aegisub
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.
This commit is contained in:
parent
f95f1f13cf
commit
8ab9ba77ae
|
@ -74,7 +74,6 @@ VideoContext::VideoContext()
|
||||||
: playback(this)
|
: playback(this)
|
||||||
, startMS(0)
|
, startMS(0)
|
||||||
, endFrame(0)
|
, endFrame(0)
|
||||||
, playNextFrame(-1)
|
|
||||||
, nextFrame(-1)
|
, nextFrame(-1)
|
||||||
, keepAudioSync(true)
|
, keepAudioSync(true)
|
||||||
, frame_n(0)
|
, frame_n(0)
|
||||||
|
@ -271,13 +270,17 @@ void VideoContext::OnSubtitlesSave() {
|
||||||
void VideoContext::JumpToFrame(int n) {
|
void VideoContext::JumpToFrame(int n) {
|
||||||
if (!IsLoaded()) return;
|
if (!IsLoaded()) return;
|
||||||
|
|
||||||
// Prevent intervention during playback
|
bool was_playing = IsPlaying();
|
||||||
if (IsPlaying() && n != playNextFrame) return;
|
if (was_playing)
|
||||||
|
Stop();
|
||||||
|
|
||||||
frame_n = mid(0, n, GetLength() - 1);
|
frame_n = mid(0, n, GetLength() - 1);
|
||||||
|
|
||||||
GetFrameAsync(frame_n);
|
GetFrameAsync(frame_n);
|
||||||
Seek(frame_n);
|
Seek(frame_n);
|
||||||
|
|
||||||
|
if (was_playing)
|
||||||
|
Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoContext::JumpToTime(int ms, agi::vfr::Time end) {
|
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;
|
endFrame = FrameAtTime(context->selectionController->GetActiveLine()->End.GetMS(),agi::vfr::END) + 1;
|
||||||
|
|
||||||
// Jump to start
|
// Jump to start
|
||||||
playNextFrame = startFrame;
|
|
||||||
JumpToFrame(startFrame);
|
JumpToFrame(startFrame);
|
||||||
|
|
||||||
// Start timer
|
// Start timer
|
||||||
|
@ -436,9 +438,9 @@ void VideoContext::OnPlayTimer(wxTimerEvent &) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jump to next frame
|
// Jump to next frame
|
||||||
playNextFrame = nextFrame;
|
|
||||||
frame_n = nextFrame;
|
frame_n = nextFrame;
|
||||||
JumpToFrame(nextFrame);
|
GetFrameAsync(frame_n);
|
||||||
|
Seek(frame_n);
|
||||||
|
|
||||||
// Sync audio
|
// Sync audio
|
||||||
if (keepAudioSync && nextFrame % 10 == 0 && context->audioController->IsPlaying()) {
|
if (keepAudioSync && nextFrame % 10 == 0 && context->audioController->IsPlaying()) {
|
||||||
|
|
|
@ -104,9 +104,6 @@ class VideoContext : public wxEvtHandler {
|
||||||
/// DOCME
|
/// DOCME
|
||||||
int endFrame;
|
int endFrame;
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
int playNextFrame;
|
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
int nextFrame;
|
int nextFrame;
|
||||||
|
|
||||||
|
|
|
@ -113,9 +113,9 @@ BEGIN_EVENT_TABLE(VideoSlider, wxWindow)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
void VideoSlider::OnMouse(wxMouseEvent &event) {
|
void VideoSlider::OnMouse(wxMouseEvent &event) {
|
||||||
|
if (event.LeftIsDown()) {
|
||||||
int x = event.GetX();
|
int x = event.GetX();
|
||||||
|
|
||||||
if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
|
|
||||||
// If the slider didn't already have focus, don't seek if the user
|
// 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
|
// clicked very close to the current location as they were probably
|
||||||
// just trying to focus the slider
|
// just trying to focus the slider
|
||||||
|
@ -125,7 +125,7 @@ void VideoSlider::OnMouse(wxMouseEvent &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shift click to snap to keyframe
|
// Shift click to snap to keyframe
|
||||||
if (event.m_shiftDown) {
|
if (event.ShiftDown()) {
|
||||||
int clickedFrame = GetValueAtX(x);
|
int clickedFrame = GetValueAtX(x);
|
||||||
std::vector<int>::const_iterator pos = lower_bound(keyframes.begin(), keyframes.end(), clickedFrame);
|
std::vector<int>::const_iterator pos = lower_bound(keyframes.begin(), keyframes.end(), clickedFrame);
|
||||||
if (pos == keyframes.end())
|
if (pos == keyframes.end())
|
||||||
|
@ -144,23 +144,11 @@ void VideoSlider::OnMouse(wxMouseEvent &event) {
|
||||||
SetValue(go);
|
SetValue(go);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->videoController->IsPlaying()) {
|
|
||||||
c->videoController->Stop();
|
|
||||||
c->videoController->JumpToFrame(val);
|
|
||||||
c->videoController->Play();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
c->videoController->JumpToFrame(val);
|
c->videoController->JumpToFrame(val);
|
||||||
SetFocus();
|
SetFocus();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else if (event.ButtonDown())
|
||||||
if (event.ButtonDown(wxMOUSE_BTN_RIGHT) || event.ButtonDown(wxMOUSE_BTN_MIDDLE)) {
|
|
||||||
SetFocus();
|
SetFocus();
|
||||||
}
|
|
||||||
|
|
||||||
else if (!c->videoController->IsPlaying())
|
|
||||||
event.Skip();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoSlider::OnKeyDown(wxKeyEvent &event) {
|
void VideoSlider::OnKeyDown(wxKeyEvent &event) {
|
||||||
|
|
Loading…
Reference in New Issue