I am developing a music app but i am getting error can anybody tell me how to fix this PlayerNotificationManager.createWithNotificationChannel
?
.createWithNotificationChannel
is not recognizable
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 {
newSongCallback()
return mediaController.metadata.description.title.toString()
}
override fun createCurrentContentIntent(player: Player): PendingIntent? {
return mediaController.sessionActivity
}
//get current playing song title
override fun getCurrentContentText(player: Player): CharSequence? {
return mediaController.metadata.description.subtitle.toString()
}
//get current playing song icon
override fun getCurrentLargeIcon(
player: Player,
callback: PlayerNotificationManager.BitmapCallback
): Bitmap? {
Glide.with(context).asBitmap()
.load(mediaController.metadata.description.iconUri)
.into(object : CustomTarget<Bitmap>(){
override fun onResourceReady(
resource: Bitmap,
transition: Transition<in Bitmap>?
) {
callback.onBitmap(resource)
}
override fun onLoadCleared(placeholder: Drawable?) = Unit
})
return null
}
}
}
I have tried to add all possible dependencies in my build.gradle file but not able to resolve this issue.
build.gradle
– Microfiche