Leonid Nikitin 9bb835beaf
Make a choice of the encoder in the form
Made a choice of the encoder by categories: video, audio and photo.
2025-06-08 17:26:49 +05:00

81 lines
1.8 KiB
Go

package controller
import (
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/ffmpeg"
"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() {
formats, err := c.app.GetConvertorService().GetSupportFormats()
if err != nil {
c.startWithError(err)
return
}
content := view.Convertor(
c.window,
c.addFileForConversion,
c.app.GetSetting().GetDirectoryForSaving(),
c.setDirectoryForSaving,
formats,
)
c.window.SetContent(content)
}
func (c *controller) addFileForConversion(file ffmpeg.File) {
c.app.GetItemsToConvert().Add(&file)
c.window.GetLayout().GetRContainer().SelectAddedFilesTab()
}
func (c *controller) setDirectoryForSaving(path string) {
c.app.GetSetting().SetDirectoryForSaving(path)
}
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
}