strip-beats/app/run.go
2023-09-08 11:00:07 -05:00

71 lines
1.3 KiB
Go

package app
import (
"fmt"
"os"
"codeberg.org/danjones000/strip-beats/input/boolean"
"codeberg.org/danjones000/strip-beats/media"
)
type AppStep int
const (
Pick AppStep = iota
Watch
Fade
Restart
Quit
)
func quit() {
PickAgain()
fmt.Println("Goodbye!")
os.Exit(0)
}
func testTrim() {
path := "/home/drj/MyFiles/Videos/WebShows/YouTube/Savannah_Outen/Love_Me_Like_You_Do_-_Ellie_Goulding_Cover_by_Savannah_Outen-tPYfBpRxXfI.mp4"
file := SetFile(path)
tmp, _ := os.CreateTemp("", "audio.*.mka")
tmp.Close()
// err := media.TrimWithFade(file, tmp.Name(), 0, 215.84, 0, 3)
// err := media.Trim(file, tmp.Name(), 0, 215.84)
err := media.TrimWithFade(file, tmp.Name(), 15.2, 70.84, 3.6, 8.4)
if err != nil {
panic(err)
}
fmt.Println(tmp.Name())
quit()
}
func Run(step AppStep) {
for step < Quit {
switch step {
case Pick:
PickAgain()
PickFileWithConf()
if file == nil {
quit()
}
watch := boolean.Choose(fmt.Sprintf("Would you like to watch %s?", file.ShortPath()))
if watch {
step = Watch
} else {
step = mainMenu()
}
case Watch:
media.Watch(file.Format.Path)
fade := boolean.Choose(fmt.Sprintf("Would you like to trim/fade %s?", file.ShortPath()))
if fade {
step = Fade
} else {
step = mainMenu()
}
case Quit:
quit()
default:
step = mainMen()
}
}
}