本文整理匯總了Java中com.google.android.exoplayer.ExoPlayer.STATE_READY屬性的典型用法代碼示例。如果您正苦於以下問題:Java ExoPlayer.STATE_READY屬性的具體用法?Java ExoPlayer.STATE_READY怎麽用?Java ExoPlayer.STATE_READY使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.google.android.exoplayer.ExoPlayer
的用法示例。
在下文中一共展示了ExoPlayer.STATE_READY屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onStateChanged
@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {
if (playWhenReady && playbackState == ExoPlayer.STATE_READY) {
notifyTracksChanged(getAllTracks());
String audioId = getTrackId(TvTrackInfo.TYPE_AUDIO,
mPlayer.getSelectedTrack(TvTrackInfo.TYPE_AUDIO));
String videoId = getTrackId(TvTrackInfo.TYPE_VIDEO,
mPlayer.getSelectedTrack(TvTrackInfo.TYPE_VIDEO));
String textId = getTrackId(TvTrackInfo.TYPE_SUBTITLE,
mPlayer.getSelectedTrack(TvTrackInfo.TYPE_SUBTITLE));
notifyTrackSelected(TvTrackInfo.TYPE_AUDIO, audioId);
notifyTrackSelected(TvTrackInfo.TYPE_VIDEO, videoId);
notifyTrackSelected(TvTrackInfo.TYPE_SUBTITLE, textId);
notifyVideoAvailable();
}
}
示例2: getStateString
private String getStateString(int state) {
switch (state) {
case ExoPlayer.STATE_BUFFERING:
return "B";
case ExoPlayer.STATE_ENDED:
return "E";
case ExoPlayer.STATE_IDLE:
return "I";
case ExoPlayer.STATE_PREPARING:
return "P";
case ExoPlayer.STATE_READY:
return "R";
default:
return "?";
}
}
示例3: isPlaying
@Override
public boolean isPlaying() {
if (mInternalPlayer == null)
return false;
int state = mInternalPlayer.getPlaybackState();
switch (state) {
case ExoPlayer.STATE_BUFFERING:
case ExoPlayer.STATE_READY:
return mInternalPlayer.getPlayWhenReady();
case ExoPlayer.STATE_IDLE:
case ExoPlayer.STATE_PREPARING:
case ExoPlayer.STATE_ENDED:
default:
return false;
}
}
示例4: isPlaying
@Override
public boolean isPlaying() {
if (mInternalPlayer == null)
return false;
int state = mInternalPlayer.getPlaybackState();
switch (state) {
case ExoPlayer.STATE_BUFFERING:
case ExoPlayer.STATE_READY:
return mInternalPlayer.getPlayWhenReady();
case ExoPlayer.STATE_IDLE:
case ExoPlayer.STATE_PREPARING:
case ExoPlayer.STATE_ENDED:
default:
return false;
}
}
示例5: run
@Override public void run() {
switch (player.getPlaybackState()) {
case ExoPlayer.STATE_BUFFERING:
mlistener.onBuffering(playerControl.getBufferPercentage() + "");
break;
case ExoPlayer.STATE_ENDED:
mlistener.onCompletion();
break;
case ExoPlayer.STATE_IDLE:
break;
case ExoPlayer.STATE_PREPARING:
mlistener.onBufferingStarted();
break;
case ExoPlayer.STATE_READY:
mlistener.onBufferingFinished();
break;
default:
break;
}
mlistener.onProgressChanged((int) player.getCurrentPosition());
mainHandler.postDelayed(updatePlayer, 200);
}
示例6: executeListeners
private void executeListeners() {
long duration = player.getDuration() / 1000;
long position = player.getCurrentPosition() / 1000;
List<Pair<Long, OnTimeReached>> executed = new ArrayList<>();
if (duration > 0 && (state == ExoPlayer.STATE_READY || state == ExoPlayer.STATE_ENDED)) {
long remain = duration - position;
for (Pair<Long, OnTimeReached> listener : listeners) {
long condition = listener.first;
if (remain <= condition) {
Log.d(TAG, "Executing listener, duration=" + duration + ", position=" + position + ", remaining=" + remain);
listener.second.onPositionRemainingReached(duration, position);
executed.add(listener);
}
}
}
listeners.removeAll(executed);
}
示例7: getStateString
private String getStateString(int state) {
switch (state) {
case ExoPlayer.STATE_BUFFERING:
return "B";
case ExoPlayer.STATE_ENDED:
return "E";
case ExoPlayer.STATE_IDLE:
return "I";
case ExoPlayer.STATE_PREPARING:
return "P";
case ExoPlayer.STATE_READY:
return "R";
default:
return "?";
}
}
示例8: onPlayerStateChanged
@Override
public void onPlayerStateChanged(boolean playWhenReady, int state) {
String playerState = "";
switch (player.getPlaybackState()) {
case ExoPlayer.STATE_BUFFERING:
playerState = "buffering";
break;
case ExoPlayer.STATE_ENDED:
playerState = "ended";
break;
case ExoPlayer.STATE_IDLE:
playerState = "idle";
break;
case ExoPlayer.STATE_PREPARING:
playerState = "preparing";
break;
case ExoPlayer.STATE_READY:
playerState = "ready";
break;
}
playerStateView.setText("Player State: " + playerState);
}
示例9: onStateChanged
@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {
state = playbackState;
String text = "playWhenReady=" + playWhenReady + ", playbackState=";
switch (playbackState) {
case ExoPlayer.STATE_BUFFERING:
text += "buffering";
break;
case ExoPlayer.STATE_ENDED:
text += "ended";
break;
case ExoPlayer.STATE_IDLE:
text += "idle";
break;
case ExoPlayer.STATE_PREPARING:
text += "preparing";
break;
case ExoPlayer.STATE_READY:
text += "ready";
break;
default:
text += "unknown";
break;
}
Log.d(TAG, text);
}
示例10: onStateChanged
@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {
if (mPlayer == null) {
return;
}
if (playWhenReady && playbackState == ExoPlayer.STATE_READY) {
notifyTracksChanged(getAllTracks());
String audioId = getTrackId(TvTrackInfo.TYPE_AUDIO,
mPlayer.getSelectedTrack(TvTrackInfo.TYPE_AUDIO));
String videoId = getTrackId(TvTrackInfo.TYPE_VIDEO,
mPlayer.getSelectedTrack(TvTrackInfo.TYPE_VIDEO));
String textId = getTrackId(TvTrackInfo.TYPE_SUBTITLE,
mPlayer.getSelectedTrack(TvTrackInfo.TYPE_SUBTITLE));
notifyTrackSelected(TvTrackInfo.TYPE_AUDIO, audioId);
notifyTrackSelected(TvTrackInfo.TYPE_VIDEO, videoId);
notifyTrackSelected(TvTrackInfo.TYPE_SUBTITLE, textId);
notifyVideoAvailable();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
Math.abs(mPlayer.getPlaybackSpeed() - 1) < 0.1 &&
playWhenReady && playbackState == ExoPlayer.STATE_BUFFERING) {
notifyVideoUnavailable(TvInputManager.VIDEO_UNAVAILABLE_REASON_BUFFERING);
}
}
示例11: onStateChanged
@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {
switch (playbackState) {
case ExoPlayer.STATE_BUFFERING:
// Do nothing.
break;
case ExoPlayer.STATE_ENDED:
mIsMetadataSet = false;
mMediaController.getTransportControls().skipToNext();
break;
case ExoPlayer.STATE_IDLE:
// Do nothing.
break;
case ExoPlayer.STATE_PREPARING:
mIsMetadataSet = false;
break;
case ExoPlayer.STATE_READY:
// Duration is set here.
if (!mIsMetadataSet) {
updateMetadata(mSelectedVideo);
mIsMetadataSet = true;
}
break;
default:
// Do nothing.
break;
}
}
示例12: onStateChanged
@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_ENDED) {
muxNotifier.onMediaPlaybackEnded();
if (!notifiedCompleted) {
notifyCompletionListener();
}
} else if (playbackState == ExoPlayer.STATE_READY && !notifiedPrepared) {
notifyPreparedListener();
}
//Updates the previewImage
if (playbackState == ExoPlayer.STATE_READY && playWhenReady) {
muxNotifier.onPreviewImageStateChanged(false);
}
//Clears the textureView when requested
if (playbackState == ExoPlayer.STATE_IDLE && clearRequested) {
clearRequested = false;
ResizingTextureView textureView = clearTextureView.get();
if (textureView != null) {
textureView.clearSurface();
clearTextureView = new WeakReference<>(null);
}
}
}
示例13: onStateChanged
@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_ENDED) {
showControls();
}
String text = "playWhenReady=" + playWhenReady + ", playbackState=";
switch (playbackState) {
case ExoPlayer.STATE_BUFFERING:
text += "buffering";
break;
case ExoPlayer.STATE_ENDED:
text += "ended";
break;
case ExoPlayer.STATE_IDLE:
text += "idle";
break;
case ExoPlayer.STATE_PREPARING:
text += "preparing";
break;
case ExoPlayer.STATE_READY:
text += "ready";
break;
default:
text += "unknown";
break;
}
playerStateTextView.setText(text);
updateButtonVisibilities();
}
示例14: maybeReportPlayerState
private void maybeReportPlayerState() {
boolean playWhenReady = player.getPlayWhenReady();
int playbackState = getPlaybackState();
if (lastReportedPlayWhenReady != playWhenReady || lastReportedPlaybackState != playbackState) {
for (Listener listener : listeners) {
listener.onStateChanged(playWhenReady, playbackState);
}
switch (playbackState) {
case ExoPlayer.STATE_IDLE:
break;
case ExoPlayer.STATE_PREPARING:
break;
case ExoPlayer.STATE_READY:
if (onPreparedListener != null && !isPrepared) {
isPrepared = true;
onPreparedListener.onPrepared(this);
}
break;
case ExoPlayer.STATE_BUFFERING:
break;
case ExoPlayer.STATE_ENDED:
if (playWhenReady && onCompletionListener != null) {
onCompletionListener.onCompletion(this);
}
break;
}
lastReportedPlayWhenReady = playWhenReady;
lastReportedPlaybackState = playbackState;
}
}
示例15: onPlayerStateChanged
@Override
public final void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
playerWasPrepared |= playbackState != ExoPlayer.STATE_IDLE;
if (playbackState == ExoPlayer.STATE_ENDED
|| (playbackState == ExoPlayer.STATE_IDLE && playerWasPrepared)) {
playerFinished = true;
}
boolean playing = playWhenReady && playbackState == ExoPlayer.STATE_READY;
if (!this.playing && playing) {
lastPlayingStartTimeMs = SystemClock.elapsedRealtime();
} else if (this.playing && !playing) {
totalPlayingTimeMs += SystemClock.elapsedRealtime() - lastPlayingStartTimeMs;
}
this.playing = playing;
}