Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions po/zh_CN.po
Original file line number Diff line number Diff line change
Expand Up @@ -2452,6 +2452,38 @@ msgstr "从该位置开始播放视频"
msgid "Play line"
msgstr "播放字幕行"

#: ../src/command/video.cpp:621
msgid "Play last 500ms"
msgstr "播放最后500毫秒"

#: ../src/command/video.cpp:622
msgid "Play last 500 milliseconds of current line"
msgstr "播放当前行的最后500毫秒"

#: ../src/command/video.cpp:630
msgid "Play first 500ms"
msgstr "播放开始500毫秒"

#: ../src/command/video.cpp:631
msgid "Play first 500 milliseconds of current line"
msgstr "播放当前行的开始500毫秒"

#: ../src/command/video.cpp:639
msgid "Play 500ms before"
msgstr "播放前500毫秒"

#: ../src/command/video.cpp:640
msgid "Play 500 milliseconds before current line"
msgstr "播放当前行之前500毫秒"

#: ../src/command/video.cpp:648
msgid "Play 500ms after"
msgstr "播放后500毫秒"

#: ../src/command/video.cpp:649
msgid "Play 500 milliseconds after current line"
msgstr "播放当前行之后500毫秒"

#: ../src/command/video.cpp:656
msgid "Show &Overscan Mask"
msgstr "显示过扫描遮罩(&O)"
Expand Down
52 changes: 52 additions & 0 deletions src/command/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,54 @@ struct video_play_line final : public validator_video_loaded {
}
};

struct video_play_line_end final : public validator_video_loaded {
CMD_NAME("video/play/line/end")
CMD_ICON(button_playline)
STR_MENU("Play last 500ms")
STR_DISP("Play last 500ms")
STR_HELP("Play last 500 milliseconds of current line")

void operator()(agi::Context *c) override {
c->videoController->PlayLineEnd();
}
};

struct video_play_line_begin final : public validator_video_loaded {
CMD_NAME("video/play/line/begin")
CMD_ICON(button_playline)
STR_MENU("Play first 500ms")
STR_DISP("Play first 500ms")
STR_HELP("Play first 500 milliseconds of current line")

void operator()(agi::Context *c) override {
c->videoController->PlayLineBegin();
}
};

struct video_play_line_before final : public validator_video_loaded {
CMD_NAME("video/play/line/before")
CMD_ICON(button_playline)
STR_MENU("Play 500ms before")
STR_DISP("Play 500ms before")
STR_HELP("Play 500 milliseconds before current line")

void operator()(agi::Context *c) override {
c->videoController->PlayLineBefore();
}
};

struct video_play_line_after final : public validator_video_loaded {
CMD_NAME("video/play/line/after")
CMD_ICON(button_playline)
STR_MENU("Play 500ms after")
STR_DISP("Play 500ms after")
STR_HELP("Play 500 milliseconds after current line")

void operator()(agi::Context *c) override {
c->videoController->PlayLineAfter();
}
};

struct video_show_overscan final : public validator_video_loaded {
CMD_NAME("video/show_overscan")
STR_MENU("Show &Overscan Mask")
Expand Down Expand Up @@ -795,6 +843,10 @@ namespace cmd {
reg(std::make_unique<video_opt_autoscroll>());
reg(std::make_unique<video_play>());
reg(std::make_unique<video_play_line>());
reg(std::make_unique<video_play_line_end>());
reg(std::make_unique<video_play_line_begin>());
reg(std::make_unique<video_play_line_before>());
reg(std::make_unique<video_play_line_after>());
reg(std::make_unique<video_show_overscan>());
reg(std::make_unique<video_stop>());
reg(std::make_unique<video_zoom_100>());
Expand Down
86 changes: 85 additions & 1 deletion src/video_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,90 @@ void VideoController::PlayLine() {
playback.Start(10);
}

void VideoController::PlayLineEnd() {
Stop();

AssDialogue *curline = context->selectionController->GetActiveLine();
if (!curline) return;

int end_time = curline->End;
int start_time = std::max(0, end_time - 500);

context->audioController->PlayRange(TimeRange(start_time, end_time));

int startFrame = FrameAtTime(start_time, agi::vfr::START);
start_ms = TimeAtFrame(startFrame);
end_frame = FrameAtTime(end_time, agi::vfr::END) + 1;

JumpToFrame(startFrame);

playback_start_time = std::chrono::steady_clock::now();
playback.Start(10);
}

void VideoController::PlayLineBegin() {
Stop();

AssDialogue *curline = context->selectionController->GetActiveLine();
if (!curline) return;

int start_time = curline->Start;
int end_time = std::min(static_cast<int>(curline->End), start_time + 500);

context->audioController->PlayRange(TimeRange(start_time, end_time));

int startFrame = FrameAtTime(start_time, agi::vfr::START);
start_ms = TimeAtFrame(startFrame);
end_frame = FrameAtTime(end_time, agi::vfr::END) + 1;

JumpToFrame(startFrame);

playback_start_time = std::chrono::steady_clock::now();
playback.Start(10);
}

void VideoController::PlayLineBefore() {
Stop();

AssDialogue *curline = context->selectionController->GetActiveLine();
if (!curline) return;

int end_time = curline->Start;
int start_time = std::max(0, end_time - 500);

context->audioController->PlayRange(TimeRange(start_time, end_time));

int startFrame = FrameAtTime(start_time, agi::vfr::START);
start_ms = TimeAtFrame(startFrame);
end_frame = FrameAtTime(end_time, agi::vfr::END) + 1;

JumpToFrame(startFrame);

playback_start_time = std::chrono::steady_clock::now();
playback.Start(10);
}

void VideoController::PlayLineAfter() {
Stop();

AssDialogue *curline = context->selectionController->GetActiveLine();
if (!curline) return;

int start_time = curline->End;
int end_time = start_time + 500;

context->audioController->PlayRange(TimeRange(start_time, end_time));

int startFrame = FrameAtTime(start_time, agi::vfr::START);
start_ms = TimeAtFrame(startFrame);
end_frame = FrameAtTime(end_time, agi::vfr::END) + 1;

JumpToFrame(startFrame);

playback_start_time = std::chrono::steady_clock::now();
playback.Start(10);
}

void VideoController::Stop() {
if (IsPlaying()) {
playback.Stop();
Expand Down Expand Up @@ -233,4 +317,4 @@ void VideoController::OnSubtitlesError(SubtitlesProviderErrorEvent const& err) {
wxLogError(
"Failed rendering subtitles. Error message reported: %s",
to_wx(err.GetMessage()));
}
}
8 changes: 8 additions & 0 deletions src/video_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ class VideoController final : public wxEvtHandler {
void NextFrame();
/// Play the previous frame then stop
void PrevFrame();
/// Play the last 500 milliseconds of the current line
void PlayLineEnd();
/// Play the first 500 milliseconds of the current line
void PlayLineBegin();
/// Play 500 milliseconds before the current line
void PlayLineBefore();
/// Play 500 milliseconds after the current line
void PlayLineAfter();
/// Seek to the beginning of the current line, then play to the end of it
void PlayLine();
/// Stop playing
Expand Down