Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shuffle plays a few songs then stops #147

Closed
NotFluffy opened this issue Nov 22, 2021 · 12 comments
Closed

Shuffle plays a few songs then stops #147

NotFluffy opened this issue Nov 22, 2021 · 12 comments
Labels
awaiting response / stale Issue is possibly outdated or waiting for user feedback redesign-beta Issues related to the beta/redsigned version of Finamp

Comments

@NotFluffy
Copy link

Android with finamp version 0.5.1

When I shuffle an album, it will play a few songs then replay those same few songs before ending without playing all the other songs.

I seem to mostly get this happen when I am not actively on my phone, when it is "sleeping" and I am using a bluetooth device.

It mostly happens a first time then I have to redo the shuffle on the same album and all goes well.

Exemple :
40 track song
Plays first song of the list
Plays 5 shuffled songs
Replays the same 5 songs in the same order
Ends

@ltkun
Copy link

ltkun commented Feb 10, 2022

Same issue with me. When I change the battery optimization to not optimized finamp works well.

@Chaphasilor
Copy link
Collaborator

Is this still happening? If yes, could it be related to #491?

@shayaantx
Copy link
Contributor

shayaantx commented Dec 4, 2023

I've also noticed some behavior like this as well with shuffle, randomly stopping, and not shuffling through all the songs (haven't tried looking into it yet)

@shayaantx
Copy link
Contributor

@Chaphasilor this has been happening to me so often I've been forced to look into it (see attached patch that shows logging changes)

What seems to be happening so far:

  1. Press shuffle button on a playlist with 11 items
  2. It randomizes the initial index (in this case below it was 5)
  3. This was at 2024-02-25 13:19:24.58248
  4. I listened to one song, then at 2024-02-25 13:21:20.755077 "Stopping audio service" is logged
  5. I did not skip or do anything, finamp just stopped playing it
  6. I printed the stack when the audio service is stopped (see below) - music_player_background_task.dart:171:9 is the just_audio player processingStream reporting a ProcessingState.completed event. So it does appear like the just audio library is the current culprit so far
#0      MusicPlayerBackgroundTask.stop (package:finamp/services/music_player_background_task.dart:208:9)
#1      new MusicPlayerBackgroundTask.<anonymous closure> (package:finamp/services/music_player_background_task.dart:171:9)
[AudioServiceHelper/INFO] 2024-02-25 13:19:24.293152: Replace queue with item after media item gen, item count=11

null
[MusicPlayerBackgroundTask/INFO] 2024-02-25 13:19:24.309573: Update queue, count=11, nextIndex=5

null
[MusicPlayerLogger/INFO] 2024-02-25 13:19:24.309900: Insert called, index=0, count=11

null
[MusicPlayerLogger/INFO] 2024-02-25 13:19:24.582488: Shuffle called, initialIndex=5

null
[MusicPlayerBackgroundTask/INFO] 2024-02-25 13:19:24.943176: setShuffleMode shuffleMode=AudioServiceShuffleMode.all

null
[MusicPlayerBackgroundTask/INFO] 2024-02-25 13:21:20.755077: Stopping audio service

null
[MusicPlayerBackgroundTask/INFO] 2024-02-25 13:21:20.760580: Stopping audio service debug Exception: This is an error message

#0      MusicPlayerBackgroundTask.stop (package:finamp/services/music_player_background_task.dart:208:9)
#1      new MusicPlayerBackgroundTask.<anonymous closure> (package:finamp/services/music_player_background_task.dart:171:9)
#2      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#3      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#4      _DelayedData.perform (dart:async/stream_impl.dart:515:14)
#5      _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
#6      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
#7      _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#8      _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

[MusicPlayerLogger/INFO] 2024-02-25 13:21:20.847808: Shuffle called, initialIndex=5

logging.patch

I need to investigate a bit further and see why the player reaches the end of the audio and pushes the ProcessingState.completed event

@shayaantx
Copy link
Contributor

Based on just audio https://github.com/ryanheise/just_audio/blob/422a90e8d055dbc300516009ac6dbfc036eff46e/just_audio/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java#L343, Player.STATE_ENDED is somehow getting triggered

I guess thats all from exo player

Just first glance, finamp uses 2.18.1 of just audio, I looked through https://github.com/google/ExoPlayer/releases and didn't really see any release notes that apply except maybe this androidx/media#538 (but its not exactly the same issue)

I'll need to make a custom build of exoplayer to get more info when it occurs :|

@shayaantx
Copy link
Contributor

Looks like that exoplayer repo is getting deprecated, the newer one has a bunch of issues that are semi relevant

androidx/media#842
androidx/media#640
androidx/media#273

@Chaphasilor
Copy link
Collaborator

@shayaantx is that on the stable version or redesign beta? Could it be an issue with the queue (unlikely if it stops mid-song) or with pre-caching (more likely, player has to pause because all of the cached data has been played already)?

You could try increasing the buffer duration to see if that helps...

@shayaantx
Copy link
Contributor

@shayaantx is that on the stable version or redesign beta? Could it be an issue with the queue (unlikely if it stops mid-song) or with pre-caching (more likely, player has to pause because all of the cached data has been played already)?

You could try increasing the buffer duration to see if that helps...

I'm always using whatever the latest in main is.

I'm not sure yet, how do I increase the buffer duration?

@Chaphasilor
Copy link
Collaborator

That's the stable version. Check the release page for the beta release, it corresponds to the redesign branch. That should hopefully fix your issue!

You can increase the buffer duration by going to settings > Audio Service and setting Buffer Duration to a higher value. The new default for the redesign is 600 seconds.

@Chaphasilor
Copy link
Collaborator

@shayaantx @NotFluffy @ltkun could you guys try again with the beta version 0.9.5? This should not be an issue there anymore...

@shayaantx
Copy link
Contributor

@Chaphasilor I'll do some testing and see if it reproduces

@Chaphasilor
Copy link
Collaborator

So? Any results? :)

@Chaphasilor Chaphasilor added awaiting response / stale Issue is possibly outdated or waiting for user feedback redesign-beta Issues related to the beta/redsigned version of Finamp and removed stale labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response / stale Issue is possibly outdated or waiting for user feedback redesign-beta Issues related to the beta/redsigned version of Finamp
Projects
Status: Done
Development

No branches or pull requests

4 participants