mirror of
https://github.com/androidx/media.git
synced 2025-05-07 15:40:37 +08:00
Fix "Transforming media" page
Some information there is not correct anymore. PiperOrigin-RevId: 503141754
This commit is contained in:
parent
4f6b83e2c3
commit
ad51d1ca87
@ -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}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user