Play a playlist
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.
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.
Edit the playlist
Add, insert, remove, or clear entries at runtime. Appending is how you extend an endless feed as more videos load.
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.
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.
The reason values tell you what triggered the change:
PLAYLIST_SET: a new playlist was set withsetPlaylist.NAVIGATION: you callednext,previous, orskipTo.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
How do I play a list of videos?
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.
How do I know when the playlist advances?
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.
Does adding items interrupt playback?
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.
What happens to a playlist when I set a single item?
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 with reels, carousels, and multi-video screens.
- Preload and cache for faster startup so upcoming entries start sooner.