From 2e95cf071423250b0de07e7d9668ed17aafd9019 Mon Sep 17 00:00:00 2001 From: Daniel Iglesia Date: Fri, 21 Oct 2022 08:32:30 -0700 Subject: [PATCH] Fix MediaSession issue; update version and changelog --- packages/audiofileplayer/CHANGELOG.md | 3 +++ .../plugins/audiofileplayer/AudiofileplayerService.java | 8 ++------ packages/audiofileplayer/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/audiofileplayer/CHANGELOG.md b/packages/audiofileplayer/CHANGELOG.md index 98635fd..f9013a3 100644 --- a/packages/audiofileplayer/CHANGELOG.md +++ b/packages/audiofileplayer/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.1.1 - 21 Oct 2022 + * Fix issue with starting MediaSessionCompat + ## 2.1.0 - 08 Nov 2021 * Android service: move startForeground into onStartCommand * Android S fixes for PendingIntent diff --git a/packages/audiofileplayer/android/src/main/java/com/google/flutter/plugins/audiofileplayer/AudiofileplayerService.java b/packages/audiofileplayer/android/src/main/java/com/google/flutter/plugins/audiofileplayer/AudiofileplayerService.java index 5a3e867..7307710 100644 --- a/packages/audiofileplayer/android/src/main/java/com/google/flutter/plugins/audiofileplayer/AudiofileplayerService.java +++ b/packages/audiofileplayer/android/src/main/java/com/google/flutter/plugins/audiofileplayer/AudiofileplayerService.java @@ -62,13 +62,9 @@ public void onCreate() { super.onCreate(); Log.i(TAG, "onCreate"); instance = this; - PendingIntent pendingItent = PendingIntent.getBroadcast( - getApplicationContext(), - 0, new Intent(Intent.ACTION_MEDIA_BUTTON), - PendingIntent.FLAG_IMMUTABLE - ); - mediaSession = new MediaSessionCompat(this, TAG, null, pendingItent); + // TODO: Migrate to MediaSession, re-add support for hardware buttons via a BroadcastService. + mediaSession = new MediaSessionCompat(this, TAG); mediaSession.setFlags( MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS); diff --git a/packages/audiofileplayer/pubspec.yaml b/packages/audiofileplayer/pubspec.yaml index bc7bfb2..ff2cd6f 100644 --- a/packages/audiofileplayer/pubspec.yaml +++ b/packages/audiofileplayer/pubspec.yaml @@ -1,6 +1,6 @@ name: audiofileplayer description: A Flutter plugin for audio playback. -version: 2.1.0 +version: 2.1.1 homepage: https://github.com/google/flutter.plugins/tree/master/packages/audiofileplayer environment: