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

标签 android android-notifications exoplayer notificationmanager

我正在尝试实现 ExoPlayer 的通知管理器,它工作得很好,但我不想显示快退和快进按钮。我检查了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 的链接对此进行了解释:https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/ui/PlayerNotificationManager.html

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

关于android - ExoPlayer通知管理器,隐藏快退和快进按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60361356/

相关文章:

android - TextView 内文本的偏心对齐

安卓zxing : How to get product name when a UPC_A code is scanned

java - Android Activity 上下文 NullPointerException

android - ExoPlayer:如何播放http直播?

java - OpenGL ES 3.0 通过引用调用对象添加重力和 OnCLick 事件

android - 检查来自 RSS xml 的更新,并发送通知

android - 全屏通知仅显示为抬头

android - 在通知中使用 Picasso 的最简单方法(图标)

android - Exoplayer2 流式传输 HLS 视频,有时仅播放有声视频(视频未播放)

android - 旋转到风景时的 Exoplayer 方向问题