CS3Player: fixed ERROR_CODE_BEHIND_LIVE_WINDOW (#447)

This commit is contained in:
Shif-Jess 2023-04-09 14:37:27 +07:00 committed by GitHub
parent 4ed65f8e07
commit 4f9016713f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 6 deletions

View File

@ -985,12 +985,19 @@ class CS3IPlayer : IPlayer {
// If the Network fails then ignore the exception if the duration is set.
// This is to switch mirrors automatically if the stream has not been fetched, but
// allow playing the buffer without internet as then the duration is fetched.
if (error.errorCode == PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED
&& exoPlayer?.duration != TIME_UNSET
) {
exoPlayer?.prepare()
} else {
playerError?.invoke(error)
when {
error.errorCode == PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED
&& exoPlayer?.duration != TIME_UNSET -> {
exoPlayer?.prepare()
}
error.errorCode == PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW -> {
// Re-initialize player at the current live window default position.
exoPlayer?.seekToDefaultPosition()
exoPlayer?.prepare()
}
else -> {
playerError?.invoke(error)
}
}
super.onPlayerError(error)