Add FFmpeg utilities configuration UI and automated downloading
Introduce a new UI for configuring FFmpeg, FFprobe, and FFplay paths with file selection and error handling. Add platform-specific logic for downloading and extracting FFmpeg binaries directly within the application, improving user experience.
This commit is contained in:
@@ -1,8 +1,58 @@
|
||||
package controller
|
||||
|
||||
import "git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/view"
|
||||
import (
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg/download/service"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/gui/view"
|
||||
)
|
||||
|
||||
func (c *controller) convertor() {
|
||||
content := view.Convertor()
|
||||
c.window.SetContent(content)
|
||||
}
|
||||
|
||||
func (c *controller) settingConvertor(isAllowCancellation bool) {
|
||||
ffmpegPath := c.app.GetFFmpegService().GetFFmpegPath()
|
||||
ffprobePath := c.app.GetFFmpegService().GetFFprobePath()
|
||||
ffplayPath := c.app.GetFFmpegService().GetFFplayPath()
|
||||
|
||||
var cancel func()
|
||||
cancel = nil
|
||||
if isAllowCancellation {
|
||||
cancel = func() {
|
||||
c.convertor()
|
||||
}
|
||||
}
|
||||
|
||||
content := view.ConfiguringFFmpegUtilities(
|
||||
c.window,
|
||||
ffmpegPath,
|
||||
ffprobePath,
|
||||
ffplayPath,
|
||||
c.saveSettingConvertor,
|
||||
cancel,
|
||||
service.DownloadFFmpeg(c.app, c.saveSettingConvertor),
|
||||
)
|
||||
c.window.SetContent(content)
|
||||
}
|
||||
|
||||
func (c *controller) saveSettingConvertor(ffmpegPath string, ffprobePath string, ffplayPath string) error {
|
||||
var err error
|
||||
|
||||
err = c.app.GetFFmpegService().ChangeFFmpeg(ffmpegPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.app.GetFFmpegService().ChangeFFprobe(ffprobePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.app.GetFFmpegService().ChangeFFplay(ffplayPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.convertor()
|
||||
return nil
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ type ControllerContract interface {
|
||||
|
||||
type controller struct {
|
||||
app application.AppContract
|
||||
window window.MainWindowContract
|
||||
window window.WindowContract
|
||||
}
|
||||
|
||||
func NewController(app application.AppContract) ControllerContract {
|
||||
@@ -26,11 +26,10 @@ func NewController(app application.AppContract) ControllerContract {
|
||||
}
|
||||
|
||||
func (c *controller) Start() {
|
||||
c.window.Show()
|
||||
|
||||
isDefault, err := c.initLanguage()
|
||||
if err != nil {
|
||||
c.startWithError(err)
|
||||
c.window.Show()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -46,14 +45,21 @@ func (c *controller) Start() {
|
||||
c.verificareaFFmpeg()
|
||||
})
|
||||
c.window.SetContent(content)
|
||||
c.window.Show()
|
||||
return
|
||||
}
|
||||
|
||||
c.window.InitLayout()
|
||||
c.verificareaFFmpeg()
|
||||
c.window.Show()
|
||||
}
|
||||
|
||||
func (c *controller) verificareaFFmpeg() {
|
||||
if !c.app.GetFFmpegService().UtilityCheck() {
|
||||
c.settingConvertor(false)
|
||||
return
|
||||
}
|
||||
|
||||
c.convertor()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user