Switch video quality

Let viewers lock a fixed video quality or return to adaptive bitrate (ABR) auto mode in the FastPix Android Player.

By default, the FastPix Android Player streams adaptively (ABR), choosing a rendition based on network conditions. Use these APIs, which are available on FastPixPlayer, to let users pick a fixed quality, such as 1080p, or switch back to auto. Quality switching doesn’t recreate the player or reset the playback position.


Before you begin

Make sure you have the following:

Get the FastPixPlayer instance from your PlayerView:

1val player = binding.playerView.player as? FastPixPlayer ?: return

Get available and current qualities

1// All available video quality tracks for current media
2val qualities: List<VideoTrack> = player.getVideoQualities()
3
4// Current active quality (in auto mode this reflects currently rendered quality)
5val current: VideoTrack? = player.getCurrentVideoQuality()

Each VideoTrack exposes id, width, height, bitrate, label, isSelected, and isAuto. Use id when you call setVideoQuality.


Lock a fixed quality

Pass a quality id from getVideoQualities() to lock playback to that rendition.

1// Pick a quality id from getVideoQualities()
2player.setVideoQuality(trackId)

Return to auto (ABR)

1player.enableAutoQuality()

Listen for quality changes

The onVideoQualityChanged callback tells you both the new quality and whether the change came from a user action or the SDK’s automatic ABR switching.

1player.addPlaybackListener(object : PlaybackListener {
2 override fun onVideoQualityChanged(
3 quality: VideoTrack?,
4 source: PlaybackListener.VideoQualityChangeSource
5 ) {
6 // source = MANUAL when you call setVideoQuality/enableAutoQuality
7 // source = ABR when SDK switches rendition automatically
8 updateQualityUi(quality, source)
9 }
10 override fun onPlay() {}
11 override fun onPause() {}
12 override fun onPlaybackStateChanged(isPlaying: Boolean) {}
13 override fun onError(error: PlaybackException) {}
14})

Things to know

  • Quality switching doesn’t recreate the player or reset the playback position.
  • If a seek is in progress, the quality change is applied safely after the seek completes.
  • Keep an Auto option in your quality menu that calls enableAutoQuality(), so viewers can return to adaptive bitrate.

Frequently asked questions

What's the difference between setting a resolution and switching quality at runtime?

Setting a resolution with setFastPixMediaItem (maxResolution, minResolution, resolution) configures playback before it starts. The quality-switching APIs on this page (getVideoQualities, setVideoQuality, enableAutoQuality) let a viewer change quality during playback without reloading the stream.

Does switching quality restart the video?

No. Quality switching doesn’t recreate the player or reset the playback position. If a seek is in progress, the change is applied after the seek completes.

How do I know whether a change was manual or automatic?

The onVideoQualityChanged callback includes a source. It’s MANUAL when you call setVideoQuality or enableAutoQuality, and ABR when the SDK switches renditions automatically based on the network.

How do I let users return to adaptive bitrate?

Include an Auto entry in your quality menu that calls enableAutoQuality(). This re-enables ABR so the SDK selects the rendition automatically.


What’s next