Class PlaybackNotification

java.lang.Object
com.brightcove.player.playback.PlaybackNotification
Direct Known Subclasses:
BrightcoveNotification

public abstract class PlaybackNotification extends Object
Base class for creating and updating a media-style notification.

Action customization

Playback actions can be included or omitted as follows:

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:
  • Field Details

  • Constructor Details

    • PlaybackNotification

      public PlaybackNotification()
  • Method Details

    • 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 to null.

      This should be called when the player is released.