> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fastpix.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fastpix.com/docs/_mcp/server.

# Play a playlist

> Play a list of videos in order in the FastPix Android Player with setPlaylist, next and previous navigation, playlist editing, and PlaylistListener callbacks.

Play a list of videos in order in the FastPix Android Player.

Give the player a list and it plays the entries in order, moving on by itself when one finishes. If `loop` is on, the current entry repeats instead of advancing.

\


## Set a playlist

Call `setPlaylist` with a list of `PlaylistItem` values and an optional `startIndex`. You can build entries from a playback ID, from a signed playback ID and token, from any `setFastPixMediaItem` options, or from a direct URL.

```kotlin
player.setPlaylist(
    listOf(
        PlaylistItem.fastPix("playback-id-1"),
        PlaylistItem.fastPix("playback-id-2", playbackToken = token),   // signed playback
        PlaylistItem.fastPix {                                          // any setFastPixMediaItem option
            playbackId = "playback-id-3"
            maxResolution = PlaybackResolution.HD_720
        },
        PlaylistItem.fromUrl("https://example.com/video.m3u8"),
    ),
    startIndex = 0,
)
```

\


## Navigate the playlist

Move through the list with `next`, `previous`, and `skipTo`. `next` returns `false` at the last entry and `previous` returns `false` at the first entry, so you can use the return value to drive your own button states.

```kotlin
player.next()            // false at the last entry
player.previous()        // false at the first entry
player.skipTo(3)
```

\


## Edit the playlist

Add, insert, remove, or clear entries at runtime. Appending is how you extend an endless feed as more videos load.

```kotlin
player.addToPlaylist(moreItems)          // append, e.g. the next page of an endless feed
player.addToPlaylist(1, listOf(item))    // insert
player.removeFromPlaylist(2)
player.clearPlaylist()
```

Editing keeps the current entry playing unless it is the one removed.

\


## Inspect the playlist

Read the current state of the list and where playback sits within it.

```kotlin
player.getPlaylist(); player.getCurrentIndex(); player.getCurrentItem()
player.hasNext(); player.hasPrevious()
```

\


## Track playlist changes

Add a `PlaylistListener` to know when the current entry changes and when the list itself changes. The `onPlaylistItemChanged` callback reports why the entry changed through a `PlaylistItemChangeReason`.

```kotlin
player.addPlaylistListener(object : PlaylistListener {
    override fun onPlaylistItemChanged(index: Int, item: PlaylistItem, reason: PlaylistItemChangeReason) {
        // reason: PLAYLIST_SET, NAVIGATION, AUTO_ADVANCE or PLAYLIST_EDITED
    }
    override fun onPlaylistChanged(items: List<PlaylistItem>) { }
})
```

The `reason` values tell you what triggered the change:

* `PLAYLIST_SET`: a new playlist was set with `setPlaylist`.
* `NAVIGATION`: you called `next`, `previous`, or `skipTo`.
* `AUTO_ADVANCE`: the current entry finished and the player moved on by itself.
* `PLAYLIST_EDITED`: the list was edited and the current entry moved to a new index.

\


## Single items and deprecated APIs

`setMediaItem` and `setFastPixMediaItem` still play a single item and clear any playlist. `setMediaItems` is deprecated and now forwards to `setPlaylist`, so prefer `setPlaylist` for new code.

\


#### Frequently asked questions

Call `player.setPlaylist(items, startIndex = 0)` with a list of `PlaylistItem` values. Build each entry with `PlaylistItem.fastPix("playback-id")`, `PlaylistItem.fastPix("playback-id", playbackToken = token)` for signed playback, a `PlaylistItem.fastPix { ... }` block for full media-item options, or `PlaylistItem.fromUrl(url)` for a direct URL. The player plays the entries in order and advances by itself when one finishes.

Add a `PlaylistListener` and implement `onPlaylistItemChanged(index, item, reason)`. The `reason` is `AUTO_ADVANCE` when the current entry finished and the player moved on by itself, `NAVIGATION` when you called `next`, `previous`, or `skipTo`, `PLAYLIST_SET` when a new list was set, and `PLAYLIST_EDITED` when an edit moved the current entry to a new index.

No. Editing the playlist keeps the current entry playing unless it is the one removed. Use `addToPlaylist(items)` to append, for example the next page of an endless feed, `addToPlaylist(index, items)` to insert, `removeFromPlaylist(index)` to remove, and `clearPlaylist()` to empty the list.

`setMediaItem` and `setFastPixMediaItem` play a single item and clear any playlist. `setMediaItems` is deprecated and forwards to `setPlaylist`, so use `setPlaylist` for lists of videos.

\


## What's next

* [Build video feeds](/android-player/build-video-feeds) with reels, carousels, and multi-video screens.
* [Preload and cache for faster startup](/android-player/preload-and-cache-for-faster-startup) so upcoming entries start sooner.