mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Assign ERROR_CODE_BEHIND_LIVE_WINDOW to BehindLiveWindowExceptions
PiperOrigin-RevId: 374425179
This commit is contained in:
parent
73f28d4829
commit
66c1aedeb3
2 changed files with 28 additions and 10 deletions
|
|
@ -114,7 +114,18 @@ public final class ExoPlaybackException extends PlaybackException {
|
|||
* @return The created instance.
|
||||
*/
|
||||
public static ExoPlaybackException createForSource(IOException cause) {
|
||||
return new ExoPlaybackException(TYPE_SOURCE, cause, ERROR_CODE_UNSPECIFIED);
|
||||
return createForSource(cause, ERROR_CODE_UNSPECIFIED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of type {@link #TYPE_SOURCE}.
|
||||
*
|
||||
* @param cause The cause of the failure.
|
||||
* @param errorCode See {@link #errorCode}.
|
||||
* @return The created instance.
|
||||
*/
|
||||
public static ExoPlaybackException createForSource(IOException cause, int errorCode) {
|
||||
return new ExoPlaybackException(TYPE_SOURCE, cause, errorCode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import com.google.android.exoplayer2.Player.PlaybackSuppressionReason;
|
|||
import com.google.android.exoplayer2.Player.RepeatMode;
|
||||
import com.google.android.exoplayer2.analytics.AnalyticsCollector;
|
||||
import com.google.android.exoplayer2.metadata.Metadata;
|
||||
import com.google.android.exoplayer2.source.BehindLiveWindowException;
|
||||
import com.google.android.exoplayer2.source.MediaPeriod;
|
||||
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
||||
import com.google.android.exoplayer2.source.SampleStream;
|
||||
|
|
@ -570,16 +571,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
stopInternal(/* forceResetRenderers= */ true, /* acknowledgeStop= */ false);
|
||||
playbackInfo = playbackInfo.copyWithPlaybackError(e);
|
||||
}
|
||||
} catch (BehindLiveWindowException e) {
|
||||
handleIoException(e, PlaybackException.ERROR_CODE_BEHIND_LIVE_WINDOW);
|
||||
} catch (IOException e) {
|
||||
ExoPlaybackException error = ExoPlaybackException.createForSource(e);
|
||||
@Nullable MediaPeriodHolder playingPeriod = queue.getPlayingPeriod();
|
||||
if (playingPeriod != null) {
|
||||
// We ensure that all IOException throwing methods are only executed for the playing period.
|
||||
error = error.copyWithMediaPeriodId(playingPeriod.info.id);
|
||||
}
|
||||
Log.e(TAG, "Playback error", error);
|
||||
stopInternal(/* forceResetRenderers= */ false, /* acknowledgeStop= */ false);
|
||||
playbackInfo = playbackInfo.copyWithPlaybackError(error);
|
||||
handleIoException(e, PlaybackException.ERROR_CODE_UNSPECIFIED);
|
||||
} catch (RuntimeException e) {
|
||||
ExoPlaybackException error = ExoPlaybackException.createForUnexpected(e);
|
||||
Log.e(TAG, "Playback error", error);
|
||||
|
|
@ -592,6 +587,18 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
|
||||
// Private methods.
|
||||
|
||||
private void handleIoException(IOException e, @PlaybackException.ErrorCode int errorCode) {
|
||||
ExoPlaybackException error = ExoPlaybackException.createForSource(e, errorCode);
|
||||
@Nullable MediaPeriodHolder playingPeriod = queue.getPlayingPeriod();
|
||||
if (playingPeriod != null) {
|
||||
// We ensure that all IOException throwing methods are only executed for the playing period.
|
||||
error = error.copyWithMediaPeriodId(playingPeriod.info.id);
|
||||
}
|
||||
Log.e(TAG, "Playback error", error);
|
||||
stopInternal(/* forceResetRenderers= */ false, /* acknowledgeStop= */ false);
|
||||
playbackInfo = playbackInfo.copyWithPlaybackError(error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks the current thread until a condition becomes true or the specified amount of time has
|
||||
* elapsed.
|
||||
|
|
|
|||
Loading…
Reference in a new issue