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

Fix shuffle always starts on first song(issues:#61) and remove redund… #442

Merged
merged 1 commit into from
May 10, 2023

Conversation

yuruxuan
Copy link
Contributor

@yuruxuan yuruxuan commented Apr 30, 2023

Try to fix #61

We pick a random item and put it first, instead of putting the first one first every time. And In order to make initialIndex take effect in updateQueue → _player.setAudioSource, I removed the if judgment in the replaceQueueWithItem method.

I remove _player.shuffle() when setShuffleMode(AudioServiceShuffleMode.all). It's redundant. I see the just_audio src code. When we invoke setAudioSource() method and proload is true, just_audio will call _load() method. AudioSource will be shuffled here. And platform.load() will send audioSourceMessage, initialPosition, initialIndex to native layer program.Actually audioSourceMessage contains shuffleOrder information. You can see just_audio-0.9.32/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java
at case concatenating part.

I see when I click block(or named stop) button on bottom bar. The current music always autochanged to album/playlist first item. Is this this app feature, or a bug?

Future<Duration?> _load(AudioPlayerPlatform platform, AudioSource source,
      {_InitialSeekValues? initialSeekValues}) async {

   ...

    try {
      await source._setup(this);
      checkInterruption();
      source._shuffle(initialIndex: initialSeekValues?.index ?? 0);
      _broadcastSequence();
      _durationFuture = platform
          .load(LoadRequest(
            audioSourceMessage: source._toMessage(),
            initialPosition: initialSeekValues?.position,
            initialIndex: initialSeekValues?.index,
          ))
          .then((response) => response.duration);
      
   ...

@jmshrv
Copy link
Owner

jmshrv commented May 2, 2023

This looks like a good fix! Just tested it and it didn't have the issue that I had where it would cut off half of the album (by skipping into it).

I see when I click block(or named stop) button on bottom bar. The current music always autochanged to album/playlist first item. Is this this app feature, or a bug?

This is an intended feature. It could be modified if it would make more sense here.

@yuruxuan
Copy link
Contributor Author

yuruxuan commented May 2, 2023

All right, I'm just asking so as not to modify some normal features : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shuffle starts on first song
2 participants