[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
- Try to play a music when the app is in background. You can check the code in my snack: https://snack.expo.io/@gsantiago/reproducible-bug---failed-to-play-audio-when-the-app-is-in-background
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
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:
- Created 4 years ago
- Reactions:20
- Comments:27 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is any progress on this issue?
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.