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.

expo app playing sounds on return from multitasking

See original GitHub issue

For some reason when I return from multitasking to the app , the click sound that I have programmed in, plays. It doesn’t play the sound if the function was never called while the user was using the app. So for example if the user used the app without ever triggering the sound it won’t play when returning from the multitasking screen. However , if the user has triggered the sound once or more than once the sound will play that many times on return. This behavior can also be noticed when pulling down the notification bar or when a pop up notification appears for low battery.

Code: class Home extends Component {

Play() { this.clickSound(); }

async clickSound() { const soundObject = new Expo.Audio.Sound(); try { await soundObject.loadAsync(loadedClickSound); await soundObject.playAsync(loadedClickSound); } catch (error) { } } render() { return ( <Button title="PLAY" large onPress={() => this.Play()} /> ); } } Things I have tried :

  1. Adding soundObject.unloadAsync() in componentWillUnmount

  2. The same thing but right after the sound plays. Although this just causes the sound not to play at all.

Note: I only have an IOS device not sure if the issue can be recreated on android

Second Note: This isn’t the same as #1329, cause in that case, the un-played sounds played afterwards

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
idecommented, Mar 8, 2018

Thank you for the reports. This appears to be an bug with Expo iOS and is a known issue. We don’t have a fix slated for SDK 26 but please see my post above for a conceptual workaround. There is a small example here: https://github.com/ide/love-languages/blob/6fd73d3c85a13db60fbc0c22b26d88b3feeb3cbe/app/assets/Sounds.js#L39-L43

1reaction
sjchmielacommented, Mar 19, 2018

This issue has been fixed in https://github.com/expo/expo/commit/3835682976a0ec1c0604654546f5e6f5c77c8de5, which will ship in SDK 26. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Returning to app in multitasking - Unity Forum
If I return to the game on the main menu, the music isn't playing. That music comes from on Audio Source on one...
Read more >
LG Expo GW820: Windows Cell Phone for AT&T
Get information on the LG Expo GW820. Find pictures, reviews, and technical specifications for this LG windows cell phone.
Read more >
React Native Expo Toggle Audio On and Off - Stack Overflow
log("sound couldn't play"); } }; return ( <HeaderButton {...props} IconComponent={Ionicons} iconSize={23} iconName={soundIcon ? "ios-volume-high ...
Read more >
AppState - React Native
AppState can tell you if the app is in the foreground or background ... during periods of inactivity such as entering the multitasking...
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