37 lines
839 B
Go
37 lines
839 B
Go
|
package wh40k
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"os/exec"
|
||
|
)
|
||
|
|
||
|
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 {
|
||
|
log.Printf("Video player not configured, skipping video %v", filename)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
argc := w.Config.VideoPlayer[0]
|
||
|
argv := append(w.Config.VideoPlayer[1:], filename)
|
||
|
if err := exec.Command(argc, argv...).Run(); err != nil {
|
||
|
log.Printf("Error playing video %v: %v", filename, err)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (w *WH40K) PlayUnskippableVideo(name string) {
|
||
|
w.PlayVideo(name, false)
|
||
|
}
|
||
|
|
||
|
func (w *WH40K) PlaySkippableVideo(name string) {
|
||
|
w.PlayVideo(name, true)
|
||
|
}
|