Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/audiofileplayer/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 29
compileSdkVersion 31

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -40,5 +40,5 @@ android {

dependencies {
implementation 'androidx.core:core:1.0.0'
implementation 'androidx.media:media:1.0.0'
implementation 'androidx.media:media:1.3.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -509,16 +509,12 @@ public void onActivityDestroyed(Activity activity) {
@Override
public void onConnected() {
Log.i(TAG, "ConnectionCallback.onConnected");
try {
MediaSessionCompat.Token token = mediaBrowser.getSessionToken();
mediaController = new MediaControllerCompat(activity, token);
MediaControllerCompat.setMediaController(activity, mediaController);
mediaController.registerCallback(controllerCallback);
AudiofileplayerService.instance.setPendingIntentActivity(activity);
AudiofileplayerService.instance.setListener(AudiofileplayerPlugin.this);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
MediaSessionCompat.Token token = mediaBrowser.getSessionToken();
mediaController = new MediaControllerCompat(activity, token);
MediaControllerCompat.setMediaController(activity, mediaController);
mediaController.registerCallback(controllerCallback);
AudiofileplayerService.instance.setPendingIntentActivity(activity);
AudiofileplayerService.instance.setListener(AudiofileplayerPlugin.this);
}

@Override
Expand Down Expand Up @@ -676,8 +672,9 @@ private NotificationCompat.Action customMediaButtonMapToAction(Map customMediaBu
Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
intent.setComponent(component);
intent.putExtra(CUSTOM_MEDIA_BUTTON_EXTRA_KEY, eventId);

PendingIntent pendingIntent =
PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT);

return new NotificationCompat.Action(resourceId, title, pendingIntent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ 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);
mediaSession = new MediaSessionCompat(this, TAG, null, pendingItent);
mediaSession.setFlags(
MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS
| MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
Expand Down Expand Up @@ -137,7 +142,7 @@ public void setPendingIntentActivity(Activity activity) {
Context context = activity.getApplicationContext();
Intent intent = new Intent(context, activity.getClass());
PendingIntent pendingIntent =
PendingIntent.getActivity(context, 99, intent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent.getActivity(context, 99, intent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
mediaSession.setSessionActivity(pendingIntent);
}

Expand Down