Package com.brightcove.player.playback
Class PlaybackNotification
java.lang.Object
com.brightcove.player.playback.PlaybackNotification
- Direct Known Subclasses:
BrightcoveNotification
Base class for creating and updating a media-style notification.
Action customization
Playback actions can be included or omitted as follows:
usePlayPauseActions- Sets whether the play and pause actions are used.- Corresponding setter:
PlaybackNotification.Config.setUsePlayPauseActions(boolean) - Default:
true
- Corresponding setter:
useRewindAction- Sets whether the rewind action is used.- Corresponding setter:
PlaybackNotification.Config.setUseRewindAction(boolean) - Default:
true
- Corresponding setter:
useRewindActionInCompactView- IfuseRewindActionistrue, sets whether the rewind action is also used in compact view (including the lock screen notification). Else does nothing.- Corresponding setter:
PlaybackNotification.Config.setUseRewindActionInCompactView(boolean) - Default:
false
- Corresponding setter:
useFastForwardAction- Sets whether the fast forward action is used.- Corresponding setter:
PlaybackNotification.Config.setUseFastForwardAction(boolean) - Default:
true
- Corresponding setter:
useFastForwardActionInCompactView- IfuseFastForwardActionistrue, sets whether the fast forward action is also used in compact view (including the lock screen notification). Else does nothing.- Corresponding setter:
PlaybackNotification.Config.setUseFastForwardActionInCompactView(boolean) - Default:
false
- Corresponding setter:
usePreviousAction- Whether the previous action is used.- Corresponding setter:
PlaybackNotification.Config.setUsePreviousAction(boolean) - Default:
true
- Corresponding setter:
usePreviousActionInCompactView- IfusePreviousActionistrue, sets whether the previous action is also used in compact view (including the lock screen notification). Else does nothing.- Corresponding setter:
PlaybackNotification.Config.setUsePreviousActionInCompactView(boolean) - Default:
false
- Corresponding setter:
useNextAction- Whether the next action is used.- Corresponding setter:
PlaybackNotification.Config.setUseNextAction(boolean) - Default:
true
- Corresponding setter:
useNextActionInCompactView- IfuseNextActionistrue, sets whether the next action is also used in compact view (including the lock screen notification). Else does nothing.- Corresponding setter:
PlaybackNotification.Config.setUseNextActionInCompactView(boolean) - Default:
false
- Corresponding setter:
Overriding drawables
The action icons can be set programatically by using the PlaybackNotification.Config. The large icon (i.e. the
icon passed to Notification.Builder.setLargeIcon(Bitmap) is obtained from the
PlaybackNotification.MediaDescriptionAdapter passed to PlaybackNotification.Config.setAdapter(MediaDescriptionAdapter)
notification.setConfig(new MediaPlaybackNotification.Config(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setUseNextAction(false)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setAdapter(new MediaPlaybackNotification.MediaDescriptionAdapter() {
@Override
public CharSequence getCurrentContentTitle(MediaPlayback<?> playback) {
return "Your custom title";
}
@Nullable
@Override
public Bitmap getCurrentLargeIcon(MediaPlayback<?> playback, BitmapCallback callback) {
// TODO: return your bitmap
}
})
);
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe config used to create the on-going notification and update the notification content.static classExtras set on thePendingIntentin the default implementation of thePlaybackNotification.MediaDescriptionAdapter.createCurrentContentIntent(com.brightcove.player.playback.MediaPlayback<?>).static interfaceAn adapter to provide content assets of the media currently playing.static classstatic interfaceInterface definition used to restore playback when re-creating an activity when the user clicks on the on-going notification.static enumTypes of media to display an ongoing notification for. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default notification ID for theMediaPlaybackService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidcancel()Cancels the notification by setting the player tonull.Get the supported stream types for showing this notification.abstract booleanCheck is the notification is showing.abstract voidsetConfig(PlaybackNotification.Config config) Configure and customize the notification shown for playback.voidSet the stream types to show notifications for.protected abstract booleanshow()Starts a notification immediately unless the player is in an idle state, in which case the notification is started as soon as the player transitions away from being idle.
-
Field Details
-
DEFAULT_NOTIFICATION_ID
public static final int DEFAULT_NOTIFICATION_IDThe default notification ID for theMediaPlaybackService- See Also:
-
-
Constructor Details
-
PlaybackNotification
public PlaybackNotification()
-
-
Method Details
-
setConfig
Configure and customize the notification shown for playback.- Parameters:
config- The configuration to build the notification.
-
setStreamTypes
Set the stream types to show notifications for.- Parameters:
types- The types of media for notification playback.
-
getStreamTypes
Get the supported stream types for showing this notification.- Returns:
- The stream types supported for playback from the notification.
-
isVisible
public abstract boolean isVisible()Check is the notification is showing.- Returns:
- True if the notification is visible and on-going.
-
show
protected abstract boolean show()Starts a notification immediately unless the player is in an idle state, in which case the notification is started as soon as the player transitions away from being idle.The notification shows if the currently playing
PlaybackNotification.StreamTypeis one of {@link this#getStreamTypes()}- Returns:
- True if the notification was created and showing on the device.
-
cancel
protected abstract void cancel()Cancels the notification by setting the player tonull.This should be called when the player is released.
-