public final class

CompositionPlayer.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.transformer.CompositionPlayer.Builder

Overview

A builder for CompositionPlayer instances.

Summary

Constructors
publicBuilder(Context context)

Creates an instance

Methods
public CompositionPlayerbuild()

Builds the CompositionPlayer instance.

public CompositionPlayer.BuildersetAudioSink(AudioSink audioSink)

Sets the AudioSink that will be used to play out audio.

public CompositionPlayer.BuildersetClock(Clock clock)

Sets the Clock that will be used by the player.

public CompositionPlayer.BuildersetExternalImageLoader(ExternalLoader externalImageLoader)

Sets the ExternalLoader for loading image media items with MIME type set to MimeTypes.APPLICATION_EXTERNALLY_LOADED_IMAGE.

public CompositionPlayer.BuildersetImageDecoderFactory(ImageDecoder.Factory imageDecoderFactory)

Sets an that will create the ImageDecoder instances to decode images.

public CompositionPlayer.BuildersetLooper(Looper looper)

Sets the from which the player can be accessed and callbacks are dispatched too.

public CompositionPlayer.BuildersetPreviewingVideoGraphFactory(PreviewingVideoGraph.Factory previewingVideoGraphFactory)

Sets the that will be used by the player.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(Context context)

Creates an instance

Parameters:

context: The application context.

Methods

public CompositionPlayer.Builder setLooper(Looper looper)

Sets the from which the player can be accessed and callbacks are dispatched too.

By default, the builder uses the looper of the thread that calls CompositionPlayer.Builder.build().

Parameters:

looper: The .

Returns:

This builder, for convenience.

public CompositionPlayer.Builder setAudioSink(AudioSink audioSink)

Sets the AudioSink that will be used to play out audio.

By default, a DefaultAudioSink with its default configuration is used.

Parameters:

audioSink: The AudioSink.

Returns:

This builder, for convenience.

public CompositionPlayer.Builder setExternalImageLoader(ExternalLoader externalImageLoader)

Sets the ExternalLoader for loading image media items with MIME type set to MimeTypes.APPLICATION_EXTERNALLY_LOADED_IMAGE. When setting an external loader, also set an with CompositionPlayer.Builder.setImageDecoderFactory(ImageDecoder.Factory).

By default, the player will not be able to load images with media type of MimeTypes.APPLICATION_EXTERNALLY_LOADED_IMAGE.

Parameters:

externalImageLoader: The ExternalLoader.

Returns:

This builder, for convenience.

See also: DefaultMediaSourceFactory.setExternalImageLoader(ExternalLoader)

public CompositionPlayer.Builder setImageDecoderFactory(ImageDecoder.Factory imageDecoderFactory)

Sets an that will create the ImageDecoder instances to decode images.

By default, is used.

Parameters:

imageDecoderFactory: The .

Returns:

This builder, for convenience.

public CompositionPlayer.Builder setClock(Clock clock)

Sets the Clock that will be used by the player.

By default, Clock.DEFAULT is used.

Parameters:

clock: The Clock.

Returns:

This builder, for convenience.

public CompositionPlayer.Builder setPreviewingVideoGraphFactory(PreviewingVideoGraph.Factory previewingVideoGraphFactory)

Sets the that will be used by the player.

By default, a is used.

Parameters:

previewingVideoGraphFactory: The .

Returns:

This builder, for convenience.

public CompositionPlayer build()

Builds the CompositionPlayer instance. Must be called at most once.

If no has been called with CompositionPlayer.Builder.setLooper(Looper), then this method must be called within a thread which is the thread that can access the player instance and where callbacks are dispatched.