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
2d97d3a5
authored
Mar 08, 2023
by
kimvde
Committed by
tonihei
Mar 14, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make sure errors thrown in the PlayerListener are not swallowed
PiperOrigin-RevId: 515037497
parent
bfad60e6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
31 deletions
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/ExoPlayerAssetLoader.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/ExoPlayerAssetLoader.java
View file @
2d97d3a5
...
...
@@ -300,44 +300,54 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
@Override
public
void
onTimelineChanged
(
Timeline
timeline
,
int
reason
)
{
if
(
progressState
!=
PROGRESS_STATE_WAITING_FOR_AVAILABILITY
)
{
return
;
}
Timeline
.
Window
window
=
new
Timeline
.
Window
();
timeline
.
getWindow
(
/* windowIndex= */
0
,
window
);
if
(!
window
.
isPlaceholder
)
{
long
durationUs
=
window
.
durationUs
;
// Make progress permanently unavailable if the duration is unknown, so that it doesn't jump
// to a high value at the end of the export if the duration is set once the media is
// entirely loaded.
progressState
=
durationUs
<=
0
||
durationUs
==
C
.
TIME_UNSET
?
PROGRESS_STATE_UNAVAILABLE
:
PROGRESS_STATE_AVAILABLE
;
assetLoaderListener
.
onDurationUs
(
window
.
durationUs
);
try
{
if
(
progressState
!=
PROGRESS_STATE_WAITING_FOR_AVAILABILITY
)
{
return
;
}
Timeline
.
Window
window
=
new
Timeline
.
Window
();
timeline
.
getWindow
(
/* windowIndex= */
0
,
window
);
if
(!
window
.
isPlaceholder
)
{
long
durationUs
=
window
.
durationUs
;
// Make progress permanently unavailable if the duration is unknown, so that it doesn't
// jump to a high value at the end of the export if the duration is set once the media is
// entirely loaded.
progressState
=
durationUs
<=
0
||
durationUs
==
C
.
TIME_UNSET
?
PROGRESS_STATE_UNAVAILABLE
:
PROGRESS_STATE_AVAILABLE
;
assetLoaderListener
.
onDurationUs
(
window
.
durationUs
);
}
}
catch
(
RuntimeException
e
)
{
assetLoaderListener
.
onError
(
ExportException
.
createForAssetLoader
(
e
,
ERROR_CODE_UNSPECIFIED
));
}
}
@Override
public
void
onTracksChanged
(
Tracks
tracks
)
{
int
trackCount
=
0
;
if
(
tracks
.
isTypeSelected
(
C
.
TRACK_TYPE_AUDIO
))
{
trackCount
++;
}
if
(
tracks
.
isTypeSelected
(
C
.
TRACK_TYPE_VIDEO
))
{
trackCount
++;
}
try
{
int
trackCount
=
0
;
if
(
tracks
.
isTypeSelected
(
C
.
TRACK_TYPE_AUDIO
))
{
trackCount
++;
}
if
(
tracks
.
isTypeSelected
(
C
.
TRACK_TYPE_VIDEO
))
{
trackCount
++;
}
if
(
trackCount
>
0
)
{
assetLoaderListener
.
onTrackCount
(
trackCount
);
// Start the renderers after having registered all the tracks to make sure the AssetLoader
// listener callbacks are called in the right order.
player
.
play
();
}
else
{
if
(
trackCount
>
0
)
{
assetLoaderListener
.
onTrackCount
(
trackCount
);
// Start the renderers after having registered all the tracks to make sure the AssetLoader
// listener callbacks are called in the right order.
player
.
play
();
}
else
{
assetLoaderListener
.
onError
(
ExportException
.
createForAssetLoader
(
new
IllegalStateException
(
"The asset loader has no track to output."
),
ERROR_CODE_FAILED_RUNTIME_CHECK
));
}
}
catch
(
RuntimeException
e
)
{
assetLoaderListener
.
onError
(
ExportException
.
createForAssetLoader
(
new
IllegalStateException
(
"The asset loader has no track to output."
),
ERROR_CODE_FAILED_RUNTIME_CHECK
));
ExportException
.
createForAssetLoader
(
e
,
ERROR_CODE_UNSPECIFIED
));
}
}
...
...
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