ios – just_audio: setting audio source in background doesn’t work

0
158


My app is built on the audio-service and just-audio plugins, and works as follows:

  1. Creates a ConcatenatingAudioSource with the audio files I want to play;
  2. Calls player.setAudioSource() to this ConcatenatingAudioSource;
  3. When setAudioSource completes, calls “player.play()`;
  4. Listens to the playbackEventStream, and when processingState becomes ProcessingState.completed, (asynchronously) goes back to step 1.

Works fine on Android.

On iOS, this works fine when the app is in the foreground. When the app is in the background, though, Step 3 is never reached. I receive the AudioProcessingState.buffering event, but never the AudioProcessingState.ready event.

What’s the problem here?