0

I have many playlists, I want to change the current playlist with new playlist which user choose it. i tried using Trackplayer.reset() but the application stopped.

const setupPlayer = async () => {
    TrackPlayer.setupPlayer({waitForBuffer: true}).then(async () => {
      await TrackPlayer.add(songs);
      await TrackPlayer.play();
      await TrackPlayer.updateOptions({
        capabilities: [
          Capability.Play,
          Capability.Pause,
          Capability.SkipToNext,
          Capability.Stop,
          Capability.SkipToPrevious,
        ],
        compactCapabilities: [Capability.Play, Capability.Pause],
      });
    });
useEffect(() => {
    setupPlayer();
    scrollX.addListener(({value}) => {
      const index = Math.round(value / width);
      skipTo(index);
      setSongIndex(index);
    });
    return () => {
      scrollX.removeAllListeners();
      TrackPlayer.reset();
    };
  }, []);

I have tried this.

0 Answers0