I tested this version on android15. This is the original 2.1 extension with a few changes.
UrsMediaNotification338.aia (7.5 MB)
I tested this version on android15. This is the original 2.1 extension with a few changes.
UrsMediaNotification338.aia (7.5 MB)
Yes, this version works on Android 15, but not all buttons are displayed (not fast forward, rewind).
This version does not work on Android 11. No notification is displayed.
Ulli sent me a test app with a new version of his extension UrsMediaNotification_3.aix to test. This works on all Android versions 5-15 without any problems, except on Android 11. There the notification is not displayed. Another version works on Android 5-11 (and 12), but not on Android 13-15.
I don't have Android 11, a Logcat log would be useful. Have you tested my Media3 extension on Android 11?
On the pixel emulator with android 11 I receive notifications with this project:
UrsMediaNotification338 (1).aia (7.5 MB)
WOW, this one works!!!
with all buttons
The whole problem is here:
The problem is the album covers, which are quite large images. The extension builds the notification in the main class, along with icons, and then passes it to the service. The notification is too heavy to be passed in the Intent.
Since Android 13 the way of adding custom actions/icons has changed a bit. The standard notification always contains 3 buttons. The rest are custom buttons. And I think additional icons can only be added from drawable resources, although I could be wrong. The additional scroll buttons are not really necessary, since we have a scroll bar.
Try this extension but without image metadata.
Yes, but here the metadata is removed. The error occurs when the metadata contains large cover images.
This is a screenshot of the correctly displayed notification on my Motorola g15 (Android 15). If you press one of the buttons, the error occurs.
The notification is not transmitted via parcelable. I changed this a long time ago because there were problems with the rather large images.
Did you use MediaSessionCallback to receive button presses?
package de.ullisroboterseite.ursai2medianotification;
import android.os.Bundle;
import android.util.Log;
import android.support.v4.media.session.MediaSessionCompat;
public class MyMediaSessionCallback extends MediaSessionCompat.Callback {
private final UrsMediaNotification mediaNotification;
private final String LOG_TAG = "MyMediaSessionCallback";
public MyMediaSessionCallback(UrsMediaNotification mediaNotification) {
this.mediaNotification = mediaNotification;
}
@Override
public void onPlay() {
Log.d(LOG_TAG, "onPlay");
mediaNotification.ActionButtonClicked("play", true);
}
@Override
public void onPause() {
Log.d(LOG_TAG, "onPause");
mediaNotification.ActionButtonClicked("pause", true);
}
@Override
public void onSkipToNext() {
mediaNotification.ActionButtonClicked("next", true);
}
@Override
public void onSkipToPrevious() {
mediaNotification.ActionButtonClicked("previous", true);
}
@Override
public void onSeekTo(long pos) {
Log.d(LOG_TAG, "onSeekTo: " + pos);
mediaNotification.ActionScrollBar("seek", pos);
}
@Override
public void onRewind() {
Log.d(LOG_TAG, "onRewind");
mediaNotification.ActionButtonClicked("rewind", true);
}
@Override
public void onFastForward() {
Log.d(LOG_TAG, "onFastForward");
mediaNotification.ActionButtonClicked("fastforward", true);
}
@Override
public void onCustomAction(String action, Bundle extras) {
if ("MY_CUSTOM_ACTION".equals(action)) {
Log.d(LOG_TAG, "Received: MY_CUSTOM_ACTION");
// ... (do something)
}
}
}
And use:
MediaSessionCompat mediaSession = new MediaSessionCompat(form, "MediaNotificationSession");
MyMediaSessionCallback myMediaSessionCallback = new MyMediaSessionCallback(this);
mediaSession.setCallback(myMediaSessionCallback);
mediaSession.setActive(true);
No, I tried it but got no response. may be I did it wrong. I will have another try later.
Are you using MediaSession or MediaSessionCompat? Also Notification.Builder or NotificationCompat.Builder?
Many of your tips probably deal with the wrong topic.
I would like to come back to the version conflict:
I have also tried other players, e.g. the AI2 Player component. Always the same problem.
I have created a totally reduced version of the MediaNotification, which no longer has any function. Only a MediaSessionCompat is created in the constructor. Nothing else. This is the code:
import android.support.v4.media.session.MediaSessionCompat;
import androidx.media.session.MediaButtonReceiver;
...
@UsesLibraries(libraries = "androidx.media.jar")
...
ComponentName mbrComponent = MediaButtonReceiver.getMediaButtonReceiverComponent(form);
Intent mediaButtonIntent = new Intent("android.intent.action.MEDIA_BUTTON");
mediaButtonIntent.setComponent(mbrComponent);
PendingIntent mbrIntent = PendingIntent.getBroadcast(form, 0, mediaButtonIntent,
Build.VERSION.SDK_INT >= 31 ? PendingIntent.FLAG_IMMUTABLE : 0);
mediaSession = new MediaSessionCompat(form, "MediaNotificationSession", mbrComponent, mbrIntent);
The java file:
UrsMediaTest.java.txt (2.1 KB)
"androix.media.jar" is version 1.3.1 from https://mvnrepository.com/artifact/androidx.media/media
Creating the MediaSessionCompat prevents the player from working properly.
You can start the player immediately after downloading the compiled app and installing it. After that, the app no longer responds.
If you close the running apps and start them again, only the splash screen is displayed. Nothing happens after that.
This is the project file:
Combined.aia (1.7 MB)
To the player component I added some aditional outputs to the Log. Using the original version makes no difference.
The last projects I shared here contain your extension but in version 2.1. I modified them a bit, adding Compat and MediaSessionCalback classes. They also contain Media library in version 1.7. I didn't notice any problem. I don't think the native MediaPlayer would cause any problem.
I'll try your project. You can also share the source of the extension, e.g. on PW. I'll take a look at the whole thing. If there's a problem, it's probably something minor.