List of usage examples for android.support.v4.media.session PlaybackStateCompat ACTION_SKIP_TO_NEXT
long ACTION_SKIP_TO_NEXT
To view the source code for android.support.v4.media.session PlaybackStateCompat ACTION_SKIP_TO_NEXT.
Click Source Link
From source file:nuclei.media.playback.PlaybackManager.java
private long getAvailableActions() { long actions = PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID | PlaybackStateCompat.ACTION_PLAY_FROM_URI | PlaybackStateCompat.ACTION_PLAY_FROM_SEARCH | PlaybackStateCompat.ACTION_PREPARE | PlaybackStateCompat.ACTION_PREPARE_FROM_MEDIA_ID | PlaybackStateCompat.ACTION_PREPARE_FROM_URI | PlaybackStateCompat.ACTION_REWIND | PlaybackStateCompat.ACTION_FAST_FORWARD; if (mPlayback.isPlaying()) { actions |= PlaybackStateCompat.ACTION_PAUSE; }//from w w w.jav a 2s . c o m if (mQueue != null) { if (mQueue.hasNext() || mQueue.getNextQueue() != null) actions |= PlaybackStateCompat.ACTION_SKIP_TO_NEXT; if (mQueue.hasPrevious() || mQueue.getPreviousQueue() != null) actions |= PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS; actions |= PlaybackStateCompat.ACTION_SKIP_TO_QUEUE_ITEM; } return actions; }
From source file:android.support.v17.leanback.media.MediaControllerAdapter.java
@Override public long getSupportedActions() { long supportedActions = 0; if (mController.getPlaybackState() == null) { return supportedActions; }// w w w .jav a 2 s. co m long actionsFromController = mController.getPlaybackState().getActions(); // Translation. if ((actionsFromController & PlaybackStateCompat.ACTION_PLAY_PAUSE) != 0) { supportedActions |= ACTION_PLAY_PAUSE; } if ((actionsFromController & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { supportedActions |= ACTION_SKIP_TO_NEXT; } if ((actionsFromController & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { supportedActions |= ACTION_SKIP_TO_PREVIOUS; } if ((actionsFromController & PlaybackStateCompat.ACTION_FAST_FORWARD) != 0) { supportedActions |= ACTION_FAST_FORWARD; } if ((actionsFromController & PlaybackStateCompat.ACTION_REWIND) != 0) { supportedActions |= ACTION_REWIND; } if ((actionsFromController & PlaybackStateCompat.ACTION_SET_REPEAT_MODE) != 0) { supportedActions |= ACTION_REPEAT; } if ((actionsFromController & PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE) != 0) { supportedActions |= ACTION_SHUFFLE; } return supportedActions; }
From source file:com.example.android.leanback.PlaybackTransportControlGlueSample.java
/** * Get supported actions from player adapter then translate it into playback state compat * related actions//from ww w. ja va2 s .com */ private long getPlaybackStateActions() { long supportedActions = 0L; long actionsFromPlayerAdapter = getPlayerAdapter().getSupportedActions(); if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_SKIP_TO_PREVIOUS) != 0) { supportedActions |= PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS; } else if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_SKIP_TO_NEXT) != 0) { supportedActions |= PlaybackStateCompat.ACTION_SKIP_TO_NEXT; } else if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_REWIND) != 0) { supportedActions |= PlaybackStateCompat.ACTION_REWIND; } else if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_FAST_FORWARD) != 0) { supportedActions |= PlaybackStateCompat.ACTION_FAST_FORWARD; } else if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_PLAY_PAUSE) != 0) { supportedActions |= PlaybackStateCompat.ACTION_PLAY_PAUSE; } else if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_REPEAT) != 0) { supportedActions |= PlaybackStateCompat.ACTION_SET_REPEAT_MODE; } else if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_SHUFFLE) != 0) { supportedActions |= PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE; } return supportedActions; }
From source file:com.torrenttunes.android.MediaNotificationManager.java
private Notification createNotification() { LogHelper.d(TAG, "updateNotificationMetadata. mMetadata=" + mMetadata); if (mMetadata == null || mPlaybackState == null) { return null; }//from w w w .ja v a2s . c om NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService); int playPauseButtonPosition = 0; // If skip to previous action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { notificationBuilder.addAction(R.drawable.ic_skip_previous_white_24dp, mService.getString(R.string.label_previous), mPreviousIntent); // If there is a "skip to previous" button, the play/pause button will // be the second one. We need to keep track of it, because the MediaStyle notification // requires to specify the index of the buttons (actions) that should be visible // when in compact view. playPauseButtonPosition = 1; } addPlayPauseAction(notificationBuilder); // If skip to next action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { notificationBuilder.addAction(R.drawable.ic_skip_next_white_24dp, mService.getString(R.string.label_next), mNextIntent); } MediaDescriptionCompat description = mMetadata.getDescription(); String fetchArtUrl = null; Bitmap art = null; if (description.getIconUri() != null) { // This sample assumes the iconUri will be a valid URL formatted String, but // it can actually be any valid Android Uri formatted String. // async fetch the album art icon String artUrl = description.getIconUri().toString(); art = AlbumArtCache.getInstance().getBigImage(artUrl); if (art == null) { fetchArtUrl = artUrl; // use a placeholder art while the remote art is being downloaded art = BitmapFactory.decodeResource(mService.getResources(), R.drawable.ic_default_art); } if (art.isRecycled()) { art = null; } } notificationBuilder // .setStyle(new Notification.MediaStyle() // .setShowActionsInCompactView( // new int[]{playPauseButtonPosition}) // show only play/pause in compact view // .setMediaSession(mSessionToken)) .setColor(mNotificationColor).setSmallIcon(R.drawable.ic_notification) .setVisibility(Notification.VISIBILITY_PUBLIC).setUsesChronometer(true) .setContentIntent(createContentIntent(description)).setContentTitle(description.getTitle()) .setContentText(description.getSubtitle()).setLargeIcon(art); if (mController != null && mController.getExtras() != null) { String castName = mController.getExtras().getString(MusicService.EXTRA_CONNECTED_CAST); if (castName != null) { String castInfo = mService.getResources().getString(R.string.casting_to_device, castName); notificationBuilder.setSubText(castInfo); notificationBuilder.addAction(R.drawable.ic_close_black_24dp, mService.getString(R.string.stop_casting), mStopCastIntent); } } setNotificationPlaybackState(notificationBuilder); if (fetchArtUrl != null) { fetchBitmapFromURLAsync(fetchArtUrl, notificationBuilder); } return notificationBuilder.build(); }
From source file:com.bayapps.android.robophish.MediaNotificationManager.java
private Notification createNotification() { LogHelper.d(TAG, "updateNotificationMetadata. mMetadata=" + mMetadata); if (mMetadata == null || mPlaybackState == null) { return null; }//from w ww .ja va2s. c o m NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService); int playPauseButtonPosition = 0; // If skip to previous action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { notificationBuilder.addAction(R.drawable.ic_skip_previous_white_24dp, mService.getString(R.string.label_previous), mPreviousIntent); // If there is a "skip to previous" button, the play/pause button will // be the second one. We need to keep track of it, because the MediaStyle notification // requires to specify the index of the buttons (actions) that should be visible // when in compact view. playPauseButtonPosition = 1; } addPlayPauseAction(notificationBuilder); // If skip to next action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { notificationBuilder.addAction(R.drawable.ic_skip_next_white_24dp, mService.getString(R.string.label_next), mNextIntent); } MediaDescriptionCompat description = mMetadata.getDescription(); String fetchArtUrl = null; Bitmap art = null; if (description.getIconUri() != null) { // This sample assumes the iconUri will be a valid URL formatted String, but // it can actually be any valid Android Uri formatted String. // async fetch the album art icon String artUrl = description.getIconUri().toString(); art = AlbumArtCache.getInstance().getBigImage(artUrl); if (art == null) { fetchArtUrl = artUrl; // use a placeholder art while the remote art is being downloaded art = BitmapFactory.decodeResource(mService.getResources(), R.drawable.ic_default_art); } } notificationBuilder .setStyle(new NotificationCompat.MediaStyle() .setShowActionsInCompactView(new int[] { playPauseButtonPosition }) // show only play/pause in compact view .setMediaSession(mSessionToken)) .setColor(mNotificationColor).setSmallIcon(R.drawable.ic_notification) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setUsesChronometer(true) .setContentIntent(createContentIntent(description)).setContentTitle(description.getTitle()) .setContentText(description.getSubtitle()).setLargeIcon(art); if (mController != null && mController.getExtras() != null) { String castName = mController.getExtras().getString(MusicService.EXTRA_CONNECTED_CAST); if (castName != null) { String castInfo = mService.getResources().getString(R.string.casting_to_device, castName); notificationBuilder.setSubText(castInfo); notificationBuilder.addAction(R.drawable.ic_close_black_24dp, mService.getString(R.string.stop_casting), mStopCastIntent); } } setNotificationPlaybackState(notificationBuilder); if (fetchArtUrl != null) { fetchBitmapFromURLAsync(fetchArtUrl, notificationBuilder); } return notificationBuilder.build(); }
From source file:com.murati.oszk.audiobook.MediaNotificationManager.java
private Notification createNotification() { LogHelper.d(TAG, "updateNotificationMetadata. mMetadata=" + mMetadata); if (mMetadata == null || mPlaybackState == null) { return null; }/*from w w w . ja va 2 s . c o m*/ NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService); int playPauseButtonPosition = 0; // If skip to previous action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { notificationBuilder.addAction(R.drawable.ic_skip_previous_white_24dp, mService.getString(R.string.label_previous), mPreviousIntent); // If there is a "skip to previous" button, the play/pause button will // be the second one. We need to keep track of it, because the MediaStyle notification // requires to specify the index of the buttons (actions) that should be visible // when in compact view. playPauseButtonPosition = 1; } addPlayPauseAction(notificationBuilder); // If skip to next action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { notificationBuilder.addAction(R.drawable.ic_skip_next_white_24dp, mService.getString(R.string.label_next), mNextIntent); } MediaDescriptionCompat description = mMetadata.getDescription(); String fetchArtUrl = null; Bitmap art = null; if (description.getIconUri() != null) { // This sample assumes the iconUri will be a valid URL formatted String, but // it can actually be any valid Android Uri formatted String. // async fetch the album art icon String artUrl = description.getIconUri().toString(); try { //art = GlideApp.with(mService.getBaseContext()).asBitmap().load(artUrl).submit().get(); art = AlbumArtCache.getInstance().getBigImage(artUrl); } catch (Exception ex) { Log.d(TAG, ex.getMessage()); } if (art == null) { fetchArtUrl = artUrl; // use a placeholder art while the remote art is being downloaded art = BitmapFactory.decodeResource(mService.getResources(), R.drawable.ic_launcher_white); } } notificationBuilder .setStyle(new NotificationCompat.MediaStyle() .setShowActionsInCompactView(new int[] { playPauseButtonPosition }) // show only play/pause in compact view .setMediaSession(mSessionToken)) .setColor(mNotificationColor).setSmallIcon(R.drawable.ic_launcher_white) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setUsesChronometer(true) .setContentIntent(createContentIntent(description)).setContentTitle(description.getTitle()) .setContentText(description.getSubtitle()).setLargeIcon(art); if (mController != null && mController.getExtras() != null) { String castName = mController.getExtras().getString(MusicService.EXTRA_CONNECTED_CAST); if (castName != null) { String castInfo = mService.getResources().getString(R.string.casting_to_device, castName); notificationBuilder.setSubText(castInfo); notificationBuilder.addAction(R.drawable.ic_close_black_24dp, mService.getString(R.string.stop_casting), mStopCastIntent); } } setNotificationPlaybackState(notificationBuilder); if (fetchArtUrl != null) { fetchBitmapFromURLAsync(fetchArtUrl, notificationBuilder); } return notificationBuilder.build(); }
From source file:org.copticchurchlibrary.arabicreader.MediaNotificationManager.java
private Notification createNotification() { LogHelper.d(TAG, "updateNotificationMetadata. mMetadata=" + mMetadata); if (mMetadata == null || mPlaybackState == null) { return null; }/*from w w w.java 2 s. c o m*/ NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService); int playPauseButtonPosition = 0; // If skip to previous action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { notificationBuilder.addAction( org.copticchurchlibrary.arabicreader.R.drawable.ic_skip_previous_white_24dp, mService.getString(org.copticchurchlibrary.arabicreader.R.string.label_previous), mPreviousIntent); // If there is a "skip to previous" button, the play/pause button will // be the second one. We need to keep track of it, because the MediaStyle notification // requires to specify the index of the buttons (actions) that should be visible // when in compact view. playPauseButtonPosition = 1; } addPlayPauseAction(notificationBuilder); // If skip to next action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { notificationBuilder.addAction(org.copticchurchlibrary.arabicreader.R.drawable.ic_skip_next_white_24dp, mService.getString(org.copticchurchlibrary.arabicreader.R.string.label_next), mNextIntent); } MediaDescriptionCompat description = mMetadata.getDescription(); String fetchArtUrl = null; Bitmap art = null; if (description.getIconUri() != null) { // This sample assumes the iconUri will be a valid URL formatted String, but // it can actually be any valid Android Uri formatted String. // async fetch the album art icon String artUrl = description.getIconUri().toString(); art = AlbumArtCache.getInstance().getBigImage(artUrl); if (art == null) { fetchArtUrl = artUrl; // use a placeholder art while the remote art is being downloaded art = BitmapFactory.decodeResource(mService.getResources(), org.copticchurchlibrary.arabicreader.R.drawable.ic_default_art); } } notificationBuilder .setStyle(new NotificationCompat.MediaStyle() .setShowActionsInCompactView(new int[] { playPauseButtonPosition }) // show only play/pause in compact view .setMediaSession(mSessionToken)) .setColor(mNotificationColor) .setSmallIcon(org.copticchurchlibrary.arabicreader.R.drawable.ic_notification) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setUsesChronometer(true) .setContentIntent(createContentIntent(description)).setContentTitle(description.getTitle()) .setContentText(description.getSubtitle()).setLargeIcon(art); if (mController != null && mController.getExtras() != null) { String castName = mController.getExtras().getString(MusicService.EXTRA_CONNECTED_CAST); if (castName != null) { String castInfo = mService.getResources() .getString(org.copticchurchlibrary.arabicreader.R.string.casting_to_device, castName); notificationBuilder.setSubText(castInfo); notificationBuilder.addAction(org.copticchurchlibrary.arabicreader.R.drawable.ic_close_black_24dp, mService.getString(org.copticchurchlibrary.arabicreader.R.string.stop_casting), mStopCastIntent); } } setNotificationPlaybackState(notificationBuilder); if (fetchArtUrl != null) { fetchBitmapFromURLAsync(fetchArtUrl, notificationBuilder); } return notificationBuilder.build(); }
From source file:github.popeen.dsub.util.compat.RemoteControlClientLP.java
protected long getPlaybackActions(boolean isSong, int currentIndex, int size) { long actions = PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_SEEK_TO | PlaybackStateCompat.ACTION_SKIP_TO_QUEUE_ITEM; if (isSong) { if (currentIndex > 0) { actions |= PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS; }/* w w w. j a va 2 s. com*/ if (currentIndex < size - 1) { actions |= PlaybackStateCompat.ACTION_SKIP_TO_NEXT; } } else { actions |= PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS; actions |= PlaybackStateCompat.ACTION_SKIP_TO_NEXT; } return actions; }
From source file:org.runbuddy.tomahawk.utils.MediaNotification.java
private void updateNotificationMetadata() { Log.d(TAG, "updateNotificationMetadata. mMetadata=" + mMetadata); if (mMetadata == null || mPlaybackState == null) { return;/*from ww w .j av a 2 s .co m*/ } mNotificationBuilder = new NotificationCompat.Builder(mService); List<Integer> showInCompact = new ArrayList<>(); updateFavoriteAction(); showInCompact.add(mNotificationBuilder.mActions.size()); mNotificationBuilder.addAction(mFavoriteAction); // If skip to previous action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { NotificationCompat.Action action = new NotificationCompat.Action.Builder( R.drawable.ic_player_previous_light, mService.getString(R.string.playback_previous), mIntents.get(R.drawable.ic_player_previous_light)).build(); mNotificationBuilder.addAction(action); } updatePlayPauseAction(); showInCompact.add(mNotificationBuilder.mActions.size()); mNotificationBuilder.addAction(mPlayPauseAction); // If skip to next action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { NotificationCompat.Action action = new NotificationCompat.Action.Builder( R.drawable.ic_player_next_light, mService.getString(R.string.playback_next), mIntents.get(R.drawable.ic_player_next_light)).build(); showInCompact.add(mNotificationBuilder.mActions.size()); mNotificationBuilder.addAction(action); } MediaDescriptionCompat description = mMetadata.getDescription(); Bitmap art = description.getIconBitmap(); if (art == null) { // use a placeholder art while the remote art is being downloaded art = BitmapFactory.decodeResource(mService.getResources(), R.drawable.album_placeholder); } mNotificationBuilder .setStyle(new NotificationCompat.MediaStyle() .setShowActionsInCompactView(ArrayUtil.toIntArray(showInCompact)) .setMediaSession(mSessionToken).setShowCancelButton(true)) .setColor(mNotificationColor).setSmallIcon(R.drawable.ic_notification) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setContentIntent(createContentIntent()) .setContentTitle(description.getTitle()).setContentText(description.getSubtitle()) .setTicker(description.getTitle() + " - " + description.getSubtitle()).setLargeIcon(art) .setOngoing(false); updateNotificationPlaybackState(); mService.startForeground(NOTIFICATION_ID, mNotificationBuilder.build()); Log.d(TAG, "updateNotificationMetadata. Notification shown"); }
From source file:nuclei.media.MediaNotificationManager.java
Notification createNotification() { LOG.d("updateNotificationMetadata. mMetadata=", mMetadata); if (mMetadata == null || mPlaybackState == null) { return null; }/* w w w.ja v a2 s . com*/ NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(mService); int playPauseButtonPosition = 0; // If skip to previous action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { notificationBuilder.addAction(ResourceProvider.getInstance().getDrawable(ResourceProvider.PREVIOUS), ResourceProvider.getInstance().getString(ResourceProvider.PREVIOUS), mPreviousIntent); // If there is a "skip to previous" button, the play/pause button will // be the second one. We need to keep track of it, because the MediaStyle notification // requires to specify the index of the buttons (actions) that should be visible // when in compact view. playPauseButtonPosition = 1; } addPlayPauseAction(notificationBuilder); // If skip to next action is enabled if ((mPlaybackState.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { notificationBuilder.addAction(ResourceProvider.getInstance().getDrawable(ResourceProvider.NEXT), ResourceProvider.getInstance().getString(ResourceProvider.NEXT), mNextIntent); } MediaDescriptionCompat description = mMetadata.getDescription(); Bitmap bitmap = description.getIconBitmap(); if (bitmap != null && bitmap.isRecycled()) bitmap = null; if (bitmap == null) { bitmap = mMetadata.getBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { notificationBuilder .setStyle( new NotificationCompat.MediaStyle().setShowActionsInCompactView(playPauseButtonPosition) // show only play/pause in compact view .setShowCancelButton(true).setCancelButtonIntent(mCancelIntent) .setMediaSession(mSessionToken)) .setContentIntent(createContentIntent(description)); } notificationBuilder.setColor(mNotificationColor).setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setUsesChronometer(true).setContentTitle(description.getTitle()) .setContentText(description.getSubtitle()) .setSmallIcon(ResourceProvider.getInstance().getDrawable(ResourceProvider.ICON_SMALL)) .setLargeIcon(bitmap); if (mController != null && mController.getExtras() != null) { String castName = mController.getExtras().getString(MediaService.EXTRA_CONNECTED_CAST); if (castName != null) { CharSequence castInfo = ResourceProvider.getInstance().getString(ResourceProvider.CASTING_TO_DEVICE, castName); notificationBuilder.setSubText(castInfo); notificationBuilder.addAction( ResourceProvider.getInstance().getDrawable(ResourceProvider.ICON_CLOSE), ResourceProvider.getInstance().getString(ResourceProvider.STOP_CASTING), mStopCastIntent); } } setNotificationPlaybackState(notificationBuilder); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) notificationBuilder.mActions.clear(); return notificationBuilder.build(); }