It’s simple…on recyclerview adapter click,
pass arraylist of songs and current clicked pos to service class, then from service class play current and as soon finished play next position
Like this :
OnClick {
service.playmusic(adapter. getsonglist(), current clicked pos)
}
and in service class you got arraylist and pos
so do this
List<song> playlist = new ArrayList<>();
playlist = songlist //this is from adpter click
Song song = playlist.get(position) // current position from clicked adapter.
finally set id or path in mediaplayer.set data source ();
prepare async or sync and play.
onCompletion check if playlist is finished or not if finished and have data then play next position.
Also, this playlist you can show as queue list in the playingScreen’s queueList .
Hope, this will clear your problem 🙂
1
solved Android: What is the best way for building a music player with songs queue?