-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.go
More file actions
53 lines (45 loc) · 1.05 KB
/
player.go
File metadata and controls
53 lines (45 loc) · 1.05 KB
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
package main
// This file implements the player state.
// The player communicates over RPC (Remote Procedure Call)
// with the client. The client forks a player daemon (clip -d)
// if none is yet running and sends RPC calls to it.
import (
//"sync"
)
type Player struct {
Lib // the player's library
//playlist ItemArray
// current int // current track
// playing bool
// backend Backend
port string // default RPC port
// sync.Mutex
}
// Constructor
func NewPlayer() *Player {
p := new(Player)
p.init()
return p
}
// Wraps the player in an API to expose methods available to the user.
func (p *Player) API() API {
return API{p}
}
// Wraps the player in an RPC to expose methods available to the RPC server.
func (p *Player) RPC() RPC {
return RPC{p}
}
func (p *Player) init() {
Debug("player initialized")
(&p.Lib).init()
//p.playlist = ItemArray([]*Item{})
//p.playing = false
//p.current = -1
//p.port = ":25274"
//p.backend = new(MPlayer)
}
// Main loop for daemon mode
func (p *Player) Daemon() {
// TODO: heartbeat here
p.serveRPC()
}