Build a custom quality selector
The FastPix Player exposes a JavaScript API for reading and switching video quality levels, which lets you build a branded quality selector that gives viewers explicit resolution control while preserving adaptive bitrate (ABR) fallback for unstable networks. Combine the quality methods with slot-based overlays to position your custom UI directly over the video without managing absolute positioning yourself.
Key terms
- Rendition is one resolution/bitrate variant in the HLS manifest that FastPix generates during transcoding (for example, 360p at 800 kbps, 720p at 2.5 Mbps).
- Adaptive Bitrate Streaming (ABR) is the default mode where the player switches renditions automatically based on the viewer’s network speed.
playbackIdis the access-controlled identifier FastPix assigns for constructing the HLS playback URL:https://stream.fastpix.com/{PLAYBACK_ID}.m3u8.
Retrieve available quality levels
Call player.getQualityLevels() after the manifest loads to get the full rendition ladder.
Each entry contains:
NOTE
The array is empty for audio-only streams or single-rendition videos. Wait for the
fastpixqualitylevelsreadyevent before calling this method on a new video.
Lock playback to a specific resolution
Call player.setQualityLevel(id) to disable ABR and force the player to use one rendition.
The id value comes from a getQualityLevels() entry. Do not hard-code IDs across videos — each manifest generates its own ID set.
Re-enable adaptive bitrate
Call player.setQualityAuto() to hand control back to the ABR engine. The player resumes switching renditions based on network conditions.
Use this when the viewer selects “Auto” in your menu, or as a fallback after a quality error.
Read the current quality state
Call player.getPlaybackQuality() to get a snapshot of the player’s current quality mode and active rendition.
NOTE
loadedLevelreflects what is actually on screen. Under ABR, it can differ fromlockedLevelbriefly during a rendition switch.
Listen for quality events
The player triggers three custom events on the <fastpix-player> element. Listen with addEventListener.
fastpixqualitylevelsready
Triggers when the HLS manifest is parsed and quality levels are available. Also triggers again if a new video loads.
event.detail contains:
fastpixqualitychange
Triggers whenever the quality state changes, either from a viewer action (setQualityLevel / setQualityAuto) or from ABR switching renditions automatically.
event.detail contains:
fastpixqualityfailed
Triggers when a quality change fails — either when an invalid ID is passed to setQualityLevel(), or when a specific rendition fails to load from the network.
event.detail contains:
Build the full example
A complete, working quality selector combining every API and event described in this guide. The example uses slot overlays to position the menu in the top-right corner of the video. Copy the HTML below, replace your-playback-id with a real playbackId, and open it in a browser.
What each section does
Understand the typical flow
- Page loads →
<fastpix-player>is created - Video manifest loads →
fastpixqualitylevelsreadytriggers - Your code calls
getQualityLevels()and builds quality buttons - Viewer clicks “720p” → your code calls
setQualityLevel(id) - Player switches rendition →
fastpixqualitychangetriggers - Your code calls
getPlaybackQuality()and highlights the active button - Viewer clicks “Auto” → your code calls
setQualityAuto() fastpixqualitychangetriggers again → UI updates
Quick reference
Frequently asked questions
Do quality level IDs stay the same across different videos?
No. Each video’s HLS manifest generates its own rendition ladder with unique IDs. Always call getQualityLevels() after fastpixqualitylevelsready triggers for the current video. Do not cache IDs from one video and reuse them on another.
What happens if the video has only one rendition?
getQualityLevels() returns an empty array. The player uses the single available rendition and ABR has no alternatives to switch between. Hide or disable your quality menu in this case.
Can I set a default quality lock before the video starts?
Listen for fastpixqualitylevelsready, find the rendition you want by label or height, and call setQualityLevel(id) immediately. The player applies the lock before the first segment plays at the ABR-selected level.
How do I show the currently active quality in the menu without polling?
Listen for fastpixqualitychange — it triggers on every ABR switch and every manual selection. Call getPlaybackQuality() inside the handler and update your UI. No polling or timers are needed.