Java Code Examples for com.google.android.exoplayer2.Player#STATE_BUFFERING
The following examples show how to use
com.google.android.exoplayer2.Player#STATE_BUFFERING .
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: VideoPlayer.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { switch(playbackState) { case Player.STATE_IDLE: case Player.STATE_BUFFERING: case Player.STATE_ENDED: window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); break; case Player.STATE_READY: if (playWhenReady) { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } notifyPlayerReady(); break; default: break; } }
Example 2
Source File: LocalPlayback.java From klingar with Apache License 2.0 | 6 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { Timber.d("onPlayerStateChanged %s playWhenReady %s", getExoPlayerState(playbackState), playWhenReady); switch (playbackState) { case Player.STATE_IDLE: case Player.STATE_BUFFERING: case Player.STATE_READY: if (callback != null) { callback.onPlaybackStatusChanged(); } break; case Player.STATE_ENDED: if (callback != null) { callback.onCompletion(); } break; default: break; } }
Example 3
Source File: ExoVideoPlaybackControlView.java From ExoVideoView with Apache License 2.0 | 6 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { if (playbackState != Player.STATE_IDLE && centerError != null && centerError.getVisibility() == VISIBLE) { centerError.setVisibility(GONE); } if (playbackState == Player.STATE_IDLE || playbackState == Player.STATE_BUFFERING) { removeCallbacks(hideAction); showUtilHideCalled(); showLoading(true); } else if (playbackState == Player.STATE_READY && player.getPlayWhenReady() || playbackState == Player.STATE_ENDED) { showLoading(false); hide(); } updatePlayPauseButton(); updateProgress(); }
Example 4
Source File: ExoPlayerImpl.java From MediaSDK with Apache License 2.0 | 6 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { LogUtils.d("onPlayerStateChanged playWhenReady="+playWhenReady+", playbackState="+playbackState); switch(playbackState) { case Player.STATE_BUFFERING: break; case Player.STATE_IDLE: break; case Player.STATE_READY: if (mPrepareState == PREPARING_STATE) { notifyOnPrepared(); mPrepareState = PREPARED_STATE; } break; case Player.STATE_ENDED: break; default: break; } }
Example 5
Source File: AudioFocusManager.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
/** * Sets audio attributes that should be used to manage audio focus. * * @param audioAttributes The audio attributes or {@code null} if audio focus should not be * managed automatically. * @param playWhenReady The current state of {@link ExoPlayer#getPlayWhenReady()}. * @param playerState The current player state; {@link ExoPlayer#getPlaybackState()}. * @return A {@link PlayerCommand} to execute on the player. */ @PlayerCommand public int setAudioAttributes( @Nullable AudioAttributes audioAttributes, boolean playWhenReady, int playerState) { if (!Util.areEqual(this.audioAttributes, audioAttributes)) { this.audioAttributes = audioAttributes; focusGain = convertAudioAttributesToFocusGain(audioAttributes); Assertions.checkArgument( focusGain == C.AUDIOFOCUS_GAIN || focusGain == C.AUDIOFOCUS_NONE, "Automatic handling of audio focus is only available for USAGE_MEDIA and USAGE_GAME."); if (playWhenReady && (playerState == Player.STATE_BUFFERING || playerState == Player.STATE_READY)) { return requestAudioFocus(); } } return playerState == Player.STATE_IDLE ? handleIdle(playWhenReady) : handlePrepare(playWhenReady); }
Example 6
Source File: ExoMediaPlayer.java From DKVideoPlayer with Apache License 2.0 | 6 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { if (mPlayerEventListener == null) return; if (mIsPreparing) return; if (mLastReportedPlayWhenReady != playWhenReady || mLastReportedPlaybackState != playbackState) { switch (playbackState) { case Player.STATE_BUFFERING: mPlayerEventListener.onInfo(MEDIA_INFO_BUFFERING_START, getBufferedPercentage()); mIsBuffering = true; break; case Player.STATE_READY: if (mIsBuffering) { mPlayerEventListener.onInfo(MEDIA_INFO_BUFFERING_END, getBufferedPercentage()); mIsBuffering = false; } break; case Player.STATE_ENDED: mPlayerEventListener.onCompletion(); break; } mLastReportedPlaybackState = playbackState; mLastReportedPlayWhenReady = playWhenReady; } }
Example 7
Source File: ReactExoplayerView.java From react-native-video with MIT License | 6 votes |
private void startPlayback() { if (player != null) { switch (player.getPlaybackState()) { case Player.STATE_IDLE: case Player.STATE_ENDED: initializePlayer(); break; case Player.STATE_BUFFERING: case Player.STATE_READY: if (!player.getPlayWhenReady()) { setPlayWhenReady(true); } break; default: break; } } else { initializePlayer(); } if (!disableFocus) { setKeepScreenOn(preventsDisplaySleepDuringVideoPlayback); } }
Example 8
Source File: LocalPlayback.java From klingar with Apache License 2.0 | 6 votes |
@Override @State public int getState() { if (exoPlayer == null) { return exoPlayerNullIsStopped ? PlaybackStateCompat.STATE_STOPPED : PlaybackStateCompat.STATE_NONE; } switch (exoPlayer.getPlaybackState()) { case Player.STATE_IDLE: case Player.STATE_ENDED: return PlaybackStateCompat.STATE_PAUSED; case Player.STATE_BUFFERING: return PlaybackStateCompat.STATE_BUFFERING; case Player.STATE_READY: return exoPlayer.getPlayWhenReady() ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED; default: return PlaybackStateCompat.STATE_NONE; } }
Example 9
Source File: ExoPlayerHelper.java From ExoPlayer-Wrapper with Apache License 2.0 | 5 votes |
@Override public void run() { if (mPlayer != null && mPlayer.getPlaybackState() == Player.STATE_BUFFERING && mPlayer.getPlayWhenReady()) { Log.e("zaq", "Player.STATE_BUFFERING stuck issue"); mPlayer.seekTo(mPlayer.getContentPosition() > 500 ? mPlayer.getContentPosition() - 500 : 0); } }
Example 10
Source File: Alarmio.java From Alarmio with Apache License 2.0 | 5 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { switch (playbackState) { case Player.STATE_BUFFERING: case Player.STATE_READY: // We are idle while switching from HLS to Progressive streaming case Player.STATE_IDLE: break; default: currentStream = null; break; } }
Example 11
Source File: ExoPlayerHelper.java From ExoPlayer-Wrapper with Apache License 2.0 | 5 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { if (mExoPlayerListener == null || mPlayer == null) { return; } switch (playbackState) { case Player.STATE_READY: if (playWhenReady) { onPlayerPlaying(); mExoPlayerListener.onPlayerPlaying(mPlayer.getCurrentWindowIndex()); } else { onPlayerPaused(); mExoPlayerListener.onPlayerPaused(mPlayer.getCurrentWindowIndex()); } break; case Player.STATE_BUFFERING: onPlayerBuffering(); mExoPlayerListener.onPlayerBuffering(mPlayer.getCurrentWindowIndex()); break; case Player.STATE_ENDED: mExoPlayerListener.onPlayerStateEnded(mPlayer.getCurrentWindowIndex()); break; case Player.STATE_IDLE: mExoPlayerListener.onPlayerStateIdle(mPlayer.getCurrentWindowIndex()); break; default: Log.e("ExoPlayerHelper-zaq", "onPlayerStateChanged unknown: " + playbackState); } }
Example 12
Source File: ExoMediaPlayer.java From PlayerBase with Apache License 2.0 | 5 votes |
@Override public boolean isPlaying() { if (mInternalPlayer == null) return false; int state = mInternalPlayer.getPlaybackState(); switch (state) { case Player.STATE_BUFFERING: case Player.STATE_READY: return mInternalPlayer.getPlayWhenReady(); case Player.STATE_IDLE: case Player.STATE_ENDED: default: return false; } }
Example 13
Source File: EventLogger.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static String getStateString(int state) { switch (state) { case Player.STATE_BUFFERING: return "BUFFERING"; case Player.STATE_ENDED: return "ENDED"; case Player.STATE_IDLE: return "IDLE"; case Player.STATE_READY: return "READY"; default: return "?"; } }
Example 14
Source File: ExoPlayerFragment.java From carstream-android-auto with Apache License 2.0 | 5 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { if (playbackState == Player.STATE_BUFFERING) { BroadcastFromUI.broadCastLoading(getContext()); } else if (playbackState == Player.STATE_ENDED) { BroadcastFromUI.broadCastPaused(getContext(), String.valueOf(titleView.getText())); } else if (playWhenReady && playbackState == Player.STATE_READY) { BroadcastFromUI.broadCastPlaying(getContext(), String.valueOf(titleView.getText())); playerFocusHelper.play(); } else if (playWhenReady) { BroadcastFromUI.broadCastLoading(getContext()); } else { BroadcastFromUI.broadCastPaused(getContext(), String.valueOf(titleView.getText())); } }
Example 15
Source File: EventLogger.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static String getStateString(int state) { switch (state) { case Player.STATE_BUFFERING: return "BUFFERING"; case Player.STATE_ENDED: return "ENDED"; case Player.STATE_IDLE: return "IDLE"; case Player.STATE_READY: return "READY"; default: return "?"; } }
Example 16
Source File: SingleMediaManager.java From ChatMessagesAdapter-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void parsePlayerEvent(int playbackState) { switch (playbackState) { case Player.STATE_BUFFERING: break; case Player.STATE_ENDED: notifyListenersOnStop(); break; case Player.STATE_IDLE: break; case Player.STATE_READY: break; default: break; } }
Example 17
Source File: EventLogger.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
private static String getStateString(int state) { switch (state) { case Player.STATE_BUFFERING: return "B"; case Player.STATE_ENDED: return "E"; case Player.STATE_IDLE: return "I"; case Player.STATE_READY: return "R"; default: return "?"; } }
Example 18
Source File: IjkExo2MediaPlayer.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
@Override public boolean isPlaying() { if (mInternalPlayer == null) return false; int state = mInternalPlayer.getPlaybackState(); switch (state) { case Player.STATE_BUFFERING: case Player.STATE_READY: return mInternalPlayer.getPlayWhenReady(); case Player.STATE_IDLE: case Player.STATE_ENDED: default: return false; } }
Example 19
Source File: EventLogger.java From MediaSDK with Apache License 2.0 | 5 votes |
private static String getStateString(int state) { switch (state) { case Player.STATE_BUFFERING: return "BUFFERING"; case Player.STATE_ENDED: return "ENDED"; case Player.STATE_IDLE: return "IDLE"; case Player.STATE_READY: return "READY"; default: return "?"; } }
Example 20
Source File: JerryAudioController.java From tysq-android with GNU General Public License v3.0 | 4 votes |
/** * 播放状态改变回调 * * @param playWhenReady 是否准备完之后立马播放 * @param playbackState 播放状态 */ @Override public void onPlayerStateChanged(boolean playWhenReady, int playbackState) { String stateString; switch (playbackState) { case Player.STATE_IDLE: // 暂停 stateString = "ExoPlayer.STATE_IDLE -"; pause(); break; case Player.STATE_BUFFERING: // 缓冲 stateString = "ExoPlayer.STATE_BUFFERING -"; // loading 回调 loading(); break; case Player.STATE_READY: // 就绪 stateString = "ExoPlayer.STATE_READY -"; ready(); break; case Player.STATE_ENDED: // 结束 stateString = "ExoPlayer.STATE_ENDED -"; end(); break; default: stateString = "UNKNOWN_STATE -"; error("UNKNOWN_STATE"); break; } if (IS_DEBUG) { Log.i(TAG, "--\n" + (mMediaInfo == null ? "null" : mMediaInfo.toString()) + "\n " + "[changed state to " + stateString + "]\n" + "[playWhenReady: " + playWhenReady + "]"); } }