diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-07-01 18:53:37 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-07-01 18:53:37 +0200 |
| commit | ed9682c977fb0cc5d94f4ac653e3fbb514bd8ecc (patch) | |
| tree | fc588216fc8419ff86482dcb48a446f6058af34a /wrms.go | |
| parent | db21d2ec6980e31a2e9a0db60eb2fdad83b33671 (diff) | |
| download | WRMS-ed9682c977fb0cc5d94f4ac653e3fbb514bd8ecc.tar.gz WRMS-ed9682c977fb0cc5d94f4ac653e3fbb514bd8ecc.zip | |
introduce Player interface to allow multiple player implementations
Diffstat (limited to 'wrms.go')
| -rw-r--r-- | wrms.go | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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) } |
