简体   繁体   中英

ExoPlayer Notification Manager, hide fast rewind and fast forward buttons

I am trying to implement ExoPlayer's Notification Manager , it works pretty well but I do not want to show fast rewind and fast forward buttons. I checked documentation but can not find a way to hide these button. Is there any tricky way to hide them?

Here is my code

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)
}

You can set rewindIncrementMs and fastForwardIncrementMs to 0 to hide the buttons.

The link to the JavaDoc you posted above explaines this: https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/ui/PlayerNotificationManager.html

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

You can do this in ExoPlayer 2.15.0 -

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM