Reputation: 1326
I am using the PlayerNotificationManager with Exoplayer and upto Android 10 Notification Tray is visible on startForeground() but in one of my phone when I upgraded to Android 11, the Notification Tray for media player stopped showing.
Please Help!!
Here I debugged on Google Pixel Now:
Working on Google Pixel android 11 but Not on Samsung G973F. Why this is not working on Samsung??
Upvotes: 3
Views: 4642
Reputation: 1326
Here, I arises the issue On git ExoPlayer, the it's an device specific Issue, so, here is the link of that issue,
https://github.com/google/ExoPlayer/issues/8500
Use MediaSessionConnector with ExoPlayer PlayerNotificationManager and MediaSessions:
https://github.com/google/ExoPlayer/tree/release-v2/extensions/mediasession
Here there is use of MediaSession and MediaSessionConnector in more brief:
https://developer.android.com/codelabs/supporting-mediasession
Upvotes: 3
Reputation: 337
Here you Go, i have not tested this but i think this will work,
// Create a media session. NotificationCompat.MediaStyle
// PlayerService is your own Service or Activity responsible for media playback.
val mediaSession = MediaSessionCompat(this, "PlayerService")
// Create a MediaStyle object and supply your media session token to it.
val mediaStyle = Notification.MediaStyle().setMediaSession(mediaSession.sessionToken)
// Create a Notification which is styled by your MediaStyle object.
// This connects your media session to the media controls.
// Don't forget to include a small icon.
val notification = Notification.Builder(this@PlayerService, CHANNEL_ID)
.setStyle(mediaStyle)
.setSmallIcon(R.drawable.ic_app_logo)
.build()
// Specify any actions which your users can perform, such as pausing and skipping to
the next track.
val pauseAction: Notification.Action = Notification.Action.Builder(
pauseIcon, "Pause", pauseIntent
).build()
notification.addAction(pauseAction)
Check this link for complete guide https://android-developers.googleblog.com/2020/08/playing-nicely-with-media-controls.html
Upvotes: 0