MediaNotificationOptions

data class MediaNotificationOptions(val smallIcon: Int, val channelId: String = "kiteplayer.playback", val channelName: CharSequence = "Playback", val notificationId: Int = 1, val contentIntent: PendingIntent? = null, val pausedForegroundTimeout: Duration = 10.minutes, val onForegroundRefused: (Throwable) -> Unit? = null, val wakeLocks: WakeLockPolicy = WakeLockPolicy.Network, val labels: MediaNotificationLabels = MediaNotificationLabels(), val onDismissed: (MediaNotificationDismissal) -> Unit? = null)

How the media notification looks and behaves. Only smallIcon has no default.

Constructors

Link copied to clipboard
constructor(smallIcon: Int, channelId: String = "kiteplayer.playback", channelName: CharSequence = "Playback", notificationId: Int = 1, contentIntent: PendingIntent? = null, pausedForegroundTimeout: Duration = 10.minutes, onForegroundRefused: (Throwable) -> Unit? = null, wakeLocks: WakeLockPolicy = WakeLockPolicy.Network, labels: MediaNotificationLabels = MediaNotificationLabels(), onDismissed: (MediaNotificationDismissal) -> Unit? = null)

Properties

Link copied to clipboard

The channel the library creates when it attaches, with low importance, so it makes no sound.

Link copied to clipboard

The channel's name in the system settings. Pass a translated one.

Link copied to clipboard

Opens the application from the notification and from the system media controls, and becomes the session activity. Null uses the session activity already set, or else opens the application the way its launcher icon does.

Link copied to clipboard

What a screen reader says for each transport button. Pass translated ones.

Link copied to clipboard

Any id but zero, which Android refuses for a foreground service.

Link copied to clipboard

Called on the main thread when the user puts the notification away (#427): a swipe, or removing the application from the recent apps screen while the player is not playing. The library has already paused the player and removed the notification, as it does without a callback; the reason tells a swipe from a press of pause, which also ends at Paused, so an application that reads a swipe as "I am done" can close the player and free what it holds. Removing the application while it plays leaves the sound going and calls nothing.

Link copied to clipboard

Called on the main thread when Android refuses the foreground, which it may do from Android 12 when playback starts while the application is in the background. The notification is still posted, but nothing then keeps the process alive.

Link copied to clipboard

How long a paused or finished player keeps the application in the foreground, so a press of play from the lock screen or a headset can still start the sound. media3 uses ten minutes. Zero leaves the foreground at the pause.

Link copied to clipboard

The application's monochrome notification icon, a drawable resource id.

Link copied to clipboard

What stays awake while the player plays or buffers, so a stream keeps loading after the screen turns off. See WakeLockPolicy. A lock needs the WAKE_LOCK permission in the manifest, which KitePlayerMediaService shows. Without the permission the notification holds nothing, as with WakeLockPolicy.None, and says so once through KiteLog. media3 calls this the wake mode.