@Nullable @SuppressWarnings("UnusedReturnValue") public KeyEvent handleMediaButtonIntent(final Intent intent) { return MediaButtonReceiver.handleIntent(mediaSession, intent); }
R.drawable.ic_play_arrow_white_24dp, mService.getString(R.string.label_play), MediaButtonReceiver.buildMediaButtonPendingIntent( mService, PlaybackStateCompat.ACTION_PLAY)); R.drawable.ic_pause_white_24dp, mService.getString(R.string.label_pause), MediaButtonReceiver.buildMediaButtonPendingIntent( mService, PlaybackStateCompat.ACTION_PAUSE)); R.drawable.ic_skip_next_white_24dp, mService.getString(R.string.label_next), MediaButtonReceiver.buildMediaButtonPendingIntent( mService, PlaybackStateCompat.ACTION_SKIP_TO_NEXT)); R.drawable.ic_skip_previous_white_24dp, mService.getString(R.string.label_previous), MediaButtonReceiver.buildMediaButtonPendingIntent( mService, PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS));
.setLargeIcon(description.getIconBitmap()) .setContentIntent(controller.getSessionActivity()) .setDeleteIntent(MediaButtonReceiver.buildMediaButtonPendingIntent( this, // Context PlaybackStateCompat.ACTION_STOP)) .addAction(new NotificationCompat.Action( R.drawable.pause, getString(R.string.pause), MediaButtonReceiver.buildMediaButtonPendingIntent( this, PlaybackStateCompat.ACTION_PLAY_PAUSE))) .addAction(new NotificationCompat.Action( R.drawable.skip_to_next, getString(R.string.skip_to_next), MediaButtonReceiver.buildMediaButtonPendingIntent( this, PlaybackStateCompat.ACTION_SKIP_TO_NEXT))); .setCancelButtonIntent(MediaButtonReceiver.buildMediaButtonPendingIntent( this, PlaybackStateCompat.ACTION_STOP)));
@Override public int onStartCommand(Intent intent, int flags, int startId) { MediaButtonReceiver.handleIntent(mediaSession, intent); return super.onStartCommand(intent, flags, startId); }
MediaButtonReceiver.buildMediaButtonPendingIntent( mService, PlaybackStateCompat.ACTION_STOP))) .setDeleteIntent(MediaButtonReceiver.buildMediaButtonPendingIntent( mService, PlaybackStateCompat.ACTION_STOP))
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null && ACTION_STOP_NOTIFICATION.equals(intent.getAction())) { mMediaSession.getController().getTransportControls().pause(); mNotification.stopNotification(); } else { MediaButtonReceiver.handleIntent(mMediaSession, intent); } return START_STICKY; }
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.d(LOG_TAG, "onStartCommand"); if (intent != null) { MediaButtonReceiver.handleIntent(mediaSession, intent); String action = intent.getAction(); if ("PLAY".equals(action)) { playCmd(); } else if ("PAUSE".equals(action)) { pauseCmd(); } else if ("PLAY_PAUSE".equals(action)) { playPauseCmd(); } else if ("REWIND".equals(action)) { rewindCmd(); } else if ("FAST_FORWARD".equals(action)) { fastForwardCmd(); } } return super.onStartCommand(intent, flags, startId); }