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

How can we change the source of Audio Player ? #234

Open
ShivamJoker opened this issue Jul 28, 2020 · 3 comments
Open

How can we change the source of Audio Player ? #234

ShivamJoker opened this issue Jul 28, 2020 · 3 comments

Comments

@ShivamJoker
Copy link

How should we play multiple audios ?

Actually I am destroying and creating new player every time I need to play another audio file.
Storing the current player in a ref but it doesn't seems to be working on android properly the duration gets messed up and the audio doesn't play.

  // change the song when index changes
  useEffect(() => {
    if (isPlaying) {
      mPlayer.current.destroy();
    }
    mPlayer.current = new Player(songs[songIndex].url)
    mPlayer.current.play(() => {
      console.log(mPlayer.current.state);
      if (mPlayer.current.state === 4) {
        setIsPlaying(true);
      } else {
        setIsPlaying(false);
      }
    });
   
  }, [songIndex]);

It works perfect in ios

@laijackylai
Copy link

same problem here, on android after the initial player is destroyed, it took ages for the new player to load or refuses to load at all. works fine on ios though. any work around for this problem? thank you

@ShivamJoker
Copy link
Author

@laijackylai
Copy link

oh icic, cuz i want to play multiple tracks in my app as well and react-native-track-player cant do that while this library can. and the problem im currently having is that i cant load the second audio url

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

2 participants