-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (55 loc) · 1.05 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
package control
import (
"github.com/urfave/cli"
"github.com/robertgzr/xap/mp"
)
var Command = cli.Command{
Name: "control",
Aliases: []string{"c"},
Usage: "Control mpv via socket",
Subcommands: []cli.Command{
PlayCommand,
PauseCommand,
StopCommand,
volumeCommand,
from0Command,
seekCommand,
statusCommand,
},
}
var PlayCommand = cli.Command{
Name: "play",
Category: "CONTROL",
Usage: "Start to play the current file",
Action: func(ctx *cli.Context) error {
c, err := mp.Connect(ctx)
if err != nil {
return err
}
return c.Play()
},
}
var PauseCommand = cli.Command{
Name: "pause",
Category: "CONTROL",
Usage: "Pause the current file",
Action: func(ctx *cli.Context) error {
c, err := mp.Connect(ctx)
if err != nil {
return err
}
return c.SetPause(!c.Paused())
},
}
var StopCommand = cli.Command{
Name: "stop",
Category: "CONTROL",
Usage: "Stop the current file",
Action: func(ctx *cli.Context) error {
c, err := mp.Connect(ctx)
if err != nil {
return err
}
return c.Stop()
},
}