From e52f418dad3dd8bb34763fc8f8c1bd680d489be8 Mon Sep 17 00:00:00 2001 From: Matthijs Tijink Date: Wed, 29 May 2019 20:55:15 +0000 Subject: [PATCH] Properly close the media session when closing the media notification BUG: 407812 --- .../kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java index 6a55f099..8ca95d90 100644 --- a/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java +++ b/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.java @@ -383,7 +383,7 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh iCloseNotification.setAction(MprisMediaNotificationReceiver.ACTION_CLOSE_NOTIFICATION); iCloseNotification.putExtra(MprisMediaNotificationReceiver.EXTRA_DEVICE_ID, notificationDevice); iCloseNotification.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer()); - PendingIntent piCloseNotification = PendingIntent.getActivity(service, 0, iCloseNotification, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent piCloseNotification = PendingIntent.getBroadcast(service, 0, iCloseNotification, PendingIntent.FLAG_UPDATE_CURRENT); notification.setDeleteIntent(piCloseNotification); } @@ -448,6 +448,9 @@ public class MprisMediaSession implements SharedPreferences.OnSharedPreferenceCh //Clear the current player and media session notificationPlayer = null; if (mediaSession != null) { + mediaSession.setPlaybackState(new PlaybackStateCompat.Builder().build()); + mediaSession.setMetadata(new MediaMetadataCompat.Builder().build()); + mediaSession.setActive(false); mediaSession.release(); mediaSession = null; }