Decoder Workarounds & Fallback Configurations

These configuration options can help reduce or avoid decoder-related playback issues.

Retry playback

Using the RetryPlaybackCallback it is possible to react to playback exceptions before they fail playback. By returning one of the available RetryPlaybackAction values the desired retry behaviour can be chosen.

💡

In order to retry playback without changing any configurations, RetryPlaybackAction.LimitBitrate with a high bitrate can be used.

val retryPlaybackConfig = RetryPlaybackConfig(
    retryPlaybackCallback = {
        val failedBitrate = it.playbackQuality?.bitrate!!
        RetryPlaybackAction.LimitBitrate(failedBitrate - 1)
    }
)

Codec Preference

A priorized list of preferred codecs can be defined for audio and video decoding in order to prefer more stable codecs.

val playbackConfig = PlaybackConfig(
    videoCodecPriority = listOf("avc", "vp9", "hevc", "av1")
    audioCodecPriority = listOf("mp4a.40", "ac-3", "ec-3")
}

Custom Decoder Ranking

The config can be used for sorting and filtering decoders based on priority. Use it to exclude decoders that are known to cause issues on certain devices and to prefer or fallback to software decoding.

val decoderConfig = DecoderConfig(
    decoderPriorityProvider = DecoderPriorityProvider { decoders ->
        decoders.sortedBy { info ->
            when {
                info.name.contains("av1", ignoreCase = true) -> 2
                info.name.contains("omx", ignoreCase = true) -> 1
                else -> 0
            }
        }
    }
)