question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[iOS][Audio] Can't play an audio when the app is already in background

See original GitHub issue

🐛 Bug Report

Environment

  Expo CLI 2.19.5 environment info:
    System:
      OS: Linux 5.0 Ubuntu 19.04 (Disco Dingo)
      Shell: 3.0.2 - /usr/bin/fish
    Binaries:
      Node: 10.15.2 - /tmp/yarn--1567012357926-0.5700793194663918/node
      Yarn: 1.16.0 - /tmp/yarn--1567012357926-0.5700793194663918/yarn
      npm: 5.8.0 - /usr/bin/npm
    npmPackages:
      @types/react: ^16.8.19 => 16.8.19 
      @types/react-native: ^0.57.60 => 0.57.62 
      expo: ^34.0.3 => 34.0.4 
      react: 16.8.3 => 16.8.3 
      react-native: https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz => 0.59.8 
    npmGlobalPackages:
      expo-cli: 3.0.10

This bug only happens in iOS.

Steps to Reproduce

Expected Behavior

  • The app should play the audio when it’s already in background.

Actual Behavior

  • In Android, it works perfectly fine.
  • In iOS, I get the following error:
[Error: Play encountered an error: audio session not activated.]

Reproducible Demo

https://snack.expo.io/@gsantiago/reproducible-bug---failed-to-play-audio-when-the-app-is-in-background

And, yes. I have set staysActiveInBackground: true and all other necessary modes to play in background, and also UBackgroundModes: [‘audio’] in the app.json.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:20
  • Comments:27 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
Lyubomyrcommented, Mar 27, 2020

Is any progress on this issue?

6reactions
IjzerenHeincommented, Jul 24, 2020

As far as I’m aware, this was due to an issue in expo-av (similar issue was reported here https://github.com/expo/expo/pull/9363)

You should now be able to resume/play audio when in the background when staysActiveInBackground=true is set.

This has not yet landed in the Expo client, but you can try it out in a bare project using:

yarn install expo-av@8.4.0

You can find the changelog here: https://github.com/expo/expo/blob/master/packages/expo-av/CHANGELOG.md

Let us know whether that fixes it for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enabling Background Audio | Apple Developer Documentation
Configure your app to continue playing audio when it goes into the background. ... A common capability required by playback apps is to...
Read more >
xcode - iOS Audio/Sound won't play in background with ...
Note that the audio background mode permits an app to run in the background only for the purpose of playing audio.
Read more >
iMovie iOS | AUDIO track won't move? - YouTube
How to move and edit AUDIO and MUSIC in iMovie iPad and iMovie iPhone. ... try restarting your device. Your browser can't play...
Read more >
Understanding Audio Sessions - Audiokinetic
Ambient does not allow audio background playing from your app. If a user switches from your app to another audio app, your app...
Read more >
Audio settings for iOS - Zoom Support
Prerequisites for using the iOS audio settings · Zoom mobile app for iOS · Audio conferencing plan for Call My Phone option ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found