DefaultRenderersFactory


@UnstableApi
class DefaultRenderersFactory : RenderersFactory


Default RenderersFactory implementation.

Summary

Nested types

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
annotation DefaultRenderersFactory.ExtensionRendererMode

Modes for using extension renderers.

Constants

const Long

The default maximum duration for which a video renderer can attempt to seamlessly join an ongoing playback.

const Int

Do not allow use of extension renderers.

const Int

Allow use of extension renderers.

const Int

Allow use of extension renderers.

const Int

The maximum number of frames that can be dropped between invocations of onDroppedFrames.

Public constructors

Public functions

Array<Renderer!>!
createRenderers(
    eventHandler: Handler!,
    videoRendererEventListener: VideoRendererEventListener!,
    audioRendererEventListener: AudioRendererEventListener!,
    textRendererOutput: TextOutput!,
    metadataRendererOutput: MetadataOutput!
)

Builds the Renderer instances for an ExoPlayer.

DefaultRenderersFactory!

Sets whether to enable CONFIGURE_FLAG_USE_CRYPTO_ASYNC on API 34 and above when operating the codec in asynchronous mode.

DefaultRenderersFactory!

Disables androidx.media3.exoplayer.mediacodec.MediaCodecRenderer instances from operating their MediaCodec in asynchronous mode and perform asynchronous queueing.

DefaultRenderersFactory!

Enables androidx.media3.exoplayer.mediacodec.MediaCodecRenderer instances to operate their MediaCodec in asynchronous mode and perform asynchronous queueing.

DefaultRenderersFactory!

Sets the maximum duration for which video renderers can attempt to seamlessly join an ongoing playback.

DefaultRenderersFactory!

Sets whether floating point audio should be output when possible.

DefaultRenderersFactory!
@CanIgnoreReturnValue
setEnableAudioTrackPlaybackParams(
    enableAudioTrackPlaybackParams: Boolean
)

Sets whether to enable setting playback speed using setPlaybackParams, which is supported from API level 23, rather than using application-level audio speed adjustment.

DefaultRenderersFactory!

Sets whether to enable fallback to lower-priority decoders if decoder initialization fails.

DefaultRenderersFactory!

Sets the extension renderer mode, which determines if and how available extension renderers are used.

DefaultRenderersFactory!

Sets a MediaCodecSelector for use by MediaCodec based renderers.

Protected functions

Unit
buildAudioRenderers(
    context: Context!,
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int,
    mediaCodecSelector: MediaCodecSelector!,
    enableDecoderFallback: Boolean,
    audioSink: AudioSink!,
    eventHandler: Handler!,
    eventListener: AudioRendererEventListener!,
    out: ArrayList<Renderer!>!
)

Builds audio renderers for use by the player.

AudioSink?
buildAudioSink(
    context: Context!,
    enableFloatOutput: Boolean,
    enableAudioTrackPlaybackParams: Boolean
)

Builds an AudioSink to which the audio renderers will output.

Unit
buildCameraMotionRenderers(
    context: Context!,
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int,
    out: ArrayList<Renderer!>!
)

Builds camera motion renderers for use by the player.

Unit

Builds image renderers for use by the player.

Unit
buildMetadataRenderers(
    context: Context!,
    output: MetadataOutput!,
    outputLooper: Looper!,
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int,
    out: ArrayList<Renderer!>!
)

Builds metadata renderers for use by the player.

Unit
buildMiscellaneousRenderers(
    context: Context!,
    eventHandler: Handler!,
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int,
    out: ArrayList<Renderer!>!
)

Builds any miscellaneous renderers used by the player.

Unit
buildTextRenderers(
    context: Context!,
    output: TextOutput!,
    outputLooper: Looper!,
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int,
    out: ArrayList<Renderer!>!
)

Builds text renderers for use by the player.

Unit
buildVideoRenderers(
    context: Context!,
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int,
    mediaCodecSelector: MediaCodecSelector!,
    enableDecoderFallback: Boolean,
    eventHandler: Handler!,
    eventListener: VideoRendererEventListener!,
    allowedVideoJoiningTimeMs: Long,
    out: ArrayList<Renderer!>!
)

Builds video renderers for use by the player.

MediaCodecAdapter.Factory!

