From ad51d1ca8766b699fe62f67e3fdf1e7363cc61ec Mon Sep 17 00:00:00 2001 From: kimvde Date: Thu, 19 Jan 2023 13:50:31 +0000 Subject: [PATCH] Fix "Transforming media" page Some information there is not correct anymore. PiperOrigin-RevId: 503141754 --- docs/transforming-media.md | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/docs/transforming-media.md b/docs/transforming-media.md index 736c82d8e8..7668ff48d9 100644 --- a/docs/transforming-media.md +++ b/docs/transforming-media.md @@ -37,16 +37,14 @@ Transformer transformer = .addListener(transformerListener) .build(); // Start the transformation. -transformer.startTransformation(inputMediaItem, outputPath); +transformer.startTransformation( + new EditedMediaItem(inputMediaItem), outputPath); ~~~ {: .language-java} -Other parameters, such as the `MediaSource.Factory`, can be passed to the -builder. - -`startTransformation` receives a `MediaItem` describing the input, and a path or -a `ParcelFileDescriptor` indicating where the output should be written. The -input can be a progressive or an adaptive stream, but the output is always a +`startTransformation` receives an `EditedMediaItem` describing the input, and a +path or a `ParcelFileDescriptor` indicating where the output should be written. +The input can be a progressive or an adaptive stream, but the output is always a progressive stream. For adaptive inputs, the highest resolution tracks are always selected for the transformation. The input can be of any container format supported by ExoPlayer (see the [Supported formats page][] for details), but the @@ -65,12 +63,16 @@ app is notified of events via the listener passed to the `Transformer` builder. Transformer.Listener transformerListener = new Transformer.Listener() { @Override - public void onTransformationCompleted(MediaItem inputMediaItem, TransformationResult result) { + public void onTransformationCompleted( + MediaItem inputMediaItem, TransformationResult result) { playOutput(); } @Override - public void onTransformationError(MediaItem inputMediaItem, TransformationResult result, TransformationException exception) { + public void onTransformationError( + MediaItem inputMediaItem, + TransformationResult result, + TransformationException exception) { displayError(e); } }; @@ -88,13 +90,15 @@ the `updateProgressInUi` method could be implemented to update a progress bar displayed to the user. ~~~ -transformer.startTransformation(inputMediaItem, outputPath); +transformer.startTransformation( + new EditedMediaItem(inputMediaItem), outputPath); ProgressHolder progressHolder = new ProgressHolder(); mainHandler.post( new Runnable() { @Override public void run() { - @ProgressState int progressState = transformer.getProgress(progressHolder); + @ProgressState int progressState = + transformer.getProgress(progressHolder); updateProgressInUi(progressState, progressHolder); if (progressState != PROGRESS_STATE_NOT_STARTED) { mainHandler.postDelayed(/* r= */ this, /* delayMillis= */ 500); @@ -123,7 +127,8 @@ Transformer transformer = .setFlattenForSlowMotion(true) .addListener(transformerListener) .build(); -transformer.startTransformation(inputMediaItem, outputPath); +transformer.startTransformation( + new EditedMediaItem(inputMediaItem), outputPath); ~~~ {: .language-java}