小编Muh*_*oor的帖子

如何修复此 PlayerNotificationManager.createWithNotificationChannel 错误

在此输入图像描述

我正在开发一个音乐应用程序,但遇到错误,有人可以告诉我如何解决这个问题吗PlayerNotificationManager.createWithNotificationChannel

.createWithNotificationChannel无法识别

class MusicNotificationManager(
    private val context: Context,
    sessionToken: MediaSessionCompat.Token,
    notificationListener: PlayerNotificationManager.NotificationListener,
    private val newSongCallback: () -> Unit
) {
    //creating notification for music player
    private val notificationManager: PlayerNotificationManager

    init {
        val mediaController = MediaControllerCompat(context, sessionToken)
        notificationManager = PlayerNotificationManager.createWithNotificationChannel(
            context,
            NOTIFICATION_CHANNEL_ID,
            R.string.notification_channel_name,
            R.string.notification_channel_description,
            NOTIFICATION_ID,
            DescriptionAdapter(mediaController),
            notificationListener
        ).apply{
            setSmallIcon(R.drawable.ic_music)
            setMediaSessionToken(sessionToken)
        }
    }

    fun showNotification(player: Player){
        notificationManager.setPlayer(player)
    }
    //get current playing song
    private inner class DescriptionAdapter(
        private val mediaController: MediaControllerCompat
    ): PlayerNotificationManager.MediaDescriptionAdapter {
        override fun getCurrentContentTitle(player: Player): CharSequence { …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-studio exoplayer exoplayer2.x

6
推荐指数
2
解决办法
4517
查看次数