// [START ExoplayerWrapper.PlaybackListener region] @Override public void onStateChanged(boolean playWhenReady, int playbackState) { switch (playbackState) { case ExoPlayer.STATE_READY: if (playWhenReady) { if (mReadiness != KState.READY) { mReadiness = KState.READY; updateAdVideoTrackQuality(); mListener.adDurationUpdate((float) mAdPlayer.getDuration() / 1000); } for (VideoAdPlayer.VideoAdPlayerCallback callback : mAdCallbacks) { callback.onPlay(); } } else if (currentPosition > 0) { mAdPlayer.seek(currentPosition, true); isSeeking = true; currentPosition = 0; } else if (isSeeking) { isSeeking = false; mAdPlayer.play(); } else { for (VideoAdPlayer.VideoAdPlayerCallback callback : mAdCallbacks) { callback.onPause(); } } break; case ExoPlayer.STATE_ENDED: removeAd(); for (VideoAdPlayer.VideoAdPlayerCallback callback : mAdCallbacks) { callback.onEnded(); } mReadiness = KState.IDLE; break; } }
public void pauseAdCallback() { for (VideoAdPlayer.VideoAdPlayerCallback callback : mAdCallbacks) { callback.onPause(); } }