Skip to content

Commit

Permalink
Open player on notification click (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
siper authored Feb 4, 2025
1 parent 171bb9c commit 67a168a
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package ru.stersh.youamp.shared.player.android

import android.app.PendingIntent
import android.app.PendingIntent.FLAG_IMMUTABLE
import android.app.PendingIntent.FLAG_UPDATE_CURRENT
import androidx.annotation.OptIn
import androidx.media3.common.AudioAttributes
import androidx.media3.common.C
Expand Down Expand Up @@ -80,6 +83,11 @@ class MusicService : MediaLibraryService() {
.Builder(this, player, customCallback)
.build()

val intent = packageManager.getLaunchIntentForPackage(packageName)
val pendingIntent = PendingIntent.getActivity(this, 0, intent, FLAG_IMMUTABLE or FLAG_UPDATE_CURRENT)

mediaSession.setSessionActivity(pendingIntent)

addSession(mediaSession)
player.addListener(playerListener)

Expand Down

0 comments on commit 67a168a

Please sign in to comment.