我正在尝试实现 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)
}
最佳答案
您可以将 rewindIncrementMs
和 fastForwardIncrementMs
设置为 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/