2022-04-03 23:57:50 +02:00
|
|
|
/*
|
|
|
|
* MediaNotificationProvider.kt
|
|
|
|
* Copyright (C) 2009-2022 Ultrasonic developers
|
|
|
|
*
|
|
|
|
* Distributed under terms of the GNU GPLv3 license.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.moire.ultrasonic.playback
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import androidx.core.app.NotificationCompat
|
|
|
|
import androidx.media3.common.Player
|
|
|
|
import androidx.media3.common.util.UnstableApi
|
2022-06-19 19:43:55 +02:00
|
|
|
import androidx.media3.session.CommandButton
|
|
|
|
import androidx.media3.session.DefaultMediaNotificationProvider
|
2022-04-03 23:57:50 +02:00
|
|
|
import androidx.media3.session.MediaNotification
|
2022-06-19 19:43:55 +02:00
|
|
|
import androidx.media3.session.MediaSession
|
2022-04-03 23:57:50 +02:00
|
|
|
|
2022-06-19 19:43:55 +02:00
|
|
|
@UnstableApi
|
|
|
|
class MediaNotificationProvider(context: Context) : DefaultMediaNotificationProvider(context) {
|
2022-04-03 23:57:50 +02:00
|
|
|
|
2022-06-19 19:43:55 +02:00
|
|
|
override fun addNotificationActions(
|
|
|
|
mediaSession: MediaSession,
|
|
|
|
mediaButtons: MutableList<CommandButton>,
|
|
|
|
builder: NotificationCompat.Builder,
|
|
|
|
actionFactory: MediaNotification.ActionFactory
|
|
|
|
): IntArray {
|
|
|
|
return super.addNotificationActions(mediaSession, mediaButtons, builder, actionFactory)
|
2022-04-03 23:57:50 +02:00
|
|
|
}
|
|
|
|
|
2022-06-19 19:43:55 +02:00
|
|
|
override fun getMediaButtons(
|
|
|
|
playerCommands: Player.Commands,
|
|
|
|
customLayout: MutableList<CommandButton>,
|
|
|
|
playWhenReady: Boolean
|
|
|
|
): MutableList<CommandButton> {
|
|
|
|
val commands = super.getMediaButtons(playerCommands, customLayout, playWhenReady)
|
2022-04-03 23:57:50 +02:00
|
|
|
|
2022-06-19 19:43:55 +02:00
|
|
|
commands.forEachIndexed { index, command ->
|
|
|
|
command.extras.putInt(COMMAND_KEY_COMPACT_VIEW_INDEX, index)
|
2022-04-03 23:57:50 +02:00
|
|
|
}
|
2022-05-02 20:46:01 +02:00
|
|
|
|
2022-06-19 19:43:55 +02:00
|
|
|
return commands
|
2022-04-03 23:57:50 +02:00
|
|
|
}
|
2022-04-04 17:59:12 +02:00
|
|
|
}
|