Im using MediaSessionService to play streaming audio in the background. the notification shows but it has a seekbar which I want to remove.
Disable or hide seekbar in MediaStyle notifications
this post says to add putLong(MediaMetadata.METADATA_KEY_DURATION, -1L)
which i cant do because there is no "putLong" on the Media3 MediaMetadata
val builder = MediaMetadata.Builder().apply {
setStation (args.name)
setDisplayTitle(args.name)
setSubtitle(getString(R.string.radio_notification_description, args.name))
setArtworkUri(args.logoUrl?.toUri())
setIsBrowsable(false)
}
val media = MediaItem.Builder().setMediaId(url).setMediaMetadata(builder.build()).build()
controller.setMediaItem(media)
controller.prepare()
controller.play()
I've also created this but I'm not sure how to actually remove it from here.
@UnstableApi
class CustomMediaNotificationProvider(private val context: Context) : MediaNotification.Provider {
override fun createNotification(
mediaSession: MediaSession,
customLayout: ImmutableList,
actionFactory: MediaNotification.ActionFactory,
onNotificationChangedCallback: MediaNotification.Provider.Callback
): MediaNotification {
// val notification = NotificationCompat.Builder(context, defaultMediaNotification.notification).build()
// return MediaNotification(defaultMediaNotification.notificationId,notification)
val defaultMediaNotificationProvider = DefaultMediaNotificationProvider.Builder(context)
return defaultMediaNotificationProvider.build().createNotification(mediaSession, customLayout, actionFactory, onNotificationChangedCallback)
}
override fun handleCustomCommand(
session: MediaSession,
action: String,
extras: Bundle
): Boolean {
return true
}
}
or here:
@RequiresApi(Build.VERSION_CODES.O)
override fun onUpdateNotification(session: MediaSession, startInForegroundRequired: Boolean) {
super.onUpdateNotification(session, startInForegroundRequired)