iOS: expo-av audio cannot override silent switch unless autoplayed.
See original GitHub issueSummary
Per the docs, you can set the audio for expo-av to override the ringer / silent switch on an iOS device. However, this is not working unless the video is autoplayed. Specifically, if the shouldPlay
prop is not set or set to false on the video, the video will not have audio on iOS if the silent switch is set to silent when the user presses play on the video. It WILL properly override the silent switch if the video autoplays by having the shouldPlay
prop set to true (but, this forces you to use autoplay without some hacks).
Here is a simple snack that reproduces the problem: https://snack.expo.io/@stuckj/expo-av-video-silentmode-bug. In the snack, the shouldPlay={true}
prop is commented out so the audio will not play on an iOS device when you press play on the video if the silent switch if set to silent. If you uncomment that code the audio will work.
NOTE: The audio will continue to work for all videos in the app after autoplaying one unless you reload the app. So, if you comment out the code again it WILL play audio, but if you reload the app it won’t play audio anymore.
The snack is based on this closed issue where @sethgw was still having problems even after the explanation. Autoplay appears to be the culprit.
UPDATE: This bug is SPECIFICALLY only when the video is started from the thumbnail image produced by the player. If you have shouldPlay={false}
and programmatically start the video with video.current.playAsync()
then audio will work properly.
~UPDATE2: This is worse in SDK45. It now won’t play with the ringer silent switch with autoPlay
set to true
or if you do video.current.playAsync
. This breaks the only workaround we found making this a more serious issue before we can update to SDK 45.~
UPDATE3: SDK 45 is no worse. You just have to make sure to switch to using the InterruptionModeIOS
and InterruptionModeAndroid
enumerations when you update to SDK 45.
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
managed
What platform(s) does this occur on?
iOS
SDK Version (managed workflow only)
42 - 45.
~In SDK 45 this bug is much worse (won’t play audio with the ringer silent switch even if autoPlay
is set to true
or if programmatically started).~
Environment
It’s in a snack…so, I’m not sure how to run expo diagnostics on it.
Reproducible demo or steps to reproduce from a blank project
As mentioned in the summary, this snack replicates it: https://snack.expo.io/@stuckj/expo-av-video-silentmode-bug. See the summary for the caveat about reloading after playing audio successfully.
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (2 by maintainers)
Can confirm the issue still exists
Thank you for filing this issue! This comment acknowledges we believe this may be a bug and there’s enough information to investigate it. However, we can’t promise any sort of timeline for resolution. We prioritize issues based on severity, breadth of impact, and alignment with our roadmap. If you’d like to help move it more quickly, you can continue to investigate it more deeply and/or you can open a pull request that fixes the cause.