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
- IfuseRewindAction
istrue
, 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
- IfuseFastForwardAction
istrue
, 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
- IfusePreviousAction
istrue
, 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
- IfuseNextAction
istrue
, 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
Modifier and TypeClassDescriptionstatic class
The config used to create the on-going notification and update the notification content.static class
Extras set on thePendingIntent
in the default implementation of thePlaybackNotification.MediaDescriptionAdapter.createCurrentContentIntent(com.brightcove.player.playback.MediaPlayback<?>)
.static interface
An adapter to provide content assets of the media currently playing.static class
static interface
Interface definition used to restore playback when re-creating an activity when the user clicks on the on-going notification.static enum
Types of media to display an ongoing notification for. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default notification ID for theMediaPlaybackService
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
cancel()
Cancels the notification by setting the player tonull
.Get the supported stream types for showing this notification.abstract boolean
Check is the notification is showing.abstract void
setConfig
(PlaybackNotification.Config config) Configure and customize the notification shown for playback.void
Set the stream types to show notifications for.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.
-
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.StreamType
is 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.
-