Версия 1.0.0 #11
@ -5,11 +5,13 @@ import (
|
||||
"fyne.io/fyne/v2/lang"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type FFplayContract interface {
|
||||
GetPath() string
|
||||
GetVersion() (string, error)
|
||||
Play(file *File) error
|
||||
}
|
||||
|
||||
@ -39,6 +41,17 @@ func (f *ffplay) GetPath() string {
|
||||
return f.path
|
||||
}
|
||||
|
||||
func (f *ffplay) GetVersion() (string, error) {
|
||||
cmd := exec.Command(f.path, "-version")
|
||||
utils.PrepareBackgroundCommand(cmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
text := regexp.MustCompile("\r?\n").Split(strings.TrimSpace(string(out)), -1)
|
||||
return text[0], nil
|
||||
}
|
||||
|
||||
func (f *ffplay) Play(file *File) error {
|
||||
args := []string{file.Path}
|
||||
cmd := exec.Command(f.GetPath(), args...)
|
||||
|
@ -34,6 +34,7 @@ type UtilitiesContract interface {
|
||||
ChangeFFprobe(path string) error
|
||||
|
||||
GetFFplay() (FFplayContract, error)
|
||||
GetFFplayVersion() string
|
||||
GetFFplayPath() string
|
||||
ChangeFFplay(path string) error
|
||||
}
|
||||
@ -182,6 +183,19 @@ func (u *utilities) GetFFplay() (FFplayContract, error) {
|
||||
return u.ffplay, nil
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFplayVersion() string {
|
||||
ffplayService, err := u.GetFFplay()
|
||||
if err != nil {
|
||||
return lang.L("errorFFplayVersion")
|
||||
}
|
||||
|
||||
ffplayVersion, err := ffplayService.GetVersion()
|
||||
if err != nil {
|
||||
return lang.L("errorFFplayVersion")
|
||||
}
|
||||
return ffplayVersion
|
||||
}
|
||||
|
||||
func (u *utilities) GetFFplayPath() string {
|
||||
ffplayService, err := u.GetFFplay()
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user