AudioSource.uri with headers not playing after screen is locked.

Basically the whole issue is described here: https://stackoverflow.com/questions/72425614/audiosource-uri-with-headers-not-working-when-app-is-locked-for-some-amount-of-t

Here you will find videos and exact steps to reproduce this issue.

The issue only happens on real iOS device – release and profile mode. Issue is not present when running iOS simulator.

Credentials are:

Please don’t mind the missing images, the root api url is set to test version. Audiofiles are present, that’s what matters.

Here are the steps captured in video:

video 1

  1. Login to the app lib/screens/login.dart
  2. After login, user gets redirected to my books screen lib/screens/books/my_books.dart
  3. After selecting audiobook, user gets redirected to book detail screen lib/screens/books/book.dart
  4. Press play button (the floating action button), this triggers following:
    • Clear playlist (lib/services/audio_player_state.dart:51)
    • Build new playlist (lib/services/audio_player_state.dart:67)
    • Redirect to player screen (lib/screens/player.dart)
  5. Audio starts playing, since there is myAudioPlayerState.play() method called on player screen in the initState() method (which triggers lib/services/audio_player_state.dart:33)
  6. Pause the audio by pressing the pause button under the seeker, this triggers this: lib/services/audio_player_state.dart:35
  7. Lock the screen

RPReplay_Final1653914411.MP4

video 2

  1. After locking the screen and keeping it locked for about 20 seconds, user returns to app an press play – audio starts playing (lib/services/audio_player_state.dart:33 triggered)
  2. User skips to next chapter – next chapter starts playing (lib/services/audio_player_state.dart:41 triggered)
  3. (THIS IS THE ISSUE) When user tries to skip to another chapter:
    • no audio is playing
    • player index quickly iterates through remaining items in queue
    • player state gets stuck in loading state.

RPReplay_Final1653914522.MP4

When I remove headers from AudioSource.uri constructor (lib/services/audio_handler.dart:114), the issue disappears.

GitHub

View Github