The just_audio AudioPlayer allows you to both stop and dispose:
_player.stop();
_player.dispose();
You use stop
when you still might want to start playing again in the future whereas dispose
is for when you are completely done.
My problem is that the audio_service AudioHandler that wraps the just_audio AudioPlayer only has a stop
method. There is no dispose
.
Is the correct way to do it to add a custom action?
@override
Future customAction(String name, Map<String, dynamic>? arguments) async {
if (name == 'dispose') {
await _player.dispose();
await super.stop();
}
}
And call it like this:
myAudioHandler.customAction('dispose', null);