package com.player.musicoo.service

import android.content.Context
import androidx.core.app.NotificationCompat
import androidx.media3.common.util.UnstableApi
import androidx.media3.session.CommandButton
import androidx.media3.session.DefaultMediaNotificationProvider
import androidx.media3.session.MediaNotification
import androidx.media3.session.MediaSession
import com.google.common.collect.ImmutableList
import com.player.musicoo.util.LogTag
import com.player.musicoo.util.LogTag.LogD

@UnstableApi
class CustomMediaNotificationProvider(context: Context) :
    DefaultMediaNotificationProvider(context) {

    override fun addNotificationActions(
        mediaSession: MediaSession,
        mediaButtons: ImmutableList<CommandButton>,
        builder: NotificationCompat.Builder,
        actionFactory: MediaNotification.ActionFactory
    ): IntArray {

        LogD(LogTag.VO_API_LOG, "mediaButtons->$mediaButtons")

        for (com: CommandButton in mediaButtons) {
            LogD(LogTag.VO_API_LOG, "displayName->${com.displayName}")
            LogD(LogTag.VO_API_LOG, "playerCommand->${com.playerCommand}")
            LogD(LogTag.VO_API_LOG, "------------------------------------------")
        }

        val notificationMediaButtons = ImmutableList.builder<CommandButton>().apply {
            add(NotificationCustomButton.SKIP_BACK.commandButton)
            add(NotificationCustomButton.SKIP_FORWARD.commandButton)
        }.build()

        return super.addNotificationActions(
            mediaSession,
            notificationMediaButtons,
            builder,
            actionFactory
        )
    }

}