在MediaStyle通知中禁用或隐藏搜索栏

问题描述 投票:0回答:1

[尝试构建一个实时流媒体播放应用程序,SDK在28及以下的媒体样式通知看起来不错,没有任何搜索栏,但是在Android 10(SDK 29)中运行同一应用程序时,该通知显示了其他搜索栏,但我没有想要,因为流是实时的,并且我正在使用默认的exoplayer(exo vers。2.10.8)行为进行缓存。

如何禁用或隐藏搜索栏?

下面的通知构建器中的尝试设置:

。setProgress(0,0,true)

下面的通知摘要:

    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:

enter image description here

android android-mediaplayer android-notifications
1个回答
0
投票
您需要使用PlayerNotificationManager而不是Notification.Builder,并使用Bundle键和MediaDescriptionCompat.Builder值使用setExtras()方法将自定义MediaMetadataCompat.METADATA_KEY_DURATION额外传递给-1,然后覆盖getMediaDescription()TimelineQueueNavigator方法类,然后将其传递给MediaSessionConnector
© www.soinside.com 2019 - 2024. All rights reserved.