![](/img/trans.png)
[英]How to implement event listeners for fast forward/rewind buttons in Android MediaController
[英]ExoPlayer Notification Manager, hide fast rewind and fast forward buttons
我正在嘗試實現 ExoPlayer 的Notification Manager
,它運行良好,但我不想顯示快退和快進按鈕。 我檢查了文檔,但找不到隱藏這些按鈕的方法。 有什么巧妙的方法可以隱藏它們嗎?
這是我的代碼
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);
您可以在 ExoPlayer 2.15.0 中執行此操作 -
playerNotificationManager.setUseFastForwardAction(false)
playerNotificationManager.setUseFastForwardActionInCompactView(false)
playerNotificationManager.setUseRewindAction(false)
playerNotificationManager.setUseRewindActionInCompactView(false)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.