-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
82 lines (73 loc) · 1.23 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"runtime"
"github.com/jackmordaunt/player/play"
"github.com/murlokswarm/app"
"github.com/murlokswarm/app/drivers/mac"
)
var (
playlist *play.Playlist
)
func main() {
log.Println(os.Args)
runtime.GOMAXPROCS(1)
if len(os.Args) < 2 {
return
}
var files []string
for _, path := range os.Args[1:] {
fi, err := os.Stat(path)
if err != nil {
panic(err)
}
if fi.IsDir() {
entries, err := ioutil.ReadDir(path)
if err != nil {
panic(err)
}
for _, e := range entries {
if e.IsDir() {
continue
}
files = append(files, filepath.Join(path, e.Name()))
}
} else {
files = append(files, path)
}
}
playlist = play.New(files)
if err := app.Run(&mac.Driver{
OnRun: func() {
newMainWindow()
},
OnReopen: func(visible bool) {
if !visible {
newMainWindow()
}
},
}); err != nil {
fmt.Printf("[app] %v\n", err)
os.Exit(1)
}
}
func newMainWindow() {
app.NewWindow(app.WindowConfig{
Title: "Player",
Width: 400,
Height: 400,
Mac: app.MacWindowConfig{
BackgroundVibrancy: app.VibeDark,
},
DefaultURL: "/Player",
OnClose: func() bool {
playlist.Done()
os.Exit(0)
return true
},
})
}