Class Transformer.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.transformer.Transformer.Builder
-
- Enclosing class:
- Transformer
public static final class Transformer.Builder extends Object
A builder forTransformerinstances.
-
-
Constructor Summary
Constructors Constructor Description Builder()Deprecated.UseBuilder(Context)instead.Builder(Context context)Creates a builder with default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Transformer.BuilderaddListener(Transformer.Listener listener)Adds aTransformer.Listenerto listen to the transformation events.Transformerbuild()Builds aTransformerinstance.Transformer.BuilderremoveAllListeners()Removes alllisteners.Transformer.BuilderremoveListener(Transformer.Listener listener)Removes aTransformer.Listener.Transformer.BuildersetContext(Context context)Deprecated.UseBuilder(Context)instead.Transformer.BuildersetDebugViewProvider(Transformer.DebugViewProvider debugViewProvider)Sets a provider for views to show diagnostic information (if available) during transformation.Transformer.BuildersetEncoderFactory(Codec.EncoderFactory encoderFactory)Sets theCodec.EncoderFactorythat will be used by the transformer.Transformer.BuildersetFlattenForSlowMotion(boolean flattenForSlowMotion)Deprecated.Transformer.BuildersetListener(Transformer.Listener listener)Deprecated.Transformer.BuildersetLooper(Looper looper)Sets theLooperthat must be used for all calls to the transformer and that is used to call listeners on.Transformer.BuildersetMediaSourceFactory(MediaSource.Factory mediaSourceFactory)Sets theMediaSource.Factoryto be used to retrieve the inputs to transform.Transformer.BuildersetOutputMimeType(String outputMimeType)Deprecated.This feature will be removed in a following release and the MIME type of the output will always be MP4.Transformer.BuildersetRemoveAudio(boolean removeAudio)Sets whether to remove the audio from the output.Transformer.BuildersetRemoveVideo(boolean removeVideo)Sets whether to remove the video from the output.Transformer.BuildersetTransformationRequest(TransformationRequest transformationRequest)Sets theTransformationRequestwhich configures the editing and transcoding options.
-
-
-
Constructor Detail
-
Builder
@Deprecated public Builder()
Deprecated.UseBuilder(Context)instead.
-
-
Method Detail
-
setContext
@Deprecated public Transformer.Builder setContext(Context context)
Deprecated.UseBuilder(Context)instead.
-
setTransformationRequest
public Transformer.Builder setTransformationRequest(TransformationRequest transformationRequest)
Sets theTransformationRequestwhich configures the editing and transcoding options.- Parameters:
transformationRequest- TheTransformationRequest.- Returns:
- This builder.
-
setMediaSourceFactory
public Transformer.Builder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory)
Sets theMediaSource.Factoryto be used to retrieve the inputs to transform. The default value is aDefaultMediaSourceFactorybuilt with the context provided inthe constructor.- Parameters:
mediaSourceFactory- AMediaSource.Factory.- Returns:
- This builder.
-
setRemoveAudio
public Transformer.Builder setRemoveAudio(boolean removeAudio)
Sets whether to remove the audio from the output. The default value isfalse.The audio and video cannot both be removed because the output would not contain any samples.
- Parameters:
removeAudio- Whether to remove the audio.- Returns:
- This builder.
-
setRemoveVideo
public Transformer.Builder setRemoveVideo(boolean removeVideo)
Sets whether to remove the video from the output. The default value isfalse.The audio and video cannot both be removed because the output would not contain any samples.
- Parameters:
removeVideo- Whether to remove the video.- Returns:
- This builder.
-
setFlattenForSlowMotion
@Deprecated public Transformer.Builder setFlattenForSlowMotion(boolean flattenForSlowMotion)
Deprecated.
-
setOutputMimeType
@Deprecated public Transformer.Builder setOutputMimeType(String outputMimeType)
Deprecated.This feature will be removed in a following release and the MIME type of the output will always be MP4.
-
setListener
@Deprecated public Transformer.Builder setListener(Transformer.Listener listener)
Deprecated.
-
addListener
public Transformer.Builder addListener(Transformer.Listener listener)
Adds aTransformer.Listenerto listen to the transformation events.This is equivalent to
Transformer.addListener(Listener).- Parameters:
listener- ATransformer.Listener.- Returns:
- This builder.
-
removeListener
public Transformer.Builder removeListener(Transformer.Listener listener)
Removes aTransformer.Listener.This is equivalent to
Transformer.removeListener(Listener).- Parameters:
listener- ATransformer.Listener.- Returns:
- This builder.
-
removeAllListeners
public Transformer.Builder removeAllListeners()
Removes alllisteners.This is equivalent to
Transformer.removeAllListeners().- Returns:
- This builder.
-
setLooper
public Transformer.Builder setLooper(Looper looper)
Sets theLooperthat must be used for all calls to the transformer and that is used to call listeners on. The default value is the Looper of the thread that this builder was created on, or if that thread does not have a Looper, the Looper of the application's main thread.- Parameters:
looper- ALooper.- Returns:
- This builder.
-
setEncoderFactory
public Transformer.Builder setEncoderFactory(Codec.EncoderFactory encoderFactory)
Sets theCodec.EncoderFactorythat will be used by the transformer. The default value isCodec.EncoderFactory.DEFAULT.- Parameters:
encoderFactory- TheCodec.EncoderFactoryinstance.- Returns:
- This builder.
-
setDebugViewProvider
public Transformer.Builder setDebugViewProvider(Transformer.DebugViewProvider debugViewProvider)
Sets a provider for views to show diagnostic information (if available) during transformation. This is intended for debugging. The default value isTransformer.DebugViewProvider.NONE, which doesn't show any debug info.Not all transformations will result in debug views being populated.
- Parameters:
debugViewProvider- Provider for debug views.- Returns:
- This builder.
-
build
public Transformer build()
Builds aTransformerinstance.- Throws:
NullPointerException- If theContexthas not been provided.IllegalStateException- If both audio and video have been removed (otherwise the output would not contain any samples).IllegalStateException- If the muxer doesn't support the requested audio MIME type.IllegalStateException- If the muxer doesn't support the requested video MIME type.
-
-