Skip to content

Commit

Permalink
feat: use Options.RestorePaused when transfering playback
Browse files Browse the repository at this point in the history
See  #143
  • Loading branch information
2opremio authored Nov 16, 2024
1 parent c6486e2 commit 9e1325d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmd/daemon/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import (
"sync"
"time"

log "github.com/sirupsen/logrus"
"google.golang.org/protobuf/proto"

librespot "github.com/devgianlu/go-librespot"
"github.com/devgianlu/go-librespot/ap"
"github.com/devgianlu/go-librespot/dealer"
"github.com/devgianlu/go-librespot/player"
connectpb "github.com/devgianlu/go-librespot/proto/spotify/connectstate"
"github.com/devgianlu/go-librespot/session"
"github.com/devgianlu/go-librespot/tracks"
log "github.com/sirupsen/logrus"
"google.golang.org/protobuf/proto"
)

type AppPlayer struct {
Expand Down Expand Up @@ -160,13 +161,13 @@ func (p *AppPlayer) handlePlayerCommand(req dealer.RequestPayload) error {

// options
p.state.player.Options = transferState.Options

pause := transferState.Playback.IsPaused && req.Command.Options.RestorePaused != "resume"
// playback
// Note: this sets playback speed to 0 or 1 because that's all we're
// capable of, depending on whether the playback is paused or not.
p.state.player.Timestamp = transferState.Playback.Timestamp
p.state.player.PositionAsOfTimestamp = int64(transferState.Playback.PositionAsOfTimestamp)
p.state.setPaused(transferState.Playback.IsPaused)
p.state.setPaused(pause)

// current session
p.state.player.PlayOrigin = transferState.CurrentSession.PlayOrigin
Expand Down Expand Up @@ -225,7 +226,7 @@ func (p *AppPlayer) handlePlayerCommand(req dealer.RequestPayload) error {
p.state.player.Index = ctxTracks.Index()

// load current track into stream
if err := p.loadCurrentTrack(transferState.Playback.IsPaused, true); err != nil {
if err := p.loadCurrentTrack(pause, true); err != nil {
return fmt.Errorf("failed loading current track (transfer): %w", err)
}

Expand Down

0 comments on commit 9e1325d

Please sign in to comment.