Java Code Examples for com.google.android.exoplayer2.ExoPlayer#STATE_IDLE
The following examples show how to use
com.google.android.exoplayer2.ExoPlayer#STATE_IDLE .
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: 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 2
Source File: MediaController.java From Telegram 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: 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: 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 5
Source File: ReceiveAdState.java From TubiPlayer with MIT License | 6 votes |
@Override public void performWorkAndUpdatePlayerUI(@NonNull FsmPlayer fsmPlayer) { super.performWorkAndUpdatePlayerUI(fsmPlayer); // doesn't need to do any UI work. if (isNull(fsmPlayer)) { return; } SimpleExoPlayer moviePlayer = controller.getContentPlayer(); // this mean, user jump out of the activity lifecycle in ReceivedAdState. if (moviePlayer != null && moviePlayer.getPlaybackState() == ExoPlayer.STATE_IDLE) { fsmPlayer.transit(Input.ERROR); } }
Example 6
Source File: WebPlayerView.java From Telegram 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 7
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 8
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 9
Source File: VideoPlayer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public VideoPlayer() { mediaDataSourceFactory = new ExtendedDefaultDataSourceFactory(ApplicationLoader.applicationContext, BANDWIDTH_METER, new DefaultHttpDataSourceFactory("Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)", BANDWIDTH_METER)); mainHandler = new Handler(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); lastReportedPlaybackState = ExoPlayer.STATE_IDLE; NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.playerDidStartPlaying); }
Example 10
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 11
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 12
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 13
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"; }
Example 14
Source File: UserController.java From TubiPlayer with MIT License | 5 votes |
private void updateProgress() { long position = mPlayer == null ? 0 : mPlayer.getCurrentPosition(); long duration = mPlayer == null ? 0 : mPlayer.getDuration(); long bufferedPosition = mPlayer == null ? 0 : mPlayer.getBufferedPosition(); //only update the seekBar UI when user are not interacting, to prevent UI interference if (!isDraggingSeekBar.get() && !isDuringCustomSeek()) { updateSeekBar(position, duration, bufferedPosition); updateTimeTextViews(position, duration); } ExoPlayerLogger.i(TAG, "updateProgress:----->" + videoCurrentTime.get()); if (mPlaybackActionCallback != null && mPlaybackActionCallback.isActive()) { mPlaybackActionCallback.onProgress(mMediaModel, position, duration); } mProgressUpdateHandler.removeCallbacks(updateProgressAction); // Schedule an update if necessary. if (playerPlaybackState.get() != ExoPlayer.STATE_IDLE && playerPlaybackState.get() != STATE_ENDED && mPlaybackActionCallback .isActive()) { //don't post the updateProgress event when user pause the video if (mPlayer != null && !mPlayer.getPlayWhenReady()) { return; } long delayMs = DEFAULT_FREQUENCY; mProgressUpdateHandler.postDelayed(updateProgressAction, delayMs); } }
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 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 17
Source File: VideoPlayer.java From Telegram with GNU General Public License v2.0 | 5 votes |
public VideoPlayer() { mediaDataSourceFactory = new ExtendedDefaultDataSourceFactory(ApplicationLoader.applicationContext, BANDWIDTH_METER, new DefaultHttpDataSourceFactory("Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)", BANDWIDTH_METER)); mainHandler = new Handler(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); lastReportedPlaybackState = ExoPlayer.STATE_IDLE; NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.playerDidStartPlaying); }
Example 18
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 19
Source File: VideoPlayer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public VideoPlayer() { mediaDataSourceFactory = new ExtendedDefaultDataSourceFactory(ApplicationLoader.applicationContext, BANDWIDTH_METER, new DefaultHttpDataSourceFactory("Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)", BANDWIDTH_METER)); mainHandler = new Handler(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(BANDWIDTH_METER); trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); lastReportedPlaybackState = ExoPlayer.STATE_IDLE; NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.playerDidStartPlaying); }
Example 20
Source File: UserController.java From TubiPlayer with MIT License | 4 votes |
private void setPlaybackState() { int playBackState = mPlayer == null ? ExoPlayer.STATE_IDLE : mPlayer.getPlaybackState(); playerPlaybackState.set(playBackState); }