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: expo-av audio cannot override silent switch unless autoplayed.

See original GitHub issue

Summary

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:open
  • Created 2 years ago
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
thevintercommented, Feb 21, 2022

Can confirm the issue still exists

3reactions
expo-botcommented, Jul 12, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix 'Video play but don't have sound on iOS with expo'
Enabling background audio is not the solution (especially if you are ... due to the silent switch on the side of the iPhone...
Read more >
Audio - Expo Documentation
expo -av allows you to implement audio playback and recording in your app. Note that audio automatically stops if headphones / bluetooth audio...
Read more >
React Native: How to Load and Play Audio | by Ross Bulat
This article introduces the expo-av package, a universal audio (playing and ... Major iOS updates are launched on a yearly basis and Android ......
Read more >
Camera User Guide
If anything is missing, contact your camera retailer. Camera ... to switch to the next image, or to change ... wrong way, it...
Read more >
vfz - River Thames Conditions - Environment Agency - GOV.UK
#car Silent treatment in-flight safety mp3, Silicon forest, ... Change app name ios 6, Jackie chan adventures ps2 review, Oude spoorlijn den bosch, ......
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