Package com.brightcove.player.playback
Class PlaybackNotification
- java.lang.Object
-
- com.brightcove.player.playback.PlaybackNotification
-
- Direct Known Subclasses:
BrightcoveNotification
public abstract class PlaybackNotification extends java.lang.Object
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 toNotification.Builder.setLargeIcon(Bitmap)
is obtained from thePlaybackNotification.MediaDescriptionAdapter
passed toPlaybackNotification.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:
PlaybackNotification.Config
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PlaybackNotification.Config
The config used to create the on-going notification and update the notification content.static class
PlaybackNotification.Extras
Extras set on thePendingIntent
in the default implementation of thePlaybackNotification.MediaDescriptionAdapter.createCurrentContentIntent(com.brightcove.player.playback.MediaPlayback<?>)
.static interface
PlaybackNotification.MediaDescriptionAdapter
An adapter to provide content assets of the media currently playing.static class
PlaybackNotification.NotificationImageLoader
static interface
PlaybackNotification.OnRestorePlaybackHandler
Interface definition used to restore playback when re-creating an activity when the user clicks on the on-going notification.static class
PlaybackNotification.StreamType
Types of media to display an ongoing notification for.
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_NOTIFICATION_ID
The default notification ID for theMediaPlaybackService
-
Constructor Summary
Constructors Constructor Description PlaybackNotification()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
cancel()
Cancels the notification by setting the player tonull
.PlaybackNotification.StreamType[]
getStreamTypes()
Get the supported stream types for showing this notification.abstract boolean
isVisible()
Check is the notification is showing.abstract void
setConfig(PlaybackNotification.Config config)
Configure and customize the notification shown for playback.void
setStreamTypes(PlaybackNotification.StreamType... types)
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 Detail
-
DEFAULT_NOTIFICATION_ID
public static final int DEFAULT_NOTIFICATION_ID
The default notification ID for theMediaPlaybackService
- See Also:
- Constant Field Values
-
-
Method Detail
-
setConfig
public abstract void setConfig(PlaybackNotification.Config config)
Configure and customize the notification shown for playback.- Parameters:
config
- The configuration to build the notification.
-
setStreamTypes
public void setStreamTypes(PlaybackNotification.StreamType... types)
Set the stream types to show notifications for.- Parameters:
types
- The types of media for notification playback.
-
getStreamTypes
public PlaybackNotification.StreamType[] 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.
-
-