From c7c874acc4695a652f623bc4bf3b0bea3e8d8d44 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Tue, 23 Aug 2022 19:53:40 +0200 Subject: [PATCH] Add commands to reload audio or video This is mostly useful for reloading Avisyth or VapourSynth scripts. --- src/command/audio.cpp | 12 ++++++++++++ src/command/video.cpp | 12 ++++++++++++ src/project.h | 4 ++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/command/audio.cpp b/src/command/audio.cpp index 386866775..4b7b72395 100644 --- a/src/command/audio.cpp +++ b/src/command/audio.cpp @@ -128,6 +128,17 @@ struct audio_open_video final : public Command { } }; +struct audio_reload final : public Command { + CMD_NAME("audio/reload") + STR_MENU("Reload Audio") + STR_DISP("Reload Audio") + STR_HELP("Reload the current audio file") + + void operator()(agi::Context *c) override { + c->project->ReloadAudio(); + } +}; + struct audio_view_spectrum final : public Command { CMD_NAME("audio/view/spectrum") STR_MENU("&Spectrum Display") @@ -549,6 +560,7 @@ namespace cmd { reg(agi::make_unique()); reg(agi::make_unique()); reg(agi::make_unique()); + reg(agi::make_unique()); reg(agi::make_unique()); reg(agi::make_unique()); reg(agi::make_unique()); diff --git a/src/command/video.cpp b/src/command/video.cpp index 1a779a52b..bb0444c1b 100644 --- a/src/command/video.cpp +++ b/src/command/video.cpp @@ -612,6 +612,17 @@ struct video_open_dummy final : public Command { } }; +struct video_reload final : public Command { + CMD_NAME("video/reload") + STR_MENU("Reload Video") + STR_DISP("Reload Video") + STR_HELP("Reload the current video file") + + void operator()(agi::Context *c) override { + c->project->ReloadVideo(); + } +}; + struct video_opt_autoscroll final : public Command { CMD_NAME("video/opt/autoscroll") CMD_ICON(toggle_video_autoscroll) @@ -794,6 +805,7 @@ namespace cmd { reg(agi::make_unique()); reg(agi::make_unique()); reg(agi::make_unique()); + reg(agi::make_unique()); reg(agi::make_unique()); reg(agi::make_unique()); reg(agi::make_unique()); diff --git a/src/project.h b/src/project.h index 385a41b4b..090f99d3d 100644 --- a/src/project.h +++ b/src/project.h @@ -60,8 +60,6 @@ class Project { void LoadUnloadFiles(ProjectProperties properties); void UpdateRelativePaths(); - void ReloadAudio(); - void ReloadVideo(); void SetPath(agi::fs::path& var, const char *token, const char *mru, agi::fs::path const& value); @@ -74,11 +72,13 @@ public: bool CanLoadSubtitlesFromVideo() const { return video_has_subtitles; } void LoadAudio(agi::fs::path path); + void ReloadAudio(); void CloseAudio(); agi::AudioProvider *AudioProvider() const { return audio_provider.get(); } agi::fs::path const& AudioName() const { return audio_file; } void LoadVideo(agi::fs::path path); + void ReloadVideo(); void CloseVideo(); AsyncVideoProvider *VideoProvider() const { return video_provider.get(); } agi::fs::path const& VideoName() const { return video_file; }