package ffmpeg import ( "errors" "fyne.io/fyne/v2/lang" "git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils" "os/exec" "strings" ) type FFplayContract interface { GetPath() string } type ffplay struct { path string } func newFFplay(path string) (FFplayContract, error) { if path == "" { return nil, errors.New(lang.L("errorFFplay")) } isCheck, err := checkFFplayPath(path) if err != nil { return nil, err } if isCheck == false { return nil, errors.New(lang.L("errorFFplay")) } return &ffplay{ path: path, }, nil } func (f *ffplay) GetPath() string { return f.path } func checkFFplayPath(path string) (bool, error) { cmd := exec.Command(path, "-version") utils.PrepareBackgroundCommand(cmd) out, err := cmd.CombinedOutput() if err != nil { return false, err } if strings.Contains(strings.TrimSpace(string(out)), "ffplay") == false { return false, nil } return true, nil }