Configures the playback behaviour of the player.

Platform

Android

interface DecoderConfig {
    decoderPriorityProvider?: null | DecoderPriorityProvider;
    nativeId?: string;
}

Hierarchy

  • NativeInstanceConfig
    • DecoderConfig

Properties

decoderPriorityProvider?: null | DecoderPriorityProvider

A callback interface for sorting and filtering decoders based on priority.

This callback is invoked when the player selects a decoder, providing the DecoderContext and a list of available MediaCodecInfo objects. The list is initially ordered by the default priority in which decoders will be attempted.

The callback should return a reordered or filtered list of MediaCodecInfo objects that determines the selection priority.

Example Usage

Prefer a specific decoder for main content video playback

The following example prioritizes a specific decoder for non-ad video playback:

const decoderPriorityProvider: DecoderPriorityProvider = {
overrideDecodersPriority: (context: DecoderContext, preferredDecoders: MediaCodecInfo[]): MediaCodecInfo[] => {
if (!context.isAd && context.mediaType === DecoderContextMediaType.VIDEO) {
// Prioritize a specific decoder
return preferredDecoders.sort((a, b) => {
const aAsNumber = a.name.startsWith("OMX.google.") ? 1 : 2
const bAsNumber = b.name.startsWith("OMX.google.") ? 1 : 2
return aAsNumber - bAsNumber
})
}
return preferredDecoders
}
}

Prefer software decoders for ads playback

The following example prioritizes software decoders over hardware decoders for ad playback:

const decoderPriorityProvider: DecoderPriorityProvider = {
overrideDecodersPriority: (context: DecoderContext, preferredDecoders: MediaCodecInfo[]): MediaCodecInfo[] => {
if (context.isAd) {
// Prioritize a specific decoder
return preferredDecoders.sort((a, b) => {
const aAsNumber = a.isSoftware ? 1 : 2
const bAsNumber = b.isSoftware ? 1 : 2
return aAsNumber - bAsNumber
})
}
return preferredDecoders
}
}

Disable software fallback for video playback

The following example disables software decoders for non-ad video playback:

const decoderPriorityProvider: DecoderPriorityProvider = {
overrideDecodersPriority: (context: DecoderContext, preferredDecoders: MediaCodecInfo[]): MediaCodecInfo[] => {
if (!context.isAd && context.mediaType === DecoderContextMediaType.VIDEO) {
// Prioritize a specific decoder
return preferredDecoders.filter((info) => {
return !info.isSoftware
})
}
return preferredDecoders
}
}
nativeId?: string

Optionally user-defined string id for the native instance. Used to access a certain native instance from any point in the source code then call methods/properties on it.

When left empty, a random UUIDv4 is generated for it.

Example

Accessing or creating the Player with nativeId equal to my-player:

const player = new Player({ nativeId: 'my-player' })
player.play(); // call methods and properties...