-
Notifications
You must be signed in to change notification settings - Fork 0
/
mplayer.go
48 lines (41 loc) · 993 Bytes
/
mplayer.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
// Package player : supports playing videos via different players: Web (HTML), MPV and later
// other video players
package mplayer
import (
"fmt"
"strings"
)
// Player : interface functions for every Player
type Player interface {
Play()
SetTitle(string)
SetURL(string)
}
// Props : Props to be passed to Player
type Props struct {
URL string
Title string
}
func (p *Props) SetTitle(title string) {
p.Title = title
}
func (p *Props) SetURL(URL string) {
p.URL = URL
}
// GetPlayers : A map of all available players
func GetPlayers() map[string]Player {
engines := make(map[string]Player)
engines["browser"] = &BrowserPlayer{}
engines["mpv"] = &MPVPlayer{}
engines["vlc"] = &VLCPlayer{}
// engines["mpv"] = NewFzEngine()
return engines
}
// GetPlayer : get a player for streaming
func GetPlayer(player string) (Player, error) {
e := GetPlayers()[strings.ToLower(player)]
if e == nil {
return nil, fmt.Errorf("Player %s Does not exist", player)
}
return e, nil
}