redesign: Can't start playback from Songs tab in offline mode
Steps to reproduce (as of 89fec629833c8daf49c0362c821bd9c42276ac54):
- Download an album
- Enable offline mode
- Go to songs tab
- Click on a song
- Playback doesn't start
Logs:
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.142363:
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.142759: --> GET https://example.com/Items/[song1itemid]/InstantMix?userId=[userid]&limit=200
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.142903: Content-Type: application/json
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.143022: X-Emby-Authorization: MediaBrowser UserId="[userid]", Client="Finamp", Device="Pixel 3", DeviceId="[deviceid]", Version="0.6.15"
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.143146: X-Emby-Token: [token]
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.143278: content-length: 0
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.143424: --> END GET
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.495575:
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.495956: <-- 200 OK GET https://example.com/Items/[song1itemid]/InstantMix?userId=[userid]&limit=200
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.496125: x-response-time-ms: 87
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.496247: content-type: application/json; charset=utf-8
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.496355: transfer-encoding: chunked
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.496470: date: Sat, 09 Dec 2023 19:07:37 GMT
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.496573: strict-transport-security: max-age=16000000; includeSubDomains; always
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.496703: server: Kestrel
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.496824: content-length: 297177
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.496942:
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.497054: {"Items":[{"Name":"Dandelion (Pandapush Remix)","ServerId":"[serverid]","Id":"[song1itemid]","PremiereDate":"2021-03-19T00:00:00.0000000Z","ChannelId":null,"RunTimeTicks":1433719680,"ProductionYear":2021,"IndexNumber":2,"ParentIndexNumber":1,"IsFolder":false,"Type":"Audio","ParentLogoItemId":"[artist1itemid]","ParentBackdropItemId":"[artist1itemid]","ParentBackdropImageTags":["[someotherid]"],"UserData":{"PlaybackPositionTicks":0,"PlayCount":17,"IsFavorite":false,"LastPlayedDate":"2023-12-01T13:17:24.0042489Z","Played":true,"Key":"Galantis-Dandelion (Remixes)-0001-0002Dandelion (Pandapush Remix)"},"Artists":["Galantis","Jvke"],"ArtistItems":[{"Name":"Galantis","Id":"[artist1itemid]"},{"Name":"Jvke","Id":"[artist2itemid]"}],"Album":"Dandelion (Remixes)","AlbumId":"[albumitemid]","AlbumPrimaryImageTag":"[sometruncatedid]
I/flutter (26426): [Chopper/INFO] 2023-12-09 20:07:37.505857: <-- END HTTP
I/flutter (26426): [DownloadsHelper/INFO] 2023-12-09 20:07:37.519543: Song [song1itemid] exists offline, using local file, title: Dandelion (Pandapush Remix)
I/flutter (26426): [DownloadsHelper/INFO] 2023-12-09 20:07:37.546731: Song [song2itemid] exists offline, using local file, title: Dandelion (Carneyval Remix)
I/flutter (26426): [MusicPlayerBackgroundTask/INFO] 2023-12-09 20:07:37.561139: Stopping audio service
I/flutter (26426): [QueueService/SEVERE] 2023-12-09 20:07:37.564575: Offline mode enabled but downloaded song not found. title: Shimmer (Feat. Christian Burns)
I/flutter (26426): [AudioServiceHelper/SEVERE] 2023-12-09 20:07:37.564901: Offline mode enabled but downloaded song not found. title: Shimmer (Feat. Christian Burns)
E/flutter (26426): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Offline mode enabled but downloaded song not found. title: Shimmer (Feat. Christian Burns)
E/flutter (26426):
I've redacted the logs a bit, and edited code to include song titles in the errors.
- there are 3 songs downloaded, all from the same 1 album (
Dandelion (Remixes)) -
song1isDandelion (Pandapush Remix), which I clicked on -
song2is another song from the album -Dandelion (Carneyval Remix) -
Shimmer (Feat. Christian Burns)is a song from another album, which hasn't been downloaded, and its ID likely was received as part of the Instant Mix requested from server.
This issue is probably a regression from #484, see https://github.com/jmshrv/finamp/pull/484/files#diff-8ce322217fed731e5c785038127677c3268344f05cc74b0af807c8534c4b0b37R209 - instead of playing just one song, there's a request for Instant Mix (nice feature btw). From observing how this works in online mode, I guess that for a split second another song is put on top of queue, and then the order is corrected, and the originally clicked song plays?
Good catch. Yeah it's trying to play an instant mix, I didn't really test much with offline mode. The instant mix is a server-side feature that already has the source song as the first item, so there's no reordering going on, we're taking the order straight from the server.
I got a proof of concept for simply playing a single song (like before the regression), but because it's offline mode we could actually load up all songs and play the tracks in-order. What do you think?
It might be a little weird at first glance that playing in order is available only in offline mode, but I have no preference here, at least it would partially help with #502.
Yeah in the context of #502 I think we should just get full song list playback whereever possible...
Okay, in offline mode all tracks will now be loaded into the queue in-order, with the selected track being sandwiched somewhere in-between and selected as the current track.
Hopefully I can emulate this in online mode soon.