Optional
decoderA 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.
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
}
}
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
}
}
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
}
}
Optional
nativeOptionally 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.
Accessing or creating the Player
with nativeId
equal to my-player
:
const player = new Player({ nativeId: 'my-player' })
player.play(); // call methods and properties...
Configures the playback behaviour of the player.
Platform
Android