finamp
finamp copied to clipboard
Last.fm scrobbling is broken on Linux
On Linux (flatpak), it seems like Finamp never properly reports a track as completed to the server. While playing a track, it correctly shows up in last.fm as "playing", however it never gets scrobbled properly. Just from a surface-level inspection, I think this stems from the same base issue as #907, which is that the playbackState never gets properly updated to AudioProcessingState.completed, which is evidenced by the fact that in the logs, PlaybackHistoryService doesn't log a "Stopping playback progress" message when a track is completed, and it instead logs an "Updating playback state" message and just repeats from the beginning of the queue immediately.
Going a bit further, I think this may actually be an issue in just_audio_media_kit. This is just a theory, so tell me if I'm wildly off base though since I have no experience with flutter.
Whenever something is queued up in Finamp, it throws this error in the console:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: RangeError (length): Invalid value: Valid value range is empty: 0
#0 _Array.[] (dart:core-patch/array.dart)
#1 MediaKitPlayer._currentMedia (package:just_audio_media_kit/mediakit_player.dart:39)
#2 new MediaKitPlayer.<anonymous closure> (package:just_audio_media_kit/mediakit_player.dart:60)
#3 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594)
#4 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:365)
#5 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297)
#6 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123)
#7 _DistinctStream._handleData (dart:async/stream_pipe.dart:439)
#8 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153)
#9 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594)
#10 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:365)
#11 _DelayedData.perform (dart:async/stream_impl.dart:541)
#12 _PendingEvents.handleNext (dart:async/stream_impl.dart:646)
#13 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:617)
#14 _microtaskLoop (dart:async/schedule_microtask.dart:40)
#15 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49)
The relevant snippet from just_audio_media_kit is
Media get _currentMedia =>
_player.state.playlist.medias[_player.state.playlist.index];
This is making me think that the playlist is not getting initialized properly, and that's causing just_audio_media_kit to not properly send out the completed event. I'm wondering if https://github.com/Pato05/just_audio_media_kit/pull/17 would maybe fix this (unfortunately I don't have the means to test this myself).
Hey, thanks for investigating this yourself! Yes, it seems like this is an upstream issue. Playback for Finamp on desktop doesn't yet behave exactly as on mobile, which throws off some of the playback reporting.
Btw, do you have the Playback Reporting plugin installed on your server? If yes, does it show the correct durations, or not?
Upstream PR got merged now, so this should trickle down into Finamp within the next two versions or so :)
Please remind me if I happen to forget upgrading the dependencies!
@vimproved is this this happening?
I just tested 0.9.12 on Linux and playback reporting still seems to be broken. It does correctly scrobble the current track, but they are never properly reported as stopped. And curiously, if there's only a single track in the queue, it is looped even with looping disabled.
@Maxr1998 but is there still an exception getting thrown?
No exceptions in the logs, and there's actually a POST to BASEURL/Sessions/Playing/Stopped, but the PositionTicks is zero, preventing the scrobble..
It's mostly working with 0.9.19 now.
The tracks get scrobbled correctly but the now scrobbling is frequently incorrect.