Add GetFFplayVersion
method to retrieve FFplay version details
Extended `FFplayContract` with `GetVersion` to fetch FFplay version. Implemented version extraction in `utilities` and `ffplay` to support version retrieval functionality.
This commit is contained in:
parent
d7428683e4
commit
e6db590937
@ -5,11 +5,13 @@ import (
|
|||||||
"fyne.io/fyne/v2/lang"
|
"fyne.io/fyne/v2/lang"
|
||||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/utils"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FFplayContract interface {
|
type FFplayContract interface {
|
||||||
GetPath() string
|
GetPath() string
|
||||||
|
GetVersion() (string, error)
|
||||||
Play(file *File) error
|
Play(file *File) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,6 +41,17 @@ func (f *ffplay) GetPath() string {
|
|||||||
return f.path
|
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 {
|
func (f *ffplay) Play(file *File) error {
|
||||||
args := []string{file.Path}
|
args := []string{file.Path}
|
||||||
cmd := exec.Command(f.GetPath(), args...)
|
cmd := exec.Command(f.GetPath(), args...)
|
||||||
|
@ -34,6 +34,7 @@ type UtilitiesContract interface {
|
|||||||
ChangeFFprobe(path string) error
|
ChangeFFprobe(path string) error
|
||||||
|
|
||||||
GetFFplay() (FFplayContract, error)
|
GetFFplay() (FFplayContract, error)
|
||||||
|
GetFFplayVersion() string
|
||||||
GetFFplayPath() string
|
GetFFplayPath() string
|
||||||
ChangeFFplay(path string) error
|
ChangeFFplay(path string) error
|
||||||
}
|
}
|
||||||
@ -182,6 +183,19 @@ func (u *utilities) GetFFplay() (FFplayContract, error) {
|
|||||||
return u.ffplay, nil
|
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 {
|
func (u *utilities) GetFFplayPath() string {
|
||||||
ffplayService, err := u.GetFFplay()
|
ffplayService, err := u.GetFFplay()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user