private void setSessionInactive() { if (mServiceStarted) { stopSelf(); mServiceStarted = false; } if (mSession.isActive()) { mSession.setActive(false); } }
private void setSessionActive() { if (!mServiceStarted) { startService(new Intent(getApplicationContext(), WearBrowserService.class)); mServiceStarted = true; } if (!mSession.isActive()) { mSession.setActive(true); } }
private void releaseServiceUiAndStop() { if (isPlaying() || mPausedByTransientLossOfFocus || mPlayerHandler.hasMessages(TRACK_ENDED)) { return; } if (D) Log.d(TAG, "Nothing is playing anymore, releasing notification"); cancelNotification(); mAudioManager.abandonAudioFocus(mAudioFocusListener); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mSession.setActive(false); if (!mServiceInUse) { saveQueue(true); stopSelf(mServiceStartId); } }
MediaButtonIntentReceiver.class.getName())); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mSession.setActive(true); if (createNewNextTrack) { setNextTrack();
.build()); mediaSession.setActive(true);
public static void setActive(Object sessionObj, boolean active) { ((MediaSession)sessionObj).setActive(active); }
@Override public void onResume() { super.onResume(); mSession.setActive(true); }
/** * Unregisters a registered media session */ public void unregisterRemote() { if (mMediaSession != null) { mMediaSession.setActive(false); mMediaSession.release(); mMediaSession = null; } }
private void setSessionInactive() { if (mServiceStarted) { stopSelf(); mServiceStarted = false; } if (mSession.isActive()) { mSession.setActive(false); } }
private void setSessionInactive() { if(mServiceStarted) { // service is no longer necessary. Will be started again if needed. MirrorLinkMediaBrowserService.this.stopSelf(); mServiceStarted = false; } if(mSession.isActive()) { mSession.setActive(false); } }
private void setSessionInactive() { if (mServiceStarted) { stopSelf(); mServiceStarted = false; } if (mSession.isActive()) { mSession.setActive(false); } }
private void setSessionActive() { if (!mServiceStarted) { // The MirrorLinkMediaBrowserService needs to keep running even after the calling MediaBrowser // is disconnected. Call startService(Intent) and then stopSelf(..) when we no longer // need to play media. startService(new Intent(getApplicationContext(), MirrorLinkMediaBrowserService.class)); mServiceStarted = true; } if (!mSession.isActive()) { mSession.setActive(true); } }
private void setSessionActive() { if (!mServiceStarted) { startService(new Intent(getApplicationContext(), WearBrowserService.class)); mServiceStarted = true; } if (!mSession.isActive()) { mSession.setActive(true); } }
private void setSessionActive() { if (!mServiceStarted) { startService(new Intent(getApplicationContext(), WearBrowserService.class)); mServiceStarted = true; } if (!mSession.isActive()) { mSession.setActive(true); } }
@Override public void closePlayer() { stopVideo(); PlaybackState.Builder stateBuilder = new PlaybackState.Builder(); stateBuilder.setState(PlaybackState.STATE_PAUSED, 12, 1); mMediaSession.setPlaybackState(stateBuilder.build()); mMediaSession.setActive(false); Log.i(TAG, "closePlayer : " + mMediaSession.isActive()); }
MediaSession.Callback callback = new MediaSession.Callback() { @Override public void onPlay() { // Handle the play button } }; MediaSession mediaSession = new MediaSession(context, TAG); // Debugging tag, any string mediaSession.setFlags( MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); mediaSession.setCallback(callback); // Set up what actions you support and the state of your player mediaSession.setState( new PlaybackState.Builder() .setActions(PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_PLAY_PAUSE); .setState(PlaybackState.STATE_PLAYING, 0, // playback position in milliseconds 1.0); // playback speed // Call this when you start playback after receiving audio focus mediaSession.setActive(true);
/** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.playback_controls); loadViews(); setupCallbacks(); mSession = new MediaSession(this, "LeanbackSampleApp"); mSession.setCallback(new MediaSessionCallback()); mSession.setFlags(MediaSession.FLAG_HANDLES_MEDIA_BUTTONS | MediaSession.FLAG_HANDLES_TRANSPORT_CONTROLS); mSession.setActive(true); }
PlaybackState.ACTION_SKIP_TO_NEXT | PlaybackState.ACTION_SKIP_TO_PREVIOUS) .build()); mMediaSession.setActive(true);