florent37 / Flutter-AssetsAudioPlayer

Play simultaneously music/audio from assets/network/file directly from Flutter, compatible with android / ios / web / macos, displays notifications
https://pub.dartlang.org/packages/assets_audio_player
Apache License 2.0
750 stars 348 forks source link

[New Feature] Reopen Playlist after stop (on play) + Add ability to change `startIndex` #173

Closed pro100svitlo closed 4 years ago

pro100svitlo commented 4 years ago

Describe the feature you'd like I am creating a playlist once per lifecycle and I would like to have the possibility to play the same queue but with the possibility to start from different positions.

For example, user click play the first time (I am opening playlist with the position of this item). Then he clicks stop (notification is hidden). Then he selects another composition and clicks play again (here I would like to change start index for the playlist and reuse it again).

pro100svitlo commented 4 years ago

Or another way:

florent37 commented 4 years ago

hi, thanks for the issue, why not opening a new playlist directly ?

If you click on stop it should be better

you keep your audios inside a List, and sort them differenlty when click on play (after your stop) ?

florent37 commented 4 years ago

and for me pressing stop make the playlist not usable again,

you have to re-use open to play it again, even for a standard playlist

florent37 commented 4 years ago
class MyWidget {
      final List<Audio> allAudios = [...];
      final AssetsAudioPlayer _player = AssetsAudioPlayer();

      void open() {
           if(firstTime) {
                 _player.open(allAudios, startIndex: 0);
           } else {
                 _player.open(allAudios, startIndex: 3);
           }
      }
}
pro100svitlo commented 4 years ago

and for me pressing stop make the playlist not usable again, you have to re-use open to play it again, even for a standard playlist

this is the reason why I didn't use stop button as its designed. I am using it as release.

So (its another topic, but) I can propose also to separate stop and release/dispose. Yeah, I know there is dispose method 😄 What I expect from stop? Stop playing and put position to 0 without releasing the audio. Releasing audio and player itself is the responsibility of dispose method, IMO.

pro100svitlo commented 4 years ago
class MyWidget {
final List<Audio> allAudios = [...];
final AssetsAudioPlayer _player = AssetsAudioPlayer();
void open() {
if(firstTime) {
_player.open(allAudios, startIndex: 0);
} else {
_player.open(allAudios, startIndex: 3);
}
}
}

Will try this way, thanks :)

florent37 commented 4 years ago

Yes I agree with you, what I can do, keep the last opened audio (or playlist), and on stop, it ''stop'' :D, but not release the audio. And on next play, it can reopen the audio,

I will add a startIndex method to change it for this case ;)

pro100svitlo commented 4 years ago

I really appreciate your effort :)

florent37 commented 4 years ago

I added the stop then play which reopen at startIndex, and you can edit the playlist startindex, it's now mutable

_player.playlist?.startIndex = 1;

florent37 commented 4 years ago

can you try 2.0.2+3 ?