some simplification of PlaybackManager
This commit is contained in:
+1
-33
@@ -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
|
||||
|
||||
@@ -17,7 +17,6 @@ type BasePlayer interface {
|
||||
PlayTrackAt(idx int) error
|
||||
Continue() error
|
||||
Pause() error
|
||||
PlayPause() error
|
||||
Stop() error
|
||||
SeekPrevious() error
|
||||
SeekNext() error
|
||||
|
||||
Reference in New Issue
Block a user