just_audio icon indicating copy to clipboard operation
just_audio copied to clipboard

Add method to clear all audioSource inside AudioPlayer

Open bianca8 opened this issue 10 months ago • 6 comments

Is your feature request related to a problem? Please describe. I don't see any clear() method to clear all audioSources in the AudioPlayer! Even in the documentation it is not clear how to delete everything, so I think is necessary to add a method to remove all audioSource.

Describe the solution you'd like Add a method to clear all

Describe alternatives you've considered There isn't an alternative

Additional context Nobody

bianca8 avatar Feb 28 '25 16:02 bianca8

The next major release will offer a playlist API on the player instance itself, including a clear method. Until then, if you set a ConcatenatingAudioSource as the main audio source of the player, you can just call the clear method on that to achieve the same effect. (The new playlist will be implemented internally by just doing that.)

ryanheise avatar Mar 01 '25 05:03 ryanheise

Hi @ryanheise Thank you for your answer! I have two more questions.

  1. After calling the clear on ConcatenatingAudioSource, do I have to call the setAudioSource again?

  2. So, it’s possible to delete the elements of a playlist, but not on the single audio? Because if instead I load the single audio, I noticed that before loading the new audio, it makes me hear the previous audio for a few seconds, I wonder if it's a bug or if it's possible to solve this problem in some way.

I hope I was clear.

bianca8 avatar Mar 01 '25 14:03 bianca8

@bianca8 , please consult the examples in this repo if you would like to see how to use ConcatenatingAudioSource. I would like to keep this issue focused on the given feature request, so if you would like to report a bug, please open a new issue for that. If you have questions, the place reserved for that is StackOverflow.

ryanheise avatar Mar 01 '25 14:03 ryanheise

Ok clear, thanks @ryanheise When do you plan to release this major release?

bianca8 avatar Mar 01 '25 14:03 bianca8

As soon as I get it working.

ryanheise avatar Mar 01 '25 14:03 ryanheise

I have a PR available at #1423 .

To test, it is necessary to comment/uncomment as indicated in the pubspec.yaml files to use the new platform interface with the new features.

ryanheise avatar Mar 14 '25 15:03 ryanheise