I have a array of songs and I am mapping it on a FlatList
and onPress I am getting the song.id and using that to find specific song in the array and passing it into the TrackPlayer.add()
const songs= [{"artist": "Iglesias","id": "25erfs11","artwork": "https://27mi124bz6zg1hqy6n192jkb-wpengine.netdna-ssl.com/wp-content/uploads/2019/10/Our-Top-10-Songs-About-School-768x569.png","title": "Jola","url": "https://m4a-64.jango.com/21/38/46/2138460792780041793.m4a"},{"artist": "Version","id": "345asda5","artwork": "https://27mi124bz6zg1hqy6n192jkb-wpengine.netdna-ssl.com/wp-content/uploads/2019/10/Our-Top-10-Songs-About-School-768x569.png","title": "Bueno","url": "https://mp3-128.jango.com/music/20/30/33/2030339267.mp3"},{"artist": "Lando ","id": "16asasa12","artwork": "https://27mi124bz6zg1hqy6n192jkb-wpengine.netdna-ssl.com/wp-content/uploads/2019/10/Our-Top-10-Songs-About-School-768x569.png","title": "Paul","url": "https://mp3-128.jango.com/music/02/90/05/0290051433.mp3"},
];
and I am passing that into react-native-track-player like this:
const activeTrack = songs.find((track: Track) => track.id === song.id);TrackPlayer.add(activeTrack);
I am able to play different songs by clicking on FlatList
but doing it this way doesn't let me use TrackPlayer.skipToNext() or TrackPlayer.skipToPrevious() functionality. Can someone please suggest how can I use this functionality or a way to implement it on my own