On this page
Build a video playlist
Append videos and choose playlist behavior.
Before you begin: Control video playback.
Playlist and Append
Every attached player starts with a one-item playlist: the video passed to Frontbacked.video.attach(). appendVideo() adds more videos after the current list, so the player can move from one video to the next without rebuilding your own player UI.
Append one video:
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Append many videos:
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
appendVideo() accepts the same source shapes as Frontbacked.video.attach(): a stored file object, a media object, or a URL. Calling it multiple times keeps adding to the existing list.
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
Move through the playlist from JavaScript:
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
When appended videos exist, the standard player shows next and prev controls unless those controls are hidden. The next control appears when there is another retained video after the current one. The prev control appears when there is a retained video before the current one, or when older videos were evicted and your theme has provided a previous getter.
When a playlist move happens, the same video element is reused, playback starts from 0, and identical video sources are still treated as separate playlist entries. That means appending the same video twice creates two playable entries, while browser caching can still make the second load fast.
The next video is prepared near the end of the current video so playback can continue smoothly.
The player keeps up to 50 videos in its list. When more are appended, the oldest entries are evicted first. If your theme can fetch older entries, provide a previous getter:
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
setPrevGetter(callback) is called only when all of these are true:
- The user or theme calls
player.prev(), or the user clicks theprevcontrol. - The current playlist item is the first retained item in the local list.
- One or more older items were evicted because the playlist passed 50 items.
- A previous getter callback has been set.
If no previous getter is set, the prev control is hidden when the current video is the first retained item. In that case, the player does not try to fetch older videos; it simply stays on the first available playlist item.
The callback receives:
| Argument | Meaning |
|---|---|
evictedCount | Number of older playlist entries that were removed from the front of the local list. |
firstAvailable | Source object for the first video still retained in the playlist. Use it as a cursor when fetching older videos. |
player | The player instance, useful if your callback wants to inspect current state or pause while loading. |
Return one video, an array of videos, or nothing:
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
When the callback returns videos, Frontbacked inserts them before the first retained item, reduces evictedCount by the number returned, and plays the newest returned item. Returning an empty array, null, or undefined leaves the playlist unchanged.
Use player.list() when your theme needs the currently retained playlist sources:
Reference excerpt: use this with the page, variables and functions described in this guide. Try a complete example →
player.list() only returns the retained items, not entries that have already been evicted.
Continue with Respond to video events.