From 4c0355ac4f1764c544fa9c1c5ca1b7b92b9896e4 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Sat, 21 Mar 2020 12:05:22 +0000 Subject: [PATCH] HAXXX: Make videos skippable --- internal/wh40k/videos.go | 15 +++++++-------- internal/wh40k/wh40k.go | 3 ++- skippable.mpv.conf | 3 +++ 3 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 skippable.mpv.conf diff --git a/internal/wh40k/videos.go b/internal/wh40k/videos.go index 0cd9e0b..c861bcd 100644 --- a/internal/wh40k/videos.go +++ b/internal/wh40k/videos.go @@ -6,13 +6,6 @@ import ( ) func (w *WH40K) PlayVideo(name string, skippable bool) { - // TODO: allow the video to be skipped by pressing the ESC key or so. For - // now, skip unconditionally - if skippable { - log.Printf("TODO: Make videos conditionally skippable") - return - } - filename := w.Config.DataFile("SMK/" + name + ".smk") if len(w.Config.VideoPlayer) == 0 { @@ -21,7 +14,13 @@ func (w *WH40K) PlayVideo(name string, skippable bool) { } argc := w.Config.VideoPlayer[0] - argv := append(w.Config.VideoPlayer[1:], filename) + argv := append(w.Config.VideoPlayer[1:]) + if skippable { + argv = append(argv, "--input-conf=skippable.mpv.conf") + } + + argv = append(argv, filename) + if err := exec.Command(argc, argv...).Run(); err != nil { log.Printf("Error playing video %v: %v", filename, err) } diff --git a/internal/wh40k/wh40k.go b/internal/wh40k/wh40k.go index d8cf474..08a75e5 100644 --- a/internal/wh40k/wh40k.go +++ b/internal/wh40k/wh40k.go @@ -24,7 +24,8 @@ func Run(configFile string) error { Config: cfg, } - wh40k.PlayUnskippableVideo("LOGOS") + wh40k.PlaySkippableVideo("LOGOS") + wh40k.PlaySkippableVideo("movie1") return nil } diff --git a/skippable.mpv.conf b/skippable.mpv.conf new file mode 100644 index 0000000..c8a55be --- /dev/null +++ b/skippable.mpv.conf @@ -0,0 +1,3 @@ +SPACE quit +ESC quit +q quit