Still not working for me on iOS SDK 34, not sure what I'm missing I added "UIBackgroundModes": ["audio"] and staysActiveInBackground: true
@Alejo Mendoza: are you testing on standalone app build? Background audio will not work in Expo client app, only in your own builds.
@Ladislav Soukup: Not working on my builds as well
Anyone know if this could be harnessed to play audio on push notification receive in order to get around Expo's inability to customize the push sound?
Please add support for switching to next Automatically!
Using v33 I play a sound and then leave the Expo client back to the home screen and the sound stops. When I open the Expo client again, it resumes playing. Currently testing in iOS. Seems like it will play only in foreground. Used setAudioModeAsync to set background audio as enabled. Not sure what I'm missing here.
@Matt Goodwin: Yes it happens for me too but works well on standalone app.
Uhh.. Do i need to download the latest expo-cli to make this work on my app... ??
Love that the background audio playback is working now! Thank you Expo team!
Is the lock screen player control something I can implement? Or is that not possible via Expo? If so, can you point me to any information that will help me build that piece?
@Larry J Rutledge: only when you eject for now - https://github.com/tanguyantoine/react-native-music-control (https://forums.expo.io/t/expo-av-audio-ios-support-for-control-center-lock-screen-control-etc/24235)
I have created feature request for this - https://expo.canny.io/feature-requests/p/add-react-native-music-control
I can also confirm Audio Playback in background working for Android as well.
@Guert Geraldo: We also have this working for Android BUT the audio stops after a while - could you confirm that you don’t have this problem? Thanks.
Pretty sure that ExoPlayer has to be implemented in a service to prevent Android from terminating it in the background https://www.youtube.com/watch?v=svdq1BWl4r8 Eject Eject!
@Sam Kuhn: Not on our side. We have tested 100 songs in a row with app in background and could not reproduce your issue. how long it takes for you until it stops?
@Guert Geraldo: From a few seconds to minutes - could we ask what android version you are testing on? It seems to work ok for us on older OS's..
@Sam Kuhn: I faced and solved a similar problem while using Ionic. It was related to Dose & Standby mode which effects Android 6+ users. https://developer.android.com/training/monitoring-device-state/doze-standby
@Alper E: Thanks for the info just skimmed the link but it also happens with the power connected so doze / standby shouldn't kick in? (and also on emulator).
Seems like correct way to fix is with a foreground service and lock screen notification / player?
(Non termination if:)
"The app has a process currently in the foreground (either as an activity or foreground service, or in use by another activity or foreground service)."
"Note: You should only use a foreground service for tasks the user expects the system to execute immediately or without interruption. Such cases include uploading a photo to social media, or playing music even while the music-player app is not in the foreground. You should not start a foreground service simply to prevent the system from determining that your app is idle."
The ExoPlayer team also describe here: https://www.youtube.com/watch?v=svdq1BWl4r8
Example code from presentation:
Be interested to hear how you solved it.. ;)
@Sam Kuhn: Yes, I solved by running a foreground service (with a cordova plugin). Btw you can test the doze mode in Android Simulator using adb, which helped me a while trying to fix this. Check: https://developer.android.com/training/monitoring-device-state/doze-standby
Yeah Able to play audio in background for ios eith sdk 33. Haven't tested on android yet. Is there a plan for implementing native controls? Thank yo for your effort
@Guert Geraldo: Any tips on how you got it working? Using Expo Client on iOS and the audio pauses when I close the app and resumes when I open it again.
@Matt Goodwin: Yes Ma i can confirm that it pauses on ios (it was not always like this) when you use it inside expo client. But on Standalone app it works perfectly.
Don't forget the necessary configurations on app.json and Audio object.
Really looking forward for this to work on Android. Essential feature for my app too.
Works for me! Thank you to everyone who made it possible.
EDIT: See below, bug report for Android
My demo is here: https://expo.io/@dctalbot/wcbn-app
@David Talbot: no background audio for me on Android... 😕
@David Talbot: We have downloaded your app and noticed that you appear to have the same issue as us on Android - namely the background audio halts after a little while. Have you encountered this yourself? Thanks.
@Sam Kuhn: Yes, It must be device or OS specific. I've gotten a report of this from a beta tester who has a Moto x4 running Android 9. I can't reproduce it on my LG LS676 running Android 6. Can you please file an issue here: https://github.com/expo/expo/issues/new/choose
And I will comment whatever details I can
@David Talbot: Thanks for confirming - I have opened an issue here: https://github.com/expo/expo/issues/4850