@Override protected void doActionImpl( SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) { player.setPlayWhenReady(playWhenReady); }
@Override public void start() throws IllegalStateException { if (mInternalPlayer == null) return; mInternalPlayer.setPlayWhenReady(true); }
@Override public void pause() throws IllegalStateException { if (mInternalPlayer == null) return; mInternalPlayer.setPlayWhenReady(false); }
@Override public void start() { simpleExoPlayer.setPlayWhenReady(true); }
@Override public void pause() { simpleExoPlayer.setPlayWhenReady(false); }
@Override public void start() { mInternalPlayer.setPlayWhenReady(true); }
private void onAudioFocusLoss() { Log.d(TAG, "onAudioFocusLoss() called"); player.setPlayWhenReady(false); }
@Override protected void doActionImpl( SimpleExoPlayer player, DefaultTrackSelector trackSelector, Surface surface) { player.setPlayWhenReady(playWhenReady); }
public void onPause() { if (DEBUG) Log.d(TAG, "onPause() called"); if (audioReactor == null || simpleExoPlayer == null) return; audioReactor.abandonAudioFocus(); simpleExoPlayer.setPlayWhenReady(false); }
@Override public void pause() { int state = getState(); if(isInPlaybackState() && state!=STATE_END && state!=STATE_ERROR && state!=STATE_IDLE && state!=STATE_INITIALIZED && state!=STATE_PAUSED && state!=STATE_STOPPED) mInternalPlayer.setPlayWhenReady(false); }
private void onAudioFocusGain() { Log.d(TAG, "onAudioFocusGain() called"); player.setVolume(DUCK_AUDIO_TO); animateAudio(DUCK_AUDIO_TO, 1f); if (PlayerHelper.isResumeAfterAudioFocusGain(context)) { player.setPlayWhenReady(true); } }
@Override public void resume() { if(isInPlaybackState() && getState() == STATE_PAUSED) mInternalPlayer.setPlayWhenReady(true); }
@Override public void onStopTrackingTouch(SeekBar seekBar) { if (DEBUG) Log.d(TAG, "onStopTrackingTouch() called with: seekBar = [" + seekBar + "]"); seekTo(seekBar.getProgress()); if (wasPlaying || simpleExoPlayer.getDuration() == seekBar.getProgress()) simpleExoPlayer.setPlayWhenReady(true); playbackCurrentTime.setText(getTimeString(seekBar.getProgress())); animateView(currentDisplaySeek, AnimationUtils.Type.SCALE_AND_ALPHA, false, 200); if (getCurrentState() == STATE_PAUSED_SEEK) changeState(STATE_BUFFERING); if (!isProgressLoopRunning()) startProgressLoop(); }
public void onPlay() { if (DEBUG) Log.d(TAG, "onPlay() called"); if (audioReactor == null || playQueue == null || simpleExoPlayer == null) return; audioReactor.requestAudioFocus(); if (getCurrentState() == STATE_COMPLETED) { if (playQueue.getIndex() == 0) { seekToDefault(); } else { playQueue.setIndex(0); } } simpleExoPlayer.setPlayWhenReady(true); }
@Override public int onStartCommand(final Intent intent, int flags, int startId) { if (DEBUG) Log.d(TAG, "onStartCommand() called with: intent = [" + intent + "], flags = [" + flags + "], startId = [" + startId + "]"); if (playerImpl.getPlayer() == null) { initPopup(); initPopupCloseOverlay(); } if (!playerImpl.isPlaying()) playerImpl.getPlayer().setPlayWhenReady(true); playerImpl.handleIntent(intent); return START_NOT_STICKY; }
@Override public void onStartTrackingTouch(SeekBar seekBar) { if (DEBUG) Log.d(TAG, "onStartTrackingTouch() called with: seekBar = [" + seekBar + "]"); if (getCurrentState() != STATE_PAUSED_SEEK) changeState(STATE_PAUSED_SEEK); wasPlaying = simpleExoPlayer.getPlayWhenReady(); if (isPlaying()) simpleExoPlayer.setPlayWhenReady(false); showControls(0); animateView(currentDisplaySeek, AnimationUtils.Type.SCALE_AND_ALPHA, true, DEFAULT_CONTROLS_DURATION); }
public void init(Context context, PlayerView playerView) { // Create a default track selector. TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(); TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); // Create a player instance. player = ExoPlayerFactory.newSimpleInstance(context, trackSelector); // Bind the player to the view. playerView.setPlayer(player); // This is the MediaSource representing the content media (i.e. not the ad). String contentUrl = context.getString(R.string.content_url); MediaSource contentMediaSource = buildMediaSource(Uri.parse(contentUrl)); // Compose the content media source into a new AdsMediaSource with both ads and content. MediaSource mediaSourceWithAds = new AdsMediaSource( contentMediaSource, /* adMediaSourceFactory= */ this, adsLoader, playerView.getOverlayFrameLayout()); // Prepare the player with the source. player.seekTo(contentPosition); player.prepare(mediaSourceWithAds); player.setPlayWhenReady(true); }
public void initPlayer(final boolean playOnReady) { if (DEBUG) Log.d(TAG, "initPlayer() called with: context = [" + context + "]"); simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(renderFactory, trackSelector, loadControl); simpleExoPlayer.addListener(this); simpleExoPlayer.setPlayWhenReady(playOnReady); simpleExoPlayer.setSeekParameters(PlayerHelper.getSeekParameters(context)); audioReactor = new AudioReactor(context, simpleExoPlayer); mediaSessionManager = new MediaSessionManager(context, simpleExoPlayer, new BasePlayerMediaSession(this)); registerBroadcastReceiver(); }
@Override public final void onStart(HostActivity host, Surface surface) { this.surface = surface; // Build the player. trackSelector = buildTrackSelector(host); String userAgent = "ExoPlayerPlaybackTests"; DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = buildDrmSessionManager(userAgent); player = buildExoPlayer(host, surface, trackSelector, drmSessionManager); player.prepare(buildSource(host, Util.getUserAgent(host, userAgent))); player.addAnalyticsListener(this); player.addAnalyticsListener(new EventLogger(trackSelector, tag)); if (analyticsListener != null) { player.addAnalyticsListener(analyticsListener); } player.setPlayWhenReady(true); actionHandler = Clock.DEFAULT.createHandler(Looper.myLooper(), /* callback= */ null); // Schedule any pending actions. if (pendingSchedule != null) { pendingSchedule.start(player, trackSelector, surface, actionHandler, /* callback= */ null); pendingSchedule = null; } }
@Override public final void onStart(HostActivity host, Surface surface) { this.surface = surface; // Build the player. trackSelector = buildTrackSelector(host); String userAgent = "ExoPlayerPlaybackTests"; DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = buildDrmSessionManager(userAgent); player = buildExoPlayer(host, surface, trackSelector, drmSessionManager); player.prepare(buildSource(host, Util.getUserAgent(host, userAgent))); player.addAnalyticsListener(this); player.addAnalyticsListener(new EventLogger(trackSelector, tag)); if (analyticsListener != null) { player.addAnalyticsListener(analyticsListener); } player.setPlayWhenReady(true); actionHandler = Clock.DEFAULT.createHandler(Looper.myLooper(), /* callback= */ null); // Schedule any pending actions. if (pendingSchedule != null) { pendingSchedule.start(player, trackSelector, surface, actionHandler, /* callback= */ null); pendingSchedule = null; } }