Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e6032c73
authored
Apr 14, 2023
by
simakova
Committed by
Rohit Singh
Apr 17, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix input video duration in the result view in transformer demo
PiperOrigin-RevId: 524305085
parent
08b862dd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
11 deletions
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
View file @
e6032c73
...
@@ -222,7 +222,7 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -222,7 +222,7 @@ public final class TransformerActivity extends AppCompatActivity {
requestReadVideoPermission
(
/* activity= */
this
);
requestReadVideoPermission
(
/* activity= */
this
);
Intent
intent
=
getIntent
();
Intent
intent
=
getIntent
();
Uri
u
ri
=
checkNotNull
(
intent
.
getData
());
Uri
inputU
ri
=
checkNotNull
(
intent
.
getData
());
try
{
try
{
externalCacheFile
=
createExternalCacheFile
(
"transformer-output.mp4"
);
externalCacheFile
=
createExternalCacheFile
(
"transformer-output.mp4"
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -230,9 +230,9 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -230,9 +230,9 @@ public final class TransformerActivity extends AppCompatActivity {
}
}
String
filePath
=
externalCacheFile
.
getAbsolutePath
();
String
filePath
=
externalCacheFile
.
getAbsolutePath
();
@Nullable
Bundle
bundle
=
intent
.
getExtras
();
@Nullable
Bundle
bundle
=
intent
.
getExtras
();
MediaItem
mediaItem
=
createMediaItem
(
bundle
,
u
ri
);
MediaItem
mediaItem
=
createMediaItem
(
bundle
,
inputU
ri
);
try
{
try
{
Transformer
transformer
=
createTransformer
(
bundle
,
filePath
);
Transformer
transformer
=
createTransformer
(
bundle
,
inputUri
,
filePath
);
Composition
composition
=
createComposition
(
mediaItem
,
bundle
);
Composition
composition
=
createComposition
(
mediaItem
,
bundle
);
exportStopwatch
.
start
();
exportStopwatch
.
start
();
transformer
.
start
(
composition
,
filePath
);
transformer
.
start
(
composition
,
filePath
);
...
@@ -296,7 +296,7 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -296,7 +296,7 @@ public final class TransformerActivity extends AppCompatActivity {
"progressViewGroup"
,
"progressViewGroup"
,
"debugFrame"
,
"debugFrame"
,
})
})
private
Transformer
createTransformer
(
@Nullable
Bundle
bundle
,
String
filePath
)
{
private
Transformer
createTransformer
(
@Nullable
Bundle
bundle
,
Uri
inputUri
,
String
filePath
)
{
Transformer
.
Builder
transformerBuilder
=
new
Transformer
.
Builder
(
/* context= */
this
);
Transformer
.
Builder
transformerBuilder
=
new
Transformer
.
Builder
(
/* context= */
this
);
if
(
bundle
!=
null
)
{
if
(
bundle
!=
null
)
{
TransformationRequest
.
Builder
requestBuilder
=
new
TransformationRequest
.
Builder
();
TransformationRequest
.
Builder
requestBuilder
=
new
TransformationRequest
.
Builder
();
...
@@ -331,9 +331,7 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -331,9 +331,7 @@ public final class TransformerActivity extends AppCompatActivity {
new
Transformer
.
Listener
()
{
new
Transformer
.
Listener
()
{
@Override
@Override
public
void
onCompleted
(
Composition
composition
,
ExportResult
exportResult
)
{
public
void
onCompleted
(
Composition
composition
,
ExportResult
exportResult
)
{
MediaItem
mediaItem
=
TransformerActivity
.
this
.
onCompleted
(
inputUri
,
filePath
);
composition
.
sequences
.
get
(
0
).
editedMediaItems
.
get
(
0
).
mediaItem
;
TransformerActivity
.
this
.
onCompleted
(
filePath
,
mediaItem
);
}
}
@Override
@Override
...
@@ -659,7 +657,7 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -659,7 +657,7 @@ public final class TransformerActivity extends AppCompatActivity {
"debugFrame"
,
"debugFrame"
,
"exportStopwatch"
,
"exportStopwatch"
,
})
})
private
void
onCompleted
(
String
filePath
,
MediaItem
inputMediaItem
)
{
private
void
onCompleted
(
Uri
inputUri
,
String
filePath
)
{
exportStopwatch
.
stop
();
exportStopwatch
.
stop
();
informationTextView
.
setText
(
informationTextView
.
setText
(
getString
(
R
.
string
.
export_completed
,
exportStopwatch
.
elapsed
(
TimeUnit
.
SECONDS
)));
getString
(
R
.
string
.
export_completed
,
exportStopwatch
.
elapsed
(
TimeUnit
.
SECONDS
)));
...
@@ -670,7 +668,7 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -670,7 +668,7 @@ public final class TransformerActivity extends AppCompatActivity {
outputVideoTextView
.
setVisibility
(
View
.
VISIBLE
);
outputVideoTextView
.
setVisibility
(
View
.
VISIBLE
);
debugTextView
.
setVisibility
(
View
.
VISIBLE
);
debugTextView
.
setVisibility
(
View
.
VISIBLE
);
displayInputButton
.
setVisibility
(
View
.
VISIBLE
);
displayInputButton
.
setVisibility
(
View
.
VISIBLE
);
playMediaItems
(
inputMediaItem
,
MediaItem
.
fromUri
(
"file://"
+
filePath
));
playMediaItems
(
MediaItem
.
fromUri
(
inputUri
)
,
MediaItem
.
fromUri
(
"file://"
+
filePath
));
Log
.
d
(
TAG
,
"Output file path: file://"
+
filePath
);
Log
.
d
(
TAG
,
"Output file path: file://"
+
filePath
);
}
}
...
@@ -686,8 +684,8 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -686,8 +684,8 @@ public final class TransformerActivity extends AppCompatActivity {
inputPlayerView
.
setPlayer
(
null
);
inputPlayerView
.
setPlayer
(
null
);
outputPlayerView
.
setPlayer
(
null
);
outputPlayerView
.
setPlayer
(
null
);
releasePlayer
();
releasePlayer
();
Uri
uri
=
checkNotNull
(
inputMediaItem
.
localConfiguration
).
uri
;
Uri
uri
=
checkNotNull
(
inputMediaItem
.
localConfiguration
).
uri
;
ExoPlayer
outputPlayer
=
new
ExoPlayer
.
Builder
(
/* context= */
this
).
build
();
ExoPlayer
outputPlayer
=
new
ExoPlayer
.
Builder
(
/* context= */
this
).
build
();
outputPlayerView
.
setPlayer
(
outputPlayer
);
outputPlayerView
.
setPlayer
(
outputPlayer
);
outputPlayerView
.
setControllerAutoShow
(
false
);
outputPlayerView
.
setControllerAutoShow
(
false
);
...
@@ -718,8 +716,8 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -718,8 +716,8 @@ public final class TransformerActivity extends AppCompatActivity {
ExoPlayer
inputPlayer
=
new
ExoPlayer
.
Builder
(
/* context= */
this
).
build
();
ExoPlayer
inputPlayer
=
new
ExoPlayer
.
Builder
(
/* context= */
this
).
build
();
inputPlayerView
.
setPlayer
(
inputPlayer
);
inputPlayerView
.
setPlayer
(
inputPlayer
);
inputPlayerView
.
setControllerAutoShow
(
false
);
inputPlayerView
.
setControllerAutoShow
(
false
);
inputPlayer
.
setMediaItem
(
inputMediaItem
);
inputPlayerView
.
setOnClickListener
(
this
::
onClickingPlayerView
);
inputPlayerView
.
setOnClickListener
(
this
::
onClickingPlayerView
);
inputPlayer
.
setMediaItem
(
inputMediaItem
);
inputPlayer
.
prepare
();
inputPlayer
.
prepare
();
this
.
inputPlayer
=
inputPlayer
;
this
.
inputPlayer
=
inputPlayer
;
inputPlayer
.
setVolume
(
0
f
);
inputPlayer
.
setVolume
(
0
f
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment