Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict between react-native-audio-toolkit and react-native-track-player #236

Open
nathantqn opened this issue Aug 10, 2020 · 10 comments
Open

Comments

@nathantqn
Copy link

Hi guys, really appreciate your efforts in this super cool Audio Toolkit. My below explanation will be long to clarify my current issue, and I believe it's also a frustration of most React Native developers when they handle complex Audio Player.

I'm developing a guided meditation app. The app allows users to select a meditation sound to play, and also has a background sound embedded to each meditation (a background sound can be soft music, ambiance, ...). Another requirement for this app is supporting background mode (when user locks the screen, he/she can need to continue hearing both sounds of meditation and background sound played in background, and can also control the player via the controller on the lock screen of iOS )

The image below is to illustrate background mode
image

Because the meditation sound's duration is long (some sound can be over 1 hour length) and the requirement is background mode, I need a library which supports both streaming and background controller, that's why I chose react-native-track-player, and it works fine.

However, I also need to handle the background sound which is played concurrently with the main track of meditation, and react-native-track-player didn't support multitrack playing (you can see this issue: doublesymmetry/react-native-track-player#172 (comment)).

That's why I need to find another library to handle the background sound, at the beginning, I chose react-native-sound to handle it, however, react-native-sound didn't support streaming, and some background sounds are over 4 minutes and they take a lot of time for react-native-sound to load the whole sound before playing it.

Then I found react-native-audio-toolkit which supports streaming, I changed all of my logic of react-native-sound to react-native-audio-toolkit, and yes, it solves my slow loading speed issue, but I found another issue between react-native-audio-toolkit and react-native-track-player. Whenever the background sound handled by react-native-audio-tookit is played, it killed the background-mode functionality of react-native-track-player (the main sound handled by react-native-track-player is still playing, but the controller on the lock screen is disappeared)

The image below is to illustrate what it looks like when the controller on lock screen is disappeared
image

So my question: Is there any solution for this, I'm not sure whether it's because of the race condition between 2 libraries when they both support background mode playing. I'm super frustrated now and can't know how to solve this issue.

Thanks for your time of reading this long explanation.

@diegolego
Copy link

Why not just use react-native-audio-toolkit?

@nathantqn
Copy link
Author

nathantqn commented Aug 11, 2020

Hi @diegolego, but does react-native-audio-toolkit support the iOS background controller when the screen is locked as I screenshot above?

@diegolego
Copy link

Unfortunately it only supports background mode on Android.
https://github.com/react-native-community/react-native-audio-toolkit/blob/master/docs/API.md#player-methods

I'm building an app with the same requirements. After checking out most of react-native audio libraries out there I didn't find one that supports both: background mode and merging two audios (on iOS and Android).

I was using react-native-cli but I figured that using expo.io with the expo-av package with some extra configuration might work. I'm gonna give that a try. I'll let you know if it works. Please let me know if you find a solution to this problem.

Cheers, and the best of luck with your project!

@diegolego
Copy link

By the way, I also found this option (haven't tried it yet though)
https://dev.to/chafikgharbi/a-trick-to-play-sound-on-screen-lock-or-background-in-react-native-and-expo-32ml

@bourgois
Copy link

bourgois commented Apr 9, 2021

Did you found a solution at the end?

@gavrichards
Copy link

I'm also having the exact same problem with the conflict between the these libraries and the disappearing lock screen controls. Would love to know if anyone found a solution.

@KrisLau
Copy link

KrisLau commented May 17, 2022

@nenjamin2405 @gavrichards @bourgois Did anyone ever figure out a solution to this? I'm in the same predicament

@gavrichards
Copy link

Yes I switched to this fork, which has a fix for the issue.

@KrisLau
Copy link

KrisLau commented May 17, 2022

@gavrichards Thanks so much, that fork actually builds for me while the master fork seems to be having issues! Now to figure out hwo to actually get the player to stop playing since that doesn't seem to work for me😆

@KrisLau
Copy link

KrisLau commented May 25, 2022

Yes I switched to this fork, which has a fix for the issue.

@gavrichards In case you are looking for alternatives this thread might help: #270 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants