From ed9682c977fb0cc5d94f4ac653e3fbb514bd8ecc Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 1 Jul 2023 18:53:37 +0200 Subject: introduce Player interface to allow multiple player implementations --- wrms.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'wrms.go') 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) } -- cgit v1.2.3