Java Code Examples for com.google.android.exoplayer.ExoPlayer#STATE_ENDED
The following examples show how to use
com.google.android.exoplayer.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: IjkExoMediaPlayer.java From AndroidTvDemo with Apache License 2.0 | 6 votes |
@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; } }
Example 2
Source File: EventLogger.java From AndroidTvDemo with Apache License 2.0 | 6 votes |
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 "?"; } }
Example 3
Source File: DurationLogger.java From iview-android-tv with MIT License | 6 votes |
@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); }
Example 4
Source File: EventLogger.java From Mobilyzer with Apache License 2.0 | 6 votes |
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 "?"; } }
Example 5
Source File: DurationLogger.java From iview-android-tv with MIT License | 6 votes |
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); }
Example 6
Source File: ExVidPlayerImp.java From ExVidPlayer with Apache License 2.0 | 6 votes |
@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); }
Example 7
Source File: EventLogger.java From iview-android-tv with MIT License | 6 votes |
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 "?"; } }
Example 8
Source File: EventLogger.java From Android-Example-HLS-ExoPlayer with Apache License 2.0 | 6 votes |
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 "?"; } }
Example 9
Source File: IjkExoMediaPlayer.java From WliveTV with Apache License 2.0 | 6 votes |
@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; } }
Example 10
Source File: ImaPlayer.java From google-media-framework-android with Apache License 2.0 | 5 votes |
/** * We notify all callbacks when the ad ends. * @param playWhenReady Whether the video should play as soon as it is loaded. * @param playbackState The state of the Exoplayer instance. */ @Override public void onStateChanged(boolean playWhenReady, int playbackState) { if (playbackState == ExoPlayer.STATE_ENDED) { for (VideoAdPlayer.VideoAdPlayerCallback callback : callbacks) { callback.onEnded(); } } }
Example 11
Source File: VideoPlayerView.java From iview-android-tv with MIT License | 5 votes |
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"; showStatusText(R.string.buffering); break; case ExoPlayer.STATE_ENDED: text += "ended"; break; case ExoPlayer.STATE_IDLE: text += "idle"; break; case ExoPlayer.STATE_PREPARING: text += "preparing"; showStatusText(R.string.loading); break; case ExoPlayer.STATE_READY: text += "ready"; hideStatusText(); showShutter(false); if (mPlayer != null && mPlayer.isPlaying()) { hideControlsDelayed(); } break; default: text += "unknown"; break; } playerStateTextView.setText(text); }
Example 12
Source File: PlayerActivity.java From Android-Example-HLS-ExoPlayer with Apache License 2.0 | 5 votes |
@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(); }
Example 13
Source File: EventLogger.java From Mobilyzer with Apache License 2.0 | 5 votes |
@Override public void onStateChanged(boolean playWhenReady, int state) { Log.d(TAG, "state [" + getSessionTimeString() + ", " + playWhenReady + ", " + getStateString(state) + "]"); // DecimalFormat df = new DecimalFormat("#.##"); switch(state) { case ExoPlayer.STATE_PREPARING: // this.bitrateVarience.add(Pair.create("0.00", currentBitrate)); this.initialLoadingTime_s = Double.parseDouble(getSessionTimeString()); break; case ExoPlayer.STATE_BUFFERING: bufferCounter++; bufferTime_s = Double.parseDouble(getSessionTimeString()); break; case ExoPlayer.STATE_READY: if (bufferCounter == 1) { this.initialLoadingTime = Double.parseDouble(String.format("%.2f", Double.parseDouble(getSessionTimeString()) - this.initialLoadingTime_s)); } else { this.rebufferTime.add(Double.parseDouble(String.format("%.2f", Double.parseDouble(getSessionTimeString()) - bufferTime_s))); } break; case ExoPlayer.STATE_ENDED: this.videoBitrateVarience.add(Pair.create(getSessionTimeString(), this.previousVideoBitrate)); this.audioBitrateVarience.add(Pair.create(getSessionTimeString(), this.previousAudioBitrate)); // printStatInfo(); break; } }
Example 14
Source File: VideoPlayerActivity.java From droidkaigi2016 with Apache License 2.0 | 5 votes |
@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; } Log.d(TAG, text); }
Example 15
Source File: VideoPlayerActivity.java From droidkaigi2016 with Apache License 2.0 | 5 votes |
@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; } Log.d(TAG, text); }
Example 16
Source File: VideoPlayerService.java From Mobilyzer with Apache License 2.0 | 5 votes |
@Override public void onStateChanged(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_PREPARING: text += "preparing"; break; case ExoPlayer.STATE_READY: text += "ready"; break; default: text += "unknown"; break; } Log.e("", text); if (playbackState == ExoPlayer.STATE_ENDED) { Log.e("", "Playback ended!"); releasePlayer(true); this.stopSelf(); } // playerStateTextView.setText(text); }
Example 17
Source File: DemoPlayer.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Override public void onPlayerStateChanged(boolean playWhenReady, int state) { for (Callback tvCallback : mTvPlayerCallbacks) { if (playWhenReady && state == ExoPlayer.STATE_ENDED) { tvCallback.onCompleted(); } else if (playWhenReady && state == ExoPlayer.STATE_READY) { tvCallback.onStarted(); } } maybeReportPlayerState(); }
Example 18
Source File: IjkExoMediaPlayer.java From WliveTV with Apache License 2.0 | 4 votes |
public void onStateChanged(boolean playWhenReady, int playbackState) { if (mIsBuffering) { switch (playbackState) { case ExoPlayer.STATE_ENDED: case ExoPlayer.STATE_READY: notifyOnInfo(IMediaPlayer.MEDIA_INFO_BUFFERING_END, mInternalPlayer.getBufferedPercentage()); mIsBuffering = false; break; } } if (mIsPrepareing) { switch (playbackState) { case ExoPlayer.STATE_READY: notifyOnPrepared(); mIsPrepareing = false; mDidPrepare = false; break; } } switch (playbackState) { case ExoPlayer.STATE_IDLE: notifyOnCompletion(); break; case ExoPlayer.STATE_PREPARING: mIsPrepareing = true; break; case ExoPlayer.STATE_BUFFERING: notifyOnInfo(IMediaPlayer.MEDIA_INFO_BUFFERING_START, mInternalPlayer.getBufferedPercentage()); mIsBuffering = true; break; case ExoPlayer.STATE_READY: break; case ExoPlayer.STATE_ENDED: notifyOnCompletion(); break; default: break; } }
Example 19
Source File: IjkExoMediaPlayer.java From talk-android with MIT License | 4 votes |
public void onStateChanged(boolean playWhenReady, int playbackState) { if (mIsBuffering) { switch (playbackState) { case ExoPlayer.STATE_ENDED: case ExoPlayer.STATE_READY: notifyOnInfo(IMediaPlayer.MEDIA_INFO_BUFFERING_END, mInternalPlayer.getBufferedPercentage()); mIsBuffering = false; break; } } if (mIsPrepareing) { switch (playbackState) { case ExoPlayer.STATE_READY: notifyOnPrepared(); mIsPrepareing = false; mDidPrepare = false; break; } } switch (playbackState) { case ExoPlayer.STATE_IDLE: notifyOnCompletion(); break; case ExoPlayer.STATE_PREPARING: mIsPrepareing = true; break; case ExoPlayer.STATE_BUFFERING: notifyOnInfo(IMediaPlayer.MEDIA_INFO_BUFFERING_START, mInternalPlayer.getBufferedPercentage()); mIsBuffering = true; break; case ExoPlayer.STATE_READY: break; case ExoPlayer.STATE_ENDED: notifyOnCompletion(); break; default: break; } }
Example 20
Source File: IjkExoMediaPlayer.java From AndroidTvDemo with Apache License 2.0 | 4 votes |
public void onStateChanged(boolean playWhenReady, int playbackState) { if (mIsBuffering) { switch (playbackState) { case ExoPlayer.STATE_ENDED: case ExoPlayer.STATE_READY: notifyOnInfo(IMediaPlayer.MEDIA_INFO_BUFFERING_END, mInternalPlayer.getBufferedPercentage()); mIsBuffering = false; break; } } if (mIsPrepareing) { switch (playbackState) { case ExoPlayer.STATE_READY: notifyOnPrepared(); mIsPrepareing = false; mDidPrepare = false; break; } } switch (playbackState) { case ExoPlayer.STATE_IDLE: notifyOnCompletion(); break; case ExoPlayer.STATE_PREPARING: mIsPrepareing = true; break; case ExoPlayer.STATE_BUFFERING: notifyOnInfo(IMediaPlayer.MEDIA_INFO_BUFFERING_START, mInternalPlayer.getBufferedPercentage()); mIsBuffering = true; break; case ExoPlayer.STATE_READY: break; case ExoPlayer.STATE_ENDED: notifyOnCompletion(); break; default: break; } }