Playlist in React-Native

Mehmet Ali Yılgın
2 min readApr 30, 2022

The codes here are for react-native expo. Libraries used: “expo-av”.

Audio from expo-av
React States

This codes are unload audio, replay audio, play audio, pause audio, load audio, next audio and previous audio.

All of the functions

If you want the song in the playlist to play when you first enter the page:

Component Did Mount Process

You should make an animated transition back and forth by checking the index of the list in the playlist. That’s what the playlist is all about. If you get too confused, you can definitely use the link here for flatlist editing (Gallery Flatlist Animation ): https://www.youtube.com/watch?v=gjC2oUJhePE

Finally, this flatlist editing step, all you have to do is add a function to switch to the previous and next audio in the list. It will also have code similar to this:

thumbRef area is in bottom side. topRef area is on top side. The average view of the code you have coded the design of will be as follows.

My Playlist

Good luck everyone. Playlist writing is actually quite easy. I need to tell you a point that you should pay attention to. The sound does not stop when you exit the page. So don’t forget to stop the sound before leaving the page!

If you have any questions, you can contact me: mehmetaliyilgin.com

--

--