Audio playback in background
closed
Brent Vatne
this is now partially supported, but you cannot control the audio playback with operating system controls yet
Axel Delafosse
Hi everyone!
You can now use React Native Track Player with Expo.
Start by creating a custom development client for your Expo app and then install React Native Track Player.
Here is the configuration required for audio playback in background:
- iOS: Enable audio playback in background via your app.jsonhttps://docs.expo.dev/versions/latest/sdk/audio/#playing-or-recording-audio-in-background-ios
- Android: Stop playback when the app is closed https://react-native-track-player.js.org/background/#android
And don't forget to register a playback service.
Enjoy :)
I
Ismael Ghanim
Are there any plans to add this functionality within expo-av? I'd rather not use react-native-track-player, since it's fairly buggy and doesn't match my use case very well. But it's my only option because I need to be able to control background playback with OS controls.
Gionata Brunel
Ismael Ghanim: you can already use expo-av but you need to install one extra package (see https://medium.com/@gionata.brunel/implementing-react-native-track-player-with-expo-including-lock-screen-part-1-ios-9552fea5178c)
I
Ismael Ghanim
Gionata Brunel: Hi, thanks for your response. This article doesn't seem to address what I'm asking for though. This article seems to be a guide on how to use react-native-track-player within expo. I am already using react-native-track-player.
What I really want is to use expo-av, not react-native-track-player. But the problem is expo-av is missing media controls functionality. And I'm not aware of a way to use them together.
Brent Vatne
closed
As Axel Delafosse pointed out, you can use development builds (https://docs.expo.dev/development/introduction/) to use libraries such as React Native Track Player (https://react-native-track-player.js.org/) in your project to accomplish this functionality.
Gionata Brunel
Brent Vatne: nice - would it be possible to have an example ?
Doug Shontz, Jr.
Pretty much at this point to include ANY video in ANY app you have to at least be somewhere in the ballpark of how a social media platform works for clients to accept your work. I don't want to have to use RN Track Player when I'm already using Expo AV (and need it for video). If I have a video and want to play the audio in the background, it needs to truly be seamless and the video's audio keep playing and it act how "every other app" works. While that is happening and the audio does keep playing, the lack of OS controls is unfortunately a deal-breaker. I have clients literally rejecting my specs due to this one feature.
I've been so impressed with Expo up to this point and have spent two weeks trying to find ANY workaround for me to not ditch Expo. Everything about Expo is very clean and it is a marvelous ecosystem, but not having OS controls on audio is unacceptable after 5 years of this being "partially supported". I can't even point clients to this and say "They are working on it".
Is there an option for us to pay for this feature in some way? I understand work is time and time is money, so I'm willing to work with that statement. Maybe since this is such a popular request those of us who have any funds could kick in for the Expo team to pull background OS controls for Expo AV across the line?
Wodin
Doug Shontz, Jr.: Hi. Disclaimer: I'm just an Expo user, not part of the Expo team.
Maybe talking to one of these consultants will help:
Doug Shontz, Jr.
Wodin: Thanks for this! I will check it out. I'm also seeing if I can dedicate any dev time to this for a PR. Not sure if I can, but, if I'm going to spend time and money, I would prefer it be for the good of the community and not just myself. I would hope that the Expo team would respond to this in some way since it's such a highly requested item (the highest I can see on Canny).
Gionata Brunel
Doug Shontz, Jr.: OS controls for Expo AV would be the best option for me too - probably better than using react-native-track-player.
Gionata Brunel
Doug Shontz, Jr.: any luck?
Doug Shontz, Jr.
Gionata Brunel: None unfortunately. I did do some extensive testing of RN Track Player but it's an overly-engineered solution to try to play video, hand the audio track off, stop the video player, etc...etc. I did look at some of the consultants, but, although we don't necessarily have any monetary constraints...we have time constraints...and bringing in a new "team" of people just isn't feasible.
For now, I'm keeping Expo and just "dealing" with the lack of functionality. If I knew how to raise the flag higher of "why isn't this a thing?", I would, but I have voted for it here and I feel like anything else is a bit arrogant. The lack of movement in this in so many months and years speaks to where the team has chosen to prioritize it (no shade thrown...no emotion in the statement...Expo is massive with a lot of needs...just stating the obvious).
I have on my own time started a little side project to see if I can kind of "ground up build" a video player that has better controls and is more functional, but that will be a COMPLETE side project to what I'm doing.
Gionata Brunel
Doug Shontz, Jr.: thank you for your reply. I don't understand if Axel Delafosse or Michael Wood were or not able to make it working - reading the commets it seams that they did.
Wodin
Gionata Brunel: Hi. No, I did not try it. Perhaps you could post to forums.expo.dev to say what you have tried and what error messages you are getting etc?
Gionata Brunel
Wodin: Hi Michael and thank you for your replay. I tried few things and then I read Alex post: I'll be honest, I did not understand how to use the custom development client - the first step - and therefore I've got stuck right the way.
Tyler Sheaffer
Doug Shontz, Jr.: I've made an issue to integrate Video features into
react-native-track-player
here: https://github.com/doublesymmetry/react-native-track-player/issues/1792Would love to have you chime in on that issue. I'm facing a similar issue as you. Would the issue as described there solve your problem?
Doug Shontz, Jr.
Tyler Sheaffer: Yes, that is indeed the "hopeful" answer and I agree with what you've put in that GitHub ticket. Unfortunately, my team has moved on to another project and we lived with the limitations, so I have no time to dedicate to this other than what I investigated. I will gladly chime in over there so it's in the right place.
Gionata Brunel
Doug Shontz, Jr.: finally, I found the solution: https://medium.com/@gionata.brunel/implementing-react-native-track-player-with-expo-including-lock-screen-part-1-ios-9552fea5178c
Xpaew andX
pls add this :|
Zander Bournand
Even after installing track player with "expo install react-native-track-player" I keep getting the following error:
"Native module cannot be null".
I am not sure how to tackle this issue as I cannot open the project in xcode to follow step 2 that can be found under the installation instructions https://react-native-track-player.js.org/install/
Please Help :)
Surya
Zander Bournand: same problem have u got solution?
Wodin
Surya: You need to build with EAS Build and you cannot use Expo Go. If you want something like Expo Go you will need to build a custom development client as mentioned by Axel and then use that instead of Expo Go.
Surya
Wodin: While building eas for ios its getting error You have no team associated with your apple account cannot proceed and in brackets Do u have a paid apple dev account?
Is it compulsory to have apple paid developer account for testing purpose only ?
Wodin
Surya: I'm afraid I am not entirely sure of Apple's requirements. See if this documentation helps:
Wodin
Surya: Otherwise, I'm pretty sure you should be able to use the Simulator without paying for a developer account.
By the way, I am not a member of the Expo team. I am just another Expo user.
Gionata Brunel
Wodin: were you able to make it working?
Kevin Crabbe
I can't seem to be able to transition from one audio file to the next in the background. The transition is fine when the app is open but when I close the app, the current file keeps playing until it finishes but the transition to the next file never happens. Is there another way around this?
B
Berk Coker
Audio recording on Android is not supported as well. Need a foreground service to keep recording for anything longer than 15 seconds in the background
Axel Delafosse
in progress
Zach Reed
Yeah, can we not mark this
COMPLETE
just yet, since it isn't full support.David Talbot
Probably shouldn't be marked as complete until https://github.com/expo/expo/issues/4850 is closed
Axel Delafosse
David Talbot: I wasn't aware of this issue with
expo-av
. I'll take a look. Thanks David!By the way, you shouldn't experience this issue when using
react-native-track-player
so the pinned comment solution is still valid.David Talbot
Axel Delafosse: Awesome, thanks so much!
Load More
→