some simplification of PlaybackManager

This commit is contained in:
Drew Weymouth
2023-12-21 20:18:53 -08:00
parent 1e466e4cdf
commit 4c3d638aed
3 changed files with 41 additions and 77 deletions
+1 -33
View File
@@ -312,11 +312,6 @@ func (p *Player) setPaused(paused bool) error {
return err
}
// Start playback from the first track in the play queue.
func (p *Player) PlayFromBeginning() error {
return p.PlayTrackAt(0)
}
// Start playback from the specified track index in the play queue.
func (p *Player) PlayTrackAt(idx int) error {
// check if we have anything to play
@@ -333,33 +328,6 @@ func (p *Player) PlayTrackAt(idx int) error {
return err
}
// Begins playback if there is anything in the play queue and player is stopped or paused.
// If player is playing, pauses playback.
func (p *Player) PlayPause() error {
if !p.initialized {
return ErrUnitialized
}
switch p.status.State {
case player.Stopped:
// check if we have anything to play
if c, err := p.getInt64Property("playlist-count"); err == nil && c > 0 {
err := p.mpv.Command([]string{"playlist-play-index", "0"})
if err == nil {
p.setState(player.Playing)
}
return err
}
return nil
case player.Playing:
return p.Pause()
case player.Paused:
return p.Continue()
default:
return errors.New("Unknown player state")
}
}
// Pause playback and update the player state
func (p *Player) Pause() error {
if p.status.State != player.Playing {
@@ -382,7 +350,7 @@ func (p *Player) Continue() error {
}
return err
} else if p.status.State == player.Stopped {
return p.PlayFromBeginning()
return p.PlayTrackAt(0)
}
return nil
-1
View File
@@ -17,7 +17,6 @@ type BasePlayer interface {
PlayTrackAt(idx int) error
Continue() error
Pause() error
PlayPause() error
Stop() error
SeekPrevious() error
SeekNext() error