Commit 5f1921f5 by aquilescanta Committed by Oliver Woodman

Make Player.getPlayerError return a PlaybackException

PiperOrigin-RevId: 378899373
parent 5f77bf04
...@@ -178,7 +178,7 @@ public class ForwardingPlayer implements Player { ...@@ -178,7 +178,7 @@ public class ForwardingPlayer implements Player {
@Nullable @Nullable
@Override @Override
public ExoPlaybackException getPlayerError() { public PlaybackException getPlayerError() {
return player.getPlayerError(); return player.getPlayerError();
} }
......
...@@ -1472,7 +1472,7 @@ public interface Player { ...@@ -1472,7 +1472,7 @@ public interface Player {
* @see Listener#onPlayerError(ExoPlaybackException) * @see Listener#onPlayerError(ExoPlaybackException)
*/ */
@Nullable @Nullable
ExoPlaybackException getPlayerError(); PlaybackException getPlayerError();
/** /**
* Resumes playback as soon as {@link #getPlaybackState()} == {@link #STATE_READY}. Equivalent to * Resumes playback as soon as {@link #getPlaybackState()} == {@link #STATE_READY}. Equivalent to
......
...@@ -834,6 +834,13 @@ public interface ExoPlayer extends Player { ...@@ -834,6 +834,13 @@ public interface ExoPlayer extends Player {
} }
} }
/**
* Equivalent to {@link Player#getPlayerError()}, except the exception is guaranteed to be an
* {@link ExoPlaybackException}.
*/
@Override
ExoPlaybackException getPlayerError();
/** Returns the component of this player for audio output, or null if audio is not supported. */ /** Returns the component of this player for audio output, or null if audio is not supported. */
@Nullable @Nullable
AudioComponent getAudioComponent(); AudioComponent getAudioComponent();
......
...@@ -22,8 +22,8 @@ import android.os.SystemClock; ...@@ -22,8 +22,8 @@ import android.os.SystemClock;
import android.util.Pair; import android.util.Pair;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Period; import com.google.android.exoplayer2.Timeline.Period;
...@@ -489,7 +489,7 @@ public final class PlaybackStatsListener ...@@ -489,7 +489,7 @@ public final class PlaybackStatsListener
int droppedFrameCount, int droppedFrameCount,
boolean hasAudioUnderun, boolean hasAudioUnderun,
boolean startedLoading, boolean startedLoading,
@Nullable ExoPlaybackException fatalError, @Nullable PlaybackException fatalError,
@Nullable Exception nonFatalException, @Nullable Exception nonFatalException,
long bandwidthTimeMs, long bandwidthTimeMs,
long bandwidthBytes, long bandwidthBytes,
......
...@@ -195,7 +195,9 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest { ...@@ -195,7 +195,9 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
} }
} }
if (events.contains(EVENT_PLAYER_ERROR)) { if (events.contains(EVENT_PLAYER_ERROR)) {
playerError = checkNotNull(player.getPlayerError()); // The exception is guaranteed to be an ExoPlaybackException because the underlying player is
// an ExoPlayer instance.
playerError = (ExoPlaybackException) checkNotNull(player.getPlayerError());
onPlayerErrorInternal(playerError); onPlayerErrorInternal(playerError);
} }
if (events.contains(EVENT_PLAYBACK_STATE_CHANGED)) { if (events.contains(EVENT_PLAYBACK_STATE_CHANGED)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment