# Playlist & Queue

ByteArk Player SDK for Android supports continuous playback through both playlists (pre-defined item lists) and queues (lists you can add to / remove from at runtime).

# Playlist

Build a playlist using ByteArkPlaylistBuilder:

val item1 = ByteArkPlayerItemBuilder.Builder()
  .withMediaId("1")
  .withTitle("Episode 1")
  .withUrl("https://example.com/ep1/playlist.m3u8")
  .build()
val item2 = ByteArkPlayerItemBuilder.Builder()
  .withMediaId("2")
  .withTitle("Episode 2")
  .withUrl("https://example.com/ep2/playlist.m3u8")
  .build()
val playlist = ByteArkPlaylistBuilder.Builder()
  .withMediaId("playlist-1")
  .withTitle("Season 1")
  .withContentList(listOf(item1, item2))
  .build()
mPlayerFragment.openPlaylist(playlist)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

# Control playlist

mPlayerFragment.next()       // Next item
mPlayerFragment.previous()   // Previous item
val currentPlaylist = mPlayerFragment.getPlaylist()
1
2
3
4

# Queue

The queue lets you add or remove items at runtime:

mPlayerFragment.addItemToQueue(item)
mPlayerFragment.removeQueueItem(item)
mPlayerFragment.selectQueueItem(item)
val queue: List<ByteArkPlayerItem> = mPlayerFragment.getCurrentQueue()
1
2
3
4
5

# Receive item-change events

override fun onPlayerItemChange(
  updatePlayerItem: ByteArkPlayerItem,
  isPlaylist: Boolean,
  isQueue: Boolean,
  index: Int
) {
  // Changed to a new item
}
1
2
3
4
5
6
7
8