ExoPlayer 通知管理器,隐藏快退和快进按钮

ExoPlayer Notification Manager, hide fast rewind and fast forward buttons

我正在尝试实现 ExoPlayer 的 Notification Manager,它运行良好,但我不想显示快退和快进按钮。我检查了 documentation 但找不到隐藏这些按钮的方法。有什么巧妙的方法可以隐藏它们吗?

这是我的代码

private fun initListener() {
    val playerNotificationManager: PlayerNotificationManager
    val notificationId = 1234
    val mediaDescriptionAdapter = object : PlayerNotificationManager.MediaDescriptionAdapter {
        override fun getCurrentSubText(player: Player?): String {
            return "Sub text"
        }

        override fun getCurrentContentTitle(player: Player): String {
            return "Title"
        }

        override fun createCurrentContentIntent(player: Player): PendingIntent? {
            return null
        }

        override fun getCurrentContentText(player: Player): String {
            return "ContentText"
        }

        override fun getCurrentLargeIcon(
            player: Player,
            callback: PlayerNotificationManager.BitmapCallback
        ): Bitmap? {
            return null
        }
    }

    playerNotificationManager = PlayerNotificationManager.createWithNotificationChannel(
        context,
        "My_channel_id",
        R.string.app_name,
        notificationId,
        mediaDescriptionAdapter,
        object : PlayerNotificationManager.NotificationListener {
            override fun onNotificationPosted(notificationId: Int, notification: Notification, ongoing: Boolean) {}

            override fun onNotificationCancelled(notificationId: Int, dismissedByUser: Boolean) {}
        })

    playerNotificationManager.setUseNavigationActions(false)
    playerNotificationManager.setUseNavigationActionsInCompactView(false)
    playerNotificationManager.setVisibility(View.VISIBLE)
    playerNotificationManager.setPlayer(mPlayer)
}

您可以将 rewindIncrementMsfastForwardIncrementMs 设置为 0 以隐藏按钮。

您在上面发布的 JavaDoc 的 link 解释了这一点:https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/ui/PlayerNotificationManager.html

playerNotificationManager.setRewindIncrementMs(0);
playerNotificationManager.setFastForwardIncrementMs(0);

您可以在 ExoPlayer 2.15.0 中执行此操作 -

playerNotificationManager.setUseFastForwardAction(false)
playerNotificationManager.setUseFastForwardActionInCompactView(false)
playerNotificationManager.setUseRewindAction(false)
playerNotificationManager.setUseRewindActionInCompactView(false)