mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Add getPlaybackError to Player/ExoPlayer interface
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=193400443
This commit is contained in:
parent
fb5e31d3d6
commit
d4aceef8a8
7 changed files with 44 additions and 2 deletions
|
|
@ -9,6 +9,7 @@
|
|||
* Updated default max buffer length in `DefaultLoadControl`.
|
||||
* Added `AnalyticsListener` interface which can be registered in
|
||||
`SimpleExoPlayer` to receive detailed meta data for each ExoPlayer event.
|
||||
* Added `getPlaybackError` to `Player` interface.
|
||||
* UI components:
|
||||
* Add support for listening to `AspectRatioFrameLayout`'s aspect ratio update
|
||||
([#3736](https://github.com/google/ExoPlayer/issues/3736)).
|
||||
|
|
|
|||
|
|
@ -307,6 +307,11 @@ public final class CastPlayer implements Player {
|
|||
return playbackState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Exception getPlaybackError() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayWhenReady(boolean playWhenReady) {
|
||||
if (remoteMediaClient == null) {
|
||||
|
|
|
|||
|
|
@ -185,6 +185,10 @@ public interface ExoPlayer extends Player {
|
|||
*/
|
||||
Looper getPlaybackLooper();
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
ExoPlaybackException getPlaybackError();
|
||||
|
||||
/**
|
||||
* Prepares the player to play the provided {@link MediaSource}. Equivalent to
|
||||
* {@code prepare(mediaSource, true, true)}.
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
private boolean hasPendingPrepare;
|
||||
private boolean hasPendingSeek;
|
||||
private PlaybackParameters playbackParameters;
|
||||
private @Nullable ExoPlaybackException playbackError;
|
||||
|
||||
// Playback information when there is no pending seek/set source operation.
|
||||
private PlaybackInfo playbackInfo;
|
||||
|
|
@ -156,6 +157,11 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
return playbackInfo.playbackState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ExoPlaybackException getPlaybackError() {
|
||||
return playbackError;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(MediaSource mediaSource) {
|
||||
prepare(mediaSource, true, true);
|
||||
|
|
@ -163,6 +169,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
|
||||
@Override
|
||||
public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState) {
|
||||
playbackError = null;
|
||||
PlaybackInfo playbackInfo =
|
||||
getResetPlaybackInfo(
|
||||
resetPosition, resetState, /* playbackState= */ Player.STATE_BUFFERING);
|
||||
|
|
@ -325,6 +332,9 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
|
||||
@Override
|
||||
public void stop(boolean reset) {
|
||||
if (reset) {
|
||||
playbackError = null;
|
||||
}
|
||||
PlaybackInfo playbackInfo =
|
||||
getResetPlaybackInfo(
|
||||
/* resetPosition= */ reset,
|
||||
|
|
@ -560,9 +570,9 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||
}
|
||||
break;
|
||||
case ExoPlayerImplInternal.MSG_ERROR:
|
||||
ExoPlaybackException exception = (ExoPlaybackException) msg.obj;
|
||||
playbackError = (ExoPlaybackException) msg.obj;
|
||||
for (Player.EventListener listener : listeners) {
|
||||
listener.onPlayerError(exception);
|
||||
listener.onPlayerError(playbackError);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -459,6 +459,17 @@ public interface Player {
|
|||
*/
|
||||
int getPlaybackState();
|
||||
|
||||
/**
|
||||
* Returns the error that caused playback to fail. This is the same error that will have been
|
||||
* reported via @link Player.EventListener#onPlayerError(ExoPlaybackException)} at the time of
|
||||
* failure. It can be queried using this method until {@code stop(true)} is called or the player
|
||||
* is re-prepared.
|
||||
*
|
||||
* @return The error, or {@code null}.
|
||||
*/
|
||||
@Nullable
|
||||
Exception getPlaybackError();
|
||||
|
||||
/**
|
||||
* Sets whether playback should proceed when {@link #getPlaybackState()} == {@link #STATE_READY}.
|
||||
* <p>
|
||||
|
|
|
|||
|
|
@ -653,6 +653,11 @@ public class SimpleExoPlayer implements ExoPlayer, Player.VideoComponent, Player
|
|||
return player.getPlaybackState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExoPlaybackException getPlaybackError() {
|
||||
return player.getPlaybackError();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(MediaSource mediaSource) {
|
||||
prepare(mediaSource, /* resetPosition= */ true, /* resetState= */ true);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ package com.google.android.exoplayer2.testutil;
|
|||
|
||||
import android.os.Looper;
|
||||
import android.support.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||
import com.google.android.exoplayer2.ExoPlayer;
|
||||
import com.google.android.exoplayer2.PlaybackParameters;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
|
|
@ -63,6 +64,11 @@ public abstract class StubExoPlayer implements ExoPlayer {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExoPlaybackException getPlaybackError() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(MediaSource mediaSource) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
|||
Loading…
Reference in a new issue