Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
}
like image 336
ysfcyln Avatar asked Feb 23 '20 10:02

ysfcyln


2 Answers

You can do this in ExoPlayer 2.15.0 -

playerNotificationManager.setUseFastForwardAction(false)
playerNotificationManager.setUseFastForwardActionInCompactView(false)
playerNotificationManager.setUseRewindAction(false)
playerNotificationManager.setUseRewindActionInCompactView(false)
like image 56
Vijayendra Avatar answered Nov 14 '22 11:11

Vijayendra


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);
like image 5
marcbaechinger Avatar answered Nov 14 '22 12:11

marcbaechinger