Skip to content
12 changes: 10 additions & 2 deletions daemon/api_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,16 @@ func (p *AppPlayer) newApiResponseStatusTrack(media *librespot.Media, position i
albumCoverId = getBestImageIdForSize(track.Album.CoverGroup.Image, p.app.cfg.ImageSize)
}

var trackCoverUrl *string
if p.prodInfo != nil {
trackCoverUrl = p.prodInfo.ImageUrl(albumCoverId)
}
return &ApiResponseStatusTrack{
Uri: librespot.SpotifyIdFromGid(librespot.SpotifyIdTypeTrack, track.Gid).Uri(),
Name: *track.Name,
ArtistNames: artists,
AlbumName: *track.Album.Name,
AlbumCoverUrl: p.prodInfo.ImageUrl(albumCoverId),
AlbumCoverUrl: trackCoverUrl,
Position: position,
Duration: int(*track.Duration),
ReleaseDate: track.Album.Date.String(),
Expand All @@ -240,12 +244,16 @@ func (p *AppPlayer) newApiResponseStatusTrack(media *librespot.Media, position i

albumCoverId := getBestImageIdForSize(episode.CoverImage.Image, p.app.cfg.ImageSize)

var episodeCoverUrl *string
if p.prodInfo != nil {
episodeCoverUrl = p.prodInfo.ImageUrl(albumCoverId)
}
return &ApiResponseStatusTrack{
Uri: librespot.SpotifyIdFromGid(librespot.SpotifyIdTypeEpisode, episode.Gid).Uri(),
Name: *episode.Name,
ArtistNames: []string{*episode.Show.Name},
AlbumName: *episode.Show.Name,
AlbumCoverUrl: p.prodInfo.ImageUrl(albumCoverId),
AlbumCoverUrl: episodeCoverUrl,
Position: position,
Duration: int(*episode.Duration),
ReleaseDate: "",
Expand Down
18 changes: 18 additions & 0 deletions daemon/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/devgianlu/go-librespot/mpris"
"github.com/devgianlu/go-librespot/player"
"github.com/devgianlu/go-librespot/playplay"
connectpb "github.com/devgianlu/go-librespot/proto/spotify/connectstate"
devicespb "github.com/devgianlu/go-librespot/proto/spotify/connectstate/devices"
"github.com/devgianlu/go-librespot/session"
"github.com/devgianlu/go-librespot/zeroconf"
Expand All @@ -41,6 +42,18 @@ type App struct {
mpris mpris.Server
logoutCh chan *AppPlayer

// DJ cache persists across zeroconf reconnects so that a transfer command
// arriving on a new session can still use the queue from the last cluster push.
djCachedContextUri string
djCachedNextTracks []*connectpb.ContextTrack
djCacheIsOurs bool

// djSectionBuffer holds vibe-section playlist tracks received via hm://playlist/ pushes.
// Each entry is one section (from a different vibe playlist). When the lexicon 15-track
// window is exhausted, djPoll pops the next section from here to keep playback going
// without looping the same 15 tracks.
djSectionBuffer [][]*connectpb.ContextTrack

closed bool
}

Expand Down Expand Up @@ -212,6 +225,10 @@ func (app *App) newAppPlayer(ctx context.Context, creds any) (_ *AppPlayer, err
appPlayer.prefetchTimer = time.NewTimer(math.MaxInt64)
appPlayer.prefetchTimer.Stop()

appPlayer.djPollTimer = time.NewTimer(math.MaxInt64)
appPlayer.djPollTimer.Stop()
appPlayer.djPollAttempts = 0

if appPlayer.sess, err = session.NewSessionFromOptions(ctx, &session.Options{
Log: app.log,
DeviceType: app.deviceType,
Expand All @@ -229,6 +246,7 @@ func (app *App) newAppPlayer(ctx context.Context, creds any) (_ *AppPlayer, err

if appPlayer.player, err = player.NewPlayer(&player.Options{
Spclient: appPlayer.sess.Spclient(),
Mercury: appPlayer.sess.Mercury(),
AudioKey: appPlayer.sess.AudioKey(),
Events: appPlayer.sess.Events(),
Log: app.log,
Expand Down
Loading