I'm working on an Android Auto media app, and I'm currently creating some custom actions. I created a custom action to set the player repeat mode, and I'm using the Exoplayer icons, which is working perfectly. However, now I'm working on a custom action to toggle the shuffle mode. I created 2 vector drawable to be the icon, and the difference between both is just the color (White enabled, grey disabled).
private inner class ShuffleModeActionProvider : MediaSessionConnector.CustomActionProvider {
override fun getCustomAction(player: Player): PlaybackStateCompat.CustomAction? {
val actionLabel: CharSequence = "Shuffle Mode"
val iconResourceId: Int = if (player.shuffleModeEnabled) {
R.drawable.ic_shuffle_on
} else {
R.drawable.ic_shuffle_off
}
return PlaybackStateCompat.CustomAction.Builder(ACTION_SHUFFLE_MODE, actionLabel, iconResourceId).build()
}
override fun onCustomAction(player: Player, action: String, extras: Bundle?) {
player.shuffleModeEnabled = !player.shuffleModeEnabled
}
}
When I test it, it only shows the ic_shuffle_on, the white icon. The button is working, and it's shuffling the playlist, however the icon is not changing. If I print the iconResourceId, it's changing between both icons id, but the visual display remain showing only the white.
Has anyone had similar issues with the Android Auto?
Thank you.