'Flutter audio_service media resume

I have custom queuing logic using MediaItem which works properly when the UI is active. I am stopping the audio playback using onTaskRemoved method.

@override
  Future<void> onTaskRemoved() async {
    //if (!AudioServiceBackground.state.playing) {
    logger.v("Task Removed");
    await stop();
    //}
  }


 @override
  Future<void> stop() async {
    await _player.stop();
    await playbackState.firstWhere(
        (state) => state.processingState == AudioProcessingState.idle);
  }

However after swiping the task, notification is still visible and when I click the notification to resume nothing happens and app is stuck in splash screen.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source