/** * Should be called on player destruction to prevent leakage. * */ public void dispose() { this.sessionConnector.setPlayer(null, null); this.sessionConnector.setQueueNavigator(null); this.mediaSession.setActive(false); this.mediaSession.release(); } }
mSession.release();
@Override protected void onStop() { super.onStop(); // On entering Picture-in-Picture mode, onPause is called, but not onStop. // For this reason, this is the place where we should pause the video playback. mMovieView.pause(); mSession.release(); mSession = null; }
public void closeMediaNotification() { //Remove the notification NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(MPRIS_MEDIA_NOTIFICATION_ID); //Clear the current player and media session notificationPlayer = null; if (mediaSession != null) { mediaSession.release(); mediaSession = null; } }
private void doCloseSession() { if (mediaSession != null) { mediaSession.setActive(false); mediaSession.release(); mediaSession = null; } }
void destroyNotification() { if (!isNotificationShown()) return; notificationManager.cancel(NOTIFICATION_ID); notification = null; mediaSession.release(); }
@Override public void onDestroy() { mMediaNotificationManager.onDestroy(); mPlayback.stop(); mSession.release(); Log.d(TAG, "onDestroy: MediaPlayerAdapter stopped, and MediaSession released"); }
private void tearDownAudioPlayerRemote() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); if (audioManager != null) { audioManager.abandonAudioFocus(this); } mediaSession.release(); }
public void release() { mMediaSession.setCallback(null); mMediaSession.setActive(false); mMediaSession.release(); }
@Override public boolean onUnbind(Intent intent) { mediaSession.release(); removeNotification(); return super.onUnbind(intent); }
@Override public void onDestroy() { super.onDestroy(); mPlaybackManager.handleStopRequest(null); mNotificationFactory.stopNotification(); mDelayedStopHandler.removeCallbacksAndMessages(null); mediaSession.release(); }
@Override public void onDestroy() { pause(); exoPlayer.release(); exoPlayer.removeListener(this); if(telephonyManager != null) telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE); notificationManager.cancelNotify(); mediaSession.release(); unregisterReceiver(becomingNoisyReceiver); super.onDestroy(); }
void destroy() { playerWakeLocks.destroy(); disposables.clear(); networkConnectionHelper.endListenForNetworkChanges(); player.removeAnalyticsListener(playerEventHandler); player.release(); mediaSession.release(); }
@Override protected void onStop() { super.onStop(); BackgroundService.removeGuiInUseCounter(this); if (mMediaSession != null) { PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE); boolean screenOn; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { screenOn = pm.isInteractive(); } else { screenOn = pm.isScreenOn(); } if (screenOn) { mMediaSession.release(); } // else we are in the lockscreen, keep the mediasession } }
private void clearNotification() { if (mMediaNotificationInfo == null) return; NotificationManagerCompat manager = NotificationManagerCompat.from(mContext); manager.cancel(mMediaNotificationInfo.id); if (mMediaSession != null) { mMediaSession.setCallback(null); mMediaSession.setActive(false); mMediaSession.release(); mMediaSession = null; } mContext.stopService(createIntent(mContext)); mMediaNotificationInfo = null; }
executor = null; tts.stop(); mediaSession.release(); mediaSession = null; mediaPlayerPageFlip.release();
@Override public void onDestroy() { if (D) Log.d(TAG, "Destroying service"); super.onDestroy(); // Remove any sound effects final Intent audioEffectsIntent = new Intent( AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION); audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId()); audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(audioEffectsIntent); mAlarmManager.cancel(mShutdownIntent); mPlayerHandler.removeCallbacksAndMessages(null); if (TimberUtils.isJellyBeanMR2()) mHandlerThread.quitSafely(); else mHandlerThread.quit(); mPlayer.release(); mPlayer = null; mAudioManager.abandonAudioFocus(mAudioFocusListener); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mSession.release(); getContentResolver().unregisterContentObserver(mMediaStoreObserver); closeCursor(); unregisterReceiver(mIntentReceiver); if (mUnmountReceiver != null) { unregisterReceiver(mUnmountReceiver); mUnmountReceiver = null; } mWakeLock.release(); }
@Override public void onDestroy() { if (D) Log.d(TAG, "Destroying service"); super.onDestroy(); // Remove any sound effects final Intent audioEffectsIntent = new Intent( AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION); audioEffectsIntent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId()); audioEffectsIntent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName()); sendBroadcast(audioEffectsIntent); mAlarmManager.cancel(mShutdownIntent); mPlayerHandler.removeCallbacksAndMessages(null); if (TimberUtils.isJellyBeanMR2()) mHandlerThread.quitSafely(); else mHandlerThread.quit(); mPlayer.release(); mPlayer = null; mAudioManager.abandonAudioFocus(mAudioFocusListener); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mSession.release(); getContentResolver().unregisterContentObserver(mMediaStoreObserver); closeCursor(); unregisterReceiver(mIntentReceiver); if (mUnmountReceiver != null) { unregisterReceiver(mUnmountReceiver); mUnmountReceiver = null; } mWakeLock.release(); }
@Override public void onDestroy() { super.onDestroy(); LogHelper.v(LOG_TAG, "onDestroy called."); // stop playback if (mStation != null && mStation.getPlaybackState() != PLAYBACK_STATE_STOPPED) { mController.getTransportControls().stop(); } // save state saveAppState(); // release media session if (mSession != null) { mSession.setActive(false); mSession.release(); } // remove analytics listener mPlayer.removeAnalyticsListener(this); // release player if (mPlayer != null) { releasePlayer(); } // cancel notification stopForeground(true); }
mMediaSession.setCallback(null); synchronized (this) { mMediaSession.release();