aboutsummaryrefslogtreecommitdiff
path: root/wrms.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-07-01 18:53:37 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-07-01 18:53:37 +0200
commited9682c977fb0cc5d94f4ac653e3fbb514bd8ecc (patch)
treefc588216fc8419ff86482dcb48a446f6058af34a /wrms.go
parentdb21d2ec6980e31a2e9a0db60eb2fdad83b33671 (diff)
downloadWRMS-ed9682c977fb0cc5d94f4ac653e3fbb514bd8ecc.tar.gz
WRMS-ed9682c977fb0cc5d94f4ac653e3fbb514bd8ecc.zip
introduce Player interface to allow multiple player implementations
Diffstat (limited to 'wrms.go')
-rw-r--r--wrms.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/wrms.go b/wrms.go
index 96bb43d..9d94325 100644
--- a/wrms.go
+++ b/wrms.go
@@ -164,7 +164,7 @@ type Wrms struct {
Songs []Song
queue Playlist
CurrentSong atomic.Pointer[Song]
- Player *Player
+ Player Player
Playing bool
Config Config
eventId atomic.Uint64
@@ -173,7 +173,7 @@ type Wrms struct {
func NewWrms(config Config) *Wrms {
wrms := Wrms{}
wrms.Config = config
- wrms.Player = NewPlayer(&wrms, config.Backends)
+ wrms.Player = NewMpvPlayer(&wrms, config.Backends)
return &wrms
}
@@ -300,8 +300,8 @@ func (wrms *Wrms) DeleteSong(songUri string) {
func (wrms *Wrms) Next() {
wrms.rwlock.Lock()
- // Terminate the mpv process playing the current song
- if wrms.Player.mpv.Load() != nil {
+ // Terminate the Player if it is currently playing
+ if wrms.Player.Playing() {
wrms.Player.Stop()
}
@@ -372,10 +372,10 @@ func (wrms *Wrms) PlayPause() {
return
}
- // Wrms has an active mpv process -> continue playing
- if wrms.Player.mpv.Load() != nil {
+ // The player is playing -> continue playing
+ if wrms.Player.Playing() {
wrms.Player.Continue()
- // Wrms has a current song but no mpv process playing it -> start a new one
+ // The player is stopped -> start it
} else {
wrms.Player.Play(currentSong)
}