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.
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package controller
|
|
|
|
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
|
|
}
|