Returns the MediaCodecAdapter.Factory that will be used when creating instances.

ImageDecoder.Factory!

Returns the ImageDecoder.Factory used to build the image renderer.

Constants

DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS

const val DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS = 5000: Long

The default maximum duration for which a video renderer can attempt to seamlessly join an ongoing playback.

EXTENSION_RENDERER_MODE_OFF

const val EXTENSION_RENDERER_MODE_OFF = 0: Int

Do not allow use of extension renderers.

EXTENSION_RENDERER_MODE_ON

const val EXTENSION_RENDERER_MODE_ON = 1: Int

Allow use of extension renderers. Extension renderers are indexed after core renderers of the same type. A TrackSelector that prefers the first suitable renderer will therefore prefer to use a core renderer to an extension renderer in the case that both are able to play a given track.

EXTENSION_RENDERER_MODE_PREFER

const val EXTENSION_RENDERER_MODE_PREFER = 2: Int

Allow use of extension renderers. Extension renderers are indexed before core renderers of the same type. A TrackSelector that prefers the first suitable renderer will therefore prefer to use an extension renderer to a core renderer in the case that both are able to play a given track.

MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY

const val MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY = 50: Int

The maximum number of frames that can be dropped between invocations of onDroppedFrames.

Public constructors

DefaultRenderersFactory

DefaultRenderersFactory(context: Context!)
Parameters
context: Context!

A Context.

Public functions

createRenderers

fun createRenderers(
    eventHandler: Handler!,
    videoRendererEventListener: VideoRendererEventListener!,
    audioRendererEventListener: AudioRendererEventListener!,
    textRendererOutput: TextOutput!,
    metadataRendererOutput: MetadataOutput!
): Array<Renderer!>!

Builds the Renderer instances for an ExoPlayer.

Parameters
eventHandler: Handler!

A handler to use when invoking event listeners and outputs.

videoRendererEventListener: VideoRendererEventListener!

An event listener for video renderers.

audioRendererEventListener: AudioRendererEventListener!

An event listener for audio renderers.

textRendererOutput: TextOutput!

An output for text renderers.

metadataRendererOutput: MetadataOutput!

An output for metadata renderers.

Returns
Array<Renderer!>!

The instances.

experimentalSetMediaCodecAsyncCryptoFlagEnabled

@CanIgnoreReturnValue
fun experimentalSetMediaCodecAsyncCryptoFlagEnabled(
    enableAsyncCryptoFlag: Boolean
): DefaultRenderersFactory!

Sets whether to enable CONFIGURE_FLAG_USE_CRYPTO_ASYNC on API 34 and above when operating the codec in asynchronous mode.

This method is experimental. Its default value may change, or it may be renamed or removed in a future release.

forceDisableMediaCodecAsynchronousQueueing

@CanIgnoreReturnValue
fun forceDisableMediaCodecAsynchronousQueueing(): DefaultRenderersFactory!

Disables androidx.media3.exoplayer.mediacodec.MediaCodecRenderer instances from operating their MediaCodec in asynchronous mode and perform asynchronous queueing. MediaCodec instances will be operated synchronous mode.

Returns
DefaultRenderersFactory!

This factory, for convenience.

forceEnableMediaCodecAsynchronousQueueing

@CanIgnoreReturnValue
fun forceEnableMediaCodecAsynchronousQueueing(): DefaultRenderersFactory!

Enables androidx.media3.exoplayer.mediacodec.MediaCodecRenderer instances to operate their MediaCodec in asynchronous mode and perform asynchronous queueing.

This feature can be enabled only on devices with API versions >= 23. For devices with older API versions, this method is a no-op.

Returns
DefaultRenderersFactory!

This factory, for convenience.

setAllowedVideoJoiningTimeMs

@CanIgnoreReturnValue
fun setAllowedVideoJoiningTimeMs(allowedVideoJoiningTimeMs: Long): DefaultRenderersFactory!

Sets the maximum duration for which video renderers can attempt to seamlessly join an ongoing playback.

The default value is DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS.

Parameters
allowedVideoJoiningTimeMs: Long

The maximum duration for which video renderers can attempt to seamlessly join an ongoing playback, in milliseconds.

Returns
DefaultRenderersFactory!

