/
main.go
45 lines (36 loc) · 839 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package main
import (
"fmt"
"log"
"os"
"time"
tea "github.com/charmbracelet/bubbletea"
"github.com/faiface/beep"
"github.com/faiface/beep/speaker"
tui "github.com/ish-u/ytm_tui/tui"
)
func main() {
path := "./audio"
// Make audio dirtectory if doesn't exists
if _, err := os.Stat(path); os.IsNotExist(err) {
err := os.Mkdir(path, 0700)
// TODO: handle error
if err != nil {
log.Fatal("./audio does not exists")
return
}
}
// Initial Sample Rate
sr := beep.SampleRate(44100)
speaker.Init(sr, sr.N(time.Second/10))
tui.Queue.Current = 0
tui.Queue.Loading = false
// A zero Queue is an empty Queue.
speaker.Play(&tui.Queue)
m := tui.InitialModel()
p := tea.NewProgram(m, tea.WithAltScreen())
if err := p.Start(); err != nil {
fmt.Printf("Alas, there's been an error: %v", err)
os.Exit(1)
}
}