Add FFplay support to the application

Integrated FFplay functionality across the application. This includes support for setting up the FFplay path and invoking FFplay for media playback.
This commit is contained in:
2025-05-19 22:49:09 +05:00
parent a831d56d93
commit 306383449a
17 changed files with 244 additions and 24 deletions

View File

@@ -16,6 +16,7 @@ type ConvertorHandlerContract interface {
FfPathSelection()
GetFfmpegVersion() (string, error)
GetFfprobeVersion() (string, error)
GetFfplayVersion() (string, error)
}
type ConvertorHandler struct {
@@ -53,13 +54,14 @@ func (h ConvertorHandler) MainConvertor() {
h.convertorView.Main(conversion)
return
}
h.convertorView.SelectFFPath("", "", h.saveSettingFFPath, nil, h.downloadFFmpeg)
h.convertorView.SelectFFPath("", "", "", h.saveSettingFFPath, nil, h.downloadFFmpeg)
}
func (h ConvertorHandler) FfPathSelection() {
ffmpeg, _ := h.convertorRepository.GetPathFfmpeg()
ffprobe, _ := h.convertorRepository.GetPathFfprobe()
h.convertorView.SelectFFPath(ffmpeg, ffprobe, h.saveSettingFFPath, h.MainConvertor, h.downloadFFmpeg)
ffplay, _ := h.convertorRepository.GetPathFfplay()
h.convertorView.SelectFFPath(ffmpeg, ffprobe, ffplay, h.saveSettingFFPath, h.MainConvertor, h.downloadFFmpeg)
}
func (h ConvertorHandler) GetFfmpegVersion() (string, error) {
@@ -70,6 +72,10 @@ func (h ConvertorHandler) GetFfprobeVersion() (string, error) {
return h.app.GetConvertorService().GetFFprobeVersion()
}
func (h ConvertorHandler) GetFfplayVersion() (string, error) {
return h.app.GetConvertorService().GetFFplayVersion()
}
func (h ConvertorHandler) runConvert(setting view.HandleConvertSetting) {
h.app.GetQueue().Add(&kernel.ConvertSetting{
VideoFileInput: setting.FileInput,
@@ -98,15 +104,21 @@ func (h ConvertorHandler) checkingFFPathUtilities() bool {
if ffprobeChecking == false {
continue
}
ffplayChecking, _ := h.app.GetConvertorService().ChangeFFplayPath(item.FFplay)
if ffplayChecking == false {
continue
}
_, _ = h.convertorRepository.SavePathFfmpeg(item.FFmpeg)
_, _ = h.convertorRepository.SavePathFfprobe(item.FFprobe)
_, _ = h.convertorRepository.SavePathFfplay(item.FFplay)
return true
}
return false
}
func (h ConvertorHandler) saveSettingFFPath(ffmpegPath string, ffprobePath string) error {
func (h ConvertorHandler) saveSettingFFPath(ffmpegPath string, ffprobePath string, ffplayPath string) error {
ffmpegChecking, _ := h.app.GetConvertorService().ChangeFFmpegPath(ffmpegPath)
if ffmpegChecking == false {
errorText := h.app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{
@@ -123,8 +135,17 @@ func (h ConvertorHandler) saveSettingFFPath(ffmpegPath string, ffprobePath strin
return errors.New(errorText)
}
ffplayChecking, _ := h.app.GetConvertorService().ChangeFFplayPath(ffplayPath)
if ffplayChecking == false {
errorText := h.app.GetLocalizerService().GetMessage(&i18n.LocalizeConfig{
MessageID: "errorFFplay",
})
return errors.New(errorText)
}
_, _ = h.convertorRepository.SavePathFfmpeg(ffmpegPath)
_, _ = h.convertorRepository.SavePathFfprobe(ffprobePath)
_, _ = h.convertorRepository.SavePathFfplay(ffplayPath)
h.MainConvertor()
@@ -142,5 +163,10 @@ func (h ConvertorHandler) checkingFFPath() bool {
return false
}
_, err = h.app.GetConvertorService().GetFFplayVersion()
if err != nil {
return false
}
return true
}