This factory, for convenience.

setEnableAudioFloatOutput

@CanIgnoreReturnValue
fun setEnableAudioFloatOutput(enableFloatOutput: Boolean): DefaultRenderersFactory!

Sets whether floating point audio should be output when possible.

Enabling floating point output disables audio processing, but may allow for higher quality audio output.

The default value is false.

Parameters
enableFloatOutput: Boolean

Whether to enable use of floating point audio output, if available.

Returns
DefaultRenderersFactory!

This factory, for convenience.

setEnableAudioTrackPlaybackParams

@CanIgnoreReturnValue
fun setEnableAudioTrackPlaybackParams(
    enableAudioTrackPlaybackParams: Boolean
): DefaultRenderersFactory!

Sets whether to enable setting playback speed using setPlaybackParams, which is supported from API level 23, rather than using application-level audio speed adjustment. This setting has no effect on builds before API level 23 (application-level speed adjustment will be used in all cases).

If enabled and supported, new playback speed settings will take effect more quickly because they are applied at the audio mixer, rather than at the point of writing data to the track.

When using this mode, the maximum supported playback speed is limited by the size of the audio track's buffer. If the requested speed is not supported the player's event listener will be notified twice on setting playback speed, once with the requested speed, then again with the old playback speed reflecting the fact that the requested speed was not supported.

Parameters
enableAudioTrackPlaybackParams: Boolean

Whether to enable setting playback speed using setPlaybackParams.

Returns
DefaultRenderersFactory!

This factory, for convenience.

setEnableDecoderFallback

@CanIgnoreReturnValue
fun setEnableDecoderFallback(enableDecoderFallback: Boolean): DefaultRenderersFactory!

Sets whether to enable fallback to lower-priority decoders if decoder initialization fails. This may result in using a decoder that is less efficient or slower than the primary decoder.

Parameters
enableDecoderFallback: Boolean

Whether to enable fallback to lower-priority decoders if decoder initialization fails.

Returns
DefaultRenderersFactory!

This factory, for convenience.

setExtensionRendererMode

@CanIgnoreReturnValue
fun setExtensionRendererMode(
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int
): DefaultRenderersFactory!

Sets the extension renderer mode, which determines if and how available extension renderers are used. Note that extensions must be included in the application build for them to be considered available.

The default value is EXTENSION_RENDERER_MODE_OFF.

Parameters
@DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int

The extension renderer mode.

Returns
DefaultRenderersFactory!

This factory, for convenience.

setMediaCodecSelector

@CanIgnoreReturnValue
fun setMediaCodecSelector(mediaCodecSelector: MediaCodecSelector!): DefaultRenderersFactory!

Sets a MediaCodecSelector for use by MediaCodec based renderers.

The default value is DEFAULT.

Parameters
mediaCodecSelector: MediaCodecSelector!

The MediaCodecSelector.

Returns
DefaultRenderersFactory!

This factory, for convenience.

Protected functions

buildAudioRenderers

protected fun buildAudioRenderers(
    context: Context!,
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int,
    mediaCodecSelector: MediaCodecSelector!,
    enableDecoderFallback: Boolean,
    audioSink: AudioSink!,
    eventHandler: Handler!,
    eventListener: AudioRendererEventListener!,
    out: ArrayList<Renderer!>!
): Unit

Builds audio renderers for use by the player.

Parameters
context: Context!

The Context associated with the player.

@DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int

The extension renderer mode.

mediaCodecSelector: MediaCodecSelector!

A decoder selector.

enableDecoderFallback: Boolean

Whether to enable fallback to lower-priority decoders if decoder initialization fails. This may result in using a decoder that is slower/less efficient than the primary decoder.

audioSink: AudioSink!

A sink to which the renderers will output.

eventHandler: Handler!

A handler to use when invoking event listeners and outputs.

eventListener: AudioRendererEventListener!

An event listener.

out: ArrayList<Renderer!>!

An array to which the built renderers should be appended.

buildAudioSink

protected fun buildAudioSink(
    context: Context!,
    enableFloatOutput: Boolean,
    enableAudioTrackPlaybackParams: Boolean
): AudioSink?

Builds an AudioSink to which the audio renderers will output.

Parameters
context: Context!

The Context associated with the player.

enableFloatOutput: Boolean

Whether to enable use of floating point audio output, if available.

enableAudioTrackPlaybackParams: Boolean

Whether to enable setting playback speed using setPlaybackParams, if supported.

Returns
AudioSink?

The AudioSink to which the audio renderers will output. May be null if no audio renderers are required. If null is returned then buildAudioRenderers will not be called.

buildCameraMotionRenderers

protected fun buildCameraMotionRenderers(
    context: Context!,
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int,
    out: ArrayList<Renderer!>!
): Unit

Builds camera motion renderers for use by the player.

Parameters
context: Context!

The Context associated with the player.

@DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int

The extension renderer mode.

out: ArrayList<Renderer!>!

An array to which the built renderers should be appended.

buildImageRenderers

protected fun buildImageRenderers(out: ArrayList<Renderer!>!): Unit

Builds image renderers for use by the player.

The ImageRenderer is built with ImageOutput set to null and set to ImageDecoder.Factory.DEFAULT by default.

Parameters
out: ArrayList<Renderer!>!

An array to which the built renderers should be appended.

buildMetadataRenderers

protected fun buildMetadataRenderers(
    context: Context!,
    output: MetadataOutput!,
    outputLooper: Looper!,
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int,
    out: ArrayList<Renderer!>!
): Unit

Builds metadata renderers for use by the player.

Parameters
context: Context!

The Context associated with the player.

output: MetadataOutput!

An output for the renderers.

outputLooper: Looper!

The looper associated with the thread on which the output should be called.

@DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int

The extension renderer mode.

out: ArrayList<Renderer!>!

An array to which the built renderers should be appended.

buildMiscellaneousRenderers

protected fun buildMiscellaneousRenderers(
    context: Context!,
    eventHandler: Handler!,
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int,
    out: ArrayList<Renderer!>!
): Unit

Builds any miscellaneous renderers used by the player.

Parameters
context: Context!

The Context associated with the player.

eventHandler: Handler!

A handler to use when invoking event listeners and outputs.

@DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int

The extension renderer mode.

out: ArrayList<Renderer!>!

An array to which the built renderers should be appended.

buildTextRenderers

protected fun buildTextRenderers(
    context: Context!,
    output: TextOutput!,
    outputLooper: Looper!,
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int,
    out: ArrayList<Renderer!>!
): Unit

Builds text renderers for use by the player.

Parameters
context: Context!

The Context associated with the player.

output: TextOutput!

An output for the renderers.

outputLooper: Looper!

The looper associated with the thread on which the output should be called.

@DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int

The extension renderer mode.

out: ArrayList<Renderer!>!

An array to which the built renderers should be appended.

buildVideoRenderers

protected fun buildVideoRenderers(
    context: Context!,
    @DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int,
    mediaCodecSelector: MediaCodecSelector!,
    enableDecoderFallback: Boolean,
    eventHandler: Handler!,
    eventListener: VideoRendererEventListener!,
    allowedVideoJoiningTimeMs: Long,
    out: ArrayList<Renderer!>!
): Unit

Builds video renderers for use by the player.

Parameters
context: Context!

The Context associated with the player.

@DefaultRenderersFactory.ExtensionRendererMode extensionRendererMode: Int

The extension renderer mode.

mediaCodecSelector: MediaCodecSelector!

A decoder selector.

enableDecoderFallback: Boolean

Whether to enable fallback to lower-priority decoders if decoder initialization fails. This may result in using a decoder that is slower/less efficient than the primary decoder.

eventHandler: Handler!

A handler associated with the main thread's looper.

eventListener: VideoRendererEventListener!

An event listener.

allowedVideoJoiningTimeMs: Long

The maximum duration for which video renderers can attempt to seamlessly join an ongoing playback, in milliseconds.

out: ArrayList<Renderer!>!

An array to which the built renderers should be appended.

getCodecAdapterFactory

protected fun getCodecAdapterFactory(): MediaCodecAdapter.Factory!

Returns the MediaCodecAdapter.Factory that will be used when creating instances.

getImageDecoderFactory

protected fun getImageDecoderFactory(): ImageDecoder.Factory!

Returns the ImageDecoder.Factory used to build the image renderer.