Trying to build a live stream media playback app, the media style notifications in 28 and below sdk looks good without any seekbar, but when running same application in Android 10 (SDK 29) the notification is showing additional seekbar which i don't want since the stream is live and i am using default exoplayer (exo vers. 2.10.8) behavior to cache.
How do i disable or hide the seekbar?
tried setting below in notification builder:
.setProgress(0,0,true)
Snippet of notification below :
Notification notification = new Notification.Builder(this,Constant.CHANNEL_ID)
.setSmallIcon(R.drawable.ic_logo)
.setContentTitle(title)
.setContentText(message)
.setLargeIcon(artwork)
.addAction(new Notification.Action.Builder(
Icon.createWithResource(getApplicationContext(),playPauseResourceId),
"Play/Pause",
playPausePendingIntent).build())
.addAction(new Notification.Action.Builder(
Icon.createWithResource(getApplicationContext(),R.drawable.exo_icon_stop),
"Play/Pause",
stopPendingIntent).build())
.setStyle(new Notification.MediaStyle().setShowActionsInCompactView(0).setMediaSession(mediaSession.getSessionToken()))
.setSubText(subText)
.setContentIntent(pendingActivityIntent)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setProgress(0,0,true)
.build();
Screeshot :
You need to use PlayerNotificationManager
instead of Notification.Builder
and pass custom Bundle
extra to MediaDescriptionCompat.Builder
using setExtras()
method with MediaMetadataCompat.METADATA_KEY_DURATION
key and -1
value then override getMediaDescription()
method of TimelineQueueNavigator
class and pass it to MediaSessionConnector
like so :
mediaSessionConnector.setQueueNavigator(new TimelineQueueNavigator(mediaSession) {
@Override
public MediaDescriptionCompat getMediaDescription(Player player, int windowIndex) {
Bundle extras = new Bundle();
extras.putInt(MediaMetadataCompat.METADATA_KEY_DURATION, -1);
return new MediaDescriptionCompat.Builder()
.setMediaId(trackModel.mediaId)
.setIconBitmap(trackModel.bitmap)
.setTitle(trackModel.title)
.setDescription(trackModel.description)
.setExtras(extras)
.build();
}
});