Java Code Examples for com.google.android.exoplayer2.ExoPlayer#STATE_READY
The following examples show how to use
com.google.android.exoplayer2.ExoPlayer#STATE_READY .
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: ExoPlayerAdapter.java From tv-samples with Apache License 2.0 | 6 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { mBufferingStart = false; if (playbackState == ExoPlayer.STATE_READY && !mInitialized) { mInitialized = true; if (mSurfaceHolderGlueHost == null || mHasDisplay) { getCallback().onPreparedStateChanged(ExoPlayerAdapter.this); } } else if (playbackState == ExoPlayer.STATE_BUFFERING) { mBufferingStart = true; } else if (playbackState == ExoPlayer.STATE_ENDED) { getCallback().onPlayStateChanged(ExoPlayerAdapter.this); getCallback().onPlayCompleted(ExoPlayerAdapter.this); } notifyBufferingStartEnd(); }
Example 2
Source File: MediaController.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void onStateChanged(boolean playWhenReady, int playbackState) { if (tag != playerNum) { return; } if (playbackState == ExoPlayer.STATE_ENDED || (playbackState == ExoPlayer.STATE_IDLE || playbackState == ExoPlayer.STATE_BUFFERING) && playWhenReady && messageObject.audioProgress >= 0.999f) { if (!playlist.isEmpty() && (playlist.size() > 1 || !messageObject.isVoice())) { playNextMessageWithoutOrder(true); } else { cleanupPlayer(true, true, messageObject != null && messageObject.isVoice(), false); } } else if (seekToProgressPending != 0 && (playbackState == ExoPlayer.STATE_READY || playbackState == ExoPlayer.STATE_IDLE)) { int seekTo = (int) (audioPlayer.getDuration() * seekToProgressPending); audioPlayer.seekTo(seekTo); lastProgress = seekTo; seekToProgressPending = 0; } }
Example 3
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 4
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 5
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 6
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 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: ExoPlayerAdapter.java From leanback-showcase with Apache License 2.0 | 6 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { mBufferingStart = false; if (playbackState == ExoPlayer.STATE_READY && !mInitialized) { mInitialized = true; if (mSurfaceHolderGlueHost == null || mHasDisplay) { getCallback().onPreparedStateChanged(ExoPlayerAdapter.this); } } else if (playbackState == ExoPlayer.STATE_BUFFERING) { mBufferingStart = true; } else if (playbackState == ExoPlayer.STATE_ENDED) { getCallback().onPlayStateChanged(ExoPlayerAdapter.this); getCallback().onPlayCompleted(ExoPlayerAdapter.this); } notifyBufferingStartEnd(); }
Example 9
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 10
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 11
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 12
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 13
Source File: VideoExoPlayer.java From TigerVideo with Apache License 2.0 | 5 votes |
/**--------------------- ExoPlayer.EventListener ----------------------------**/ @Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { if(playbackState == ExoPlayer.STATE_ENDED) {//播放结束 onCompletion(); } else if(playbackState == ExoPlayer.STATE_READY) {//准备播放 if(getState() == PlayState.STATE_LOADING) {//加载视频 onPrepared(); } else if(getState() == PlayState.STATE_PLAYING_BUFFERING_START) {//seek to complete onSeekComplete(); } } }
Example 14
Source File: VideoExoPlayer.java From TigerVideo with Apache License 2.0 | 5 votes |
@Override public void play() { if(mExoPlayer.getPlaybackState() == ExoPlayer.STATE_READY) { mExoPlayer.setPlayWhenReady(true); } }
Example 15
Source File: EventLogger.java From TigerVideo 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 16
Source File: EventLogger.java From LiveVideoBroadcaster 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: 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 18
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 19
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 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"; }