attachMediaNotification

Deprecated

Use KitePlayer.attachMediaSession with notification options, which owns the notification and closes with the player.

Shows session as a media notification and keeps playback going after the application leaves the screen.

The notification appears when playback starts. It carries the title, the artist, previous, play or pause and next, and the buttons given to KitePlayerMediaSession.setCustomActions, the same ones the system media controls show. While the player plays or buffers, KitePlayerMediaService holds the application in the foreground, so Android does not stop the process. After a pause or at the end of the media it stays there for MediaNotificationOptions.pausedForegroundTimeout, then leaves the foreground, and the notification can be swiped away. A swipe stops the service and leaves the player paused. Removing the application from the recent apps screen does the same unless the player is playing. Idle and a failure remove the notification.

The application declares the service and its permissions in its manifest; KitePlayerMediaService shows how. Android 13 and later do not need the notification permission for a media session's notification. One notification shows at a time: attaching again closes the one before. Close it before the session.

A manifest without android.permission.WAKE_LOCK does not stop the attach. The notification then holds no wake lock, whatever MediaNotificationOptions.wakeLocks asks, and KiteLog receives one line that says so.

Throws

when the application's manifest does not declare KitePlayerMediaService.