Java Code Examples for com.google.android.exoplayer2.ExoPlayer#STATE_ENDED
The following examples show how to use
com.google.android.exoplayer2.ExoPlayer#STATE_ENDED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebPlayerView.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void onStateChanged(boolean playWhenReady, int playbackState) { if (playbackState != ExoPlayer.STATE_BUFFERING) { if (videoPlayer.getDuration() != C.TIME_UNSET) { controlsView.setDuration((int) (videoPlayer.getDuration() / 1000)); } else { controlsView.setDuration(0); } } if (playbackState != ExoPlayer.STATE_ENDED && playbackState != ExoPlayer.STATE_IDLE && videoPlayer.isPlaying()) { delegate.onPlayStateChanged(this, true); } else { delegate.onPlayStateChanged(this, false); } if (videoPlayer.isPlaying() && playbackState != ExoPlayer.STATE_ENDED) { updatePlayButton(); } else { if (playbackState == ExoPlayer.STATE_ENDED) { isCompleted = true; videoPlayer.pause(); videoPlayer.seekTo(0); updatePlayButton(); controlsView.show(true, true); } } }
Example 2
Source File: VideoActivity.java From evercam-android with GNU Affero General Public License v3.0 | 6 votes |
/************************ * ExoPlayer2.Listener ************************/ @Override public void onPlayerStateChanged(boolean playWhenReady, int 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_READY: onVideoLoaded(); text += "ready"; break; default: text += "unknown"; break; } Log.d(TAG, "onStateChanged: " + text); }
Example 3
Source File: WebPlayerView.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onStateChanged(boolean playWhenReady, int playbackState) { if (playbackState != ExoPlayer.STATE_BUFFERING) { if (videoPlayer.getDuration() != C.TIME_UNSET) { controlsView.setDuration((int) (videoPlayer.getDuration() / 1000)); } else { controlsView.setDuration(0); } } if (playbackState != ExoPlayer.STATE_ENDED && playbackState != ExoPlayer.STATE_IDLE && videoPlayer.isPlaying()) { delegate.onPlayStateChanged(this, true); } else { delegate.onPlayStateChanged(this, false); } if (videoPlayer.isPlaying() && playbackState != ExoPlayer.STATE_ENDED) { updatePlayButton(); } else { if (playbackState == ExoPlayer.STATE_ENDED) { isCompleted = true; videoPlayer.pause(); videoPlayer.seekTo(0); updatePlayButton(); controlsView.show(true, true); } } }
Example 4
Source File: ExoHostedTest.java From ExoPlayer-Offline with Apache License 2.0 | 6 votes |
@Override public final void onPlayerStateChanged(boolean playWhenReady, int playbackState) { Log.d(tag, "state [" + playWhenReady + ", " + 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; }
Example 5
Source File: ExoMedia.java From QSVideoPlayer with Apache License 2.0 | 6 votes |
@Override public void onPlayerStateChanged(boolean b, int i) { Log.e("ExoMedia", "onPlayerStateChanged " + b + i); if (i == ExoPlayer.STATE_READY) { //缓冲好了 iMediaCallback.onInfo(this, MEDIA_INFO_BUFFERING_END, MEDIA_INFO_BUFFERING_END); mainThreadHandler.removeCallbacks(runnable); mainThreadHandler.post(runnable); if (!isPrepar) { isPrepar = true; iMediaCallback.onPrepared(this);//第一次初始化 } } //播放完毕 if (i == ExoPlayer.STATE_ENDED) { mainThreadHandler.removeCallbacks(runnable); iMediaCallback.onCompletion(this); } if (i == ExoPlayer.STATE_BUFFERING) iMediaCallback.onInfo(this, MEDIA_INFO_BUFFERING_START, MEDIA_INFO_BUFFERING_START); }
Example 6
Source File: PlayerActivity.java From exoplayer-intro with Apache License 2.0 | 6 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { String stateString; switch (playbackState) { case ExoPlayer.STATE_IDLE: stateString = "ExoPlayer.STATE_IDLE -"; break; case ExoPlayer.STATE_BUFFERING: stateString = "ExoPlayer.STATE_BUFFERING -"; break; case ExoPlayer.STATE_READY: stateString = "ExoPlayer.STATE_READY -"; break; case ExoPlayer.STATE_ENDED: stateString = "ExoPlayer.STATE_ENDED -"; break; default: stateString = "UNKNOWN_STATE -"; break; } Log.d(TAG, "changed state to " + stateString + " playWhenReady: " + playWhenReady); }
Example 7
Source File: DebugTextViewHelper.java From K-Sonic with MIT License | 6 votes |
private String getPlayerStateString() { String text = "playWhenReady:" + player.getPlayWhenReady() + " playbackState:"; switch (player.getPlaybackState()) { case ExoPlayer.STATE_BUFFERING: text += "buffering"; break; case ExoPlayer.STATE_ENDED: text += "ended"; break; case ExoPlayer.STATE_IDLE: text += "idle"; break; case ExoPlayer.STATE_READY: text += "ready"; break; default: text += "unknown"; break; } return text; }
Example 8
Source File: MainActivity.java From ExoplayerExample with The Unlicense | 6 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { Log.i(TAG,"onPlayerStateChanged: playWhenReady = "+String.valueOf(playWhenReady) +" playbackState = "+playbackState); switch (playbackState){ case ExoPlayer.STATE_ENDED: Log.i(TAG,"Playback ended!"); //Stop playback and return to start position setPlayPause(false); exoPlayer.seekTo(0); break; case ExoPlayer.STATE_READY: Log.i(TAG,"ExoPlayer ready! pos: "+exoPlayer.getCurrentPosition() +" max: "+stringForTime((int)exoPlayer.getDuration())); setProgress(); break; case ExoPlayer.STATE_BUFFERING: Log.i(TAG,"Playback buffering!"); break; case ExoPlayer.STATE_IDLE: Log.i(TAG,"ExoPlayer idle!"); break; } }
Example 9
Source File: SimpleExoPlayerView.java From K-Sonic with MIT License | 5 votes |
private void maybeShowController(boolean isForced) { if (!useController || player == null) { return; } int playbackState = player.getPlaybackState(); boolean showIndefinitely = playbackState == ExoPlayer.STATE_IDLE || playbackState == ExoPlayer.STATE_ENDED || !player.getPlayWhenReady(); boolean wasShowingIndefinitely = controller.isVisible() && controller.getShowTimeoutMs() <= 0; controller.setShowTimeoutMs(showIndefinitely ? 0 : controllerShowTimeoutMs); if (isForced || showIndefinitely || wasShowingIndefinitely) { controller.show(); } }
Example 10
Source File: CumulusTvPlayer.java From CumulusTV with MIT License | 5 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { for (Callback tvCallback : mTvCallbacks) { if (playWhenReady && playbackState == ExoPlayer.STATE_ENDED) { tvCallback.onCompleted(); } else if (playWhenReady && playbackState == ExoPlayer.STATE_READY) { tvCallback.onStarted(); } } Log.d(TAG, "Player state changed to " + playbackState + ", PWR: " + playWhenReady); }
Example 11
Source File: KExoMediaPlayer.java From K-Sonic with MIT License | 5 votes |
@Override public void start() throws IllegalStateException { if (player != null) { if (player.getPlaybackState() == ExoPlayer.STATE_ENDED) seekTo(0); else player.setPlayWhenReady(true); } }
Example 12
Source File: EventLogger.java From K-Sonic with MIT License | 5 votes |
private static 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_READY: return "R"; default: return "?"; } }
Example 13
Source File: EventLogger.java From evercam-android with GNU Affero General Public License v3.0 | 5 votes |
private static 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_READY: return "R"; default: return "?"; } }
Example 14
Source File: MediaPlayback21.java From Melophile with Apache License 2.0 | 5 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { switch (playbackState) { case ExoPlayer.STATE_READY: if (callback != null) { if (isPause) callback.onPause(); else callback.onPlay(); } break; case ExoPlayer.STATE_ENDED: if (callback != null) callback.onCompletetion(); break; } }
Example 15
Source File: PlayerContainerView.java From Anecdote with Apache License 2.0 | 5 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { switch (playbackState) { case ExoPlayer.STATE_READY: case ExoPlayer.STATE_IDLE: case ExoPlayer.STATE_BUFFERING: mIsPlaying = true; break; case ExoPlayer.STATE_ENDED: mIsPlaying = false; break; } }
Example 16
Source File: EventLogger.java From ExoPlayer-Offline with Apache License 2.0 | 5 votes |
private static 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_READY: return "R"; default: return "?"; } }
Example 17
Source File: KExoMediaPlayer.java From K-Sonic with MIT License | 5 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { if (isBuffering && (playbackState == ExoPlayer.STATE_READY || playbackState == ExoPlayer.STATE_ENDED)) { notifyOnInfo(IMediaPlayer.MEDIA_INFO_BUFFERING_END, player.getBufferedPercentage()); isBuffering = false; } if (isPreparing && playbackState == ExoPlayer.STATE_READY) { notifyOnPrepared(); isPreparing = false; } if (isSeekToing && playbackState == ExoPlayer.STATE_READY) { notifyOnSeekComplete(); isSeekToing = false; } switch (playbackState) { case ExoPlayer.STATE_IDLE: break; case ExoPlayer.STATE_BUFFERING: notifyOnInfo(IMediaPlayer.MEDIA_INFO_BUFFERING_START, player.getBufferedPercentage()); isBuffering = true; break; case ExoPlayer.STATE_READY: break; case ExoPlayer.STATE_ENDED: if (isLooping() && player != null) player.seekTo(0); else notifyOnCompletion(); break; } }
Example 18
Source File: EventLogger.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
private static 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_READY: return "R"; default: return "?"; } }
Example 19
Source File: KExoMediaPlayer.java From K-Sonic with MIT License | 5 votes |
@Override public boolean isPlaying() { if (player == null) return false; int state = player.getPlaybackState(); switch (state) { case ExoPlayer.STATE_BUFFERING: case ExoPlayer.STATE_READY: return player.getPlayWhenReady(); case ExoPlayer.STATE_IDLE: case ExoPlayer.STATE_ENDED: default: return false; } }
Example 20
Source File: YTutils.java From YTPlayer with GNU General Public License v3.0 | 5 votes |
public static String getPlayBackstate(int state) { switch (state) { case ExoPlayer.STATE_IDLE: return "IDLE"; case ExoPlayer.STATE_BUFFERING: return "BUFFERING"; case ExoPlayer.STATE_READY: return "READY"; case ExoPlayer.STATE_ENDED: return "ENDED"; } return "-1"; }