Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification Player not properly loading after pressing stop button. #86

Closed
am2074 opened this issue Aug 11, 2020 · 10 comments
Closed

Notification Player not properly loading after pressing stop button. #86

am2074 opened this issue Aug 11, 2020 · 10 comments

Comments

@am2074
Copy link

am2074 commented Aug 11, 2020

The notification player works fine until the user presses the stop button. The problem arises when the user presses play again and this time the notification player doesn't come back on. However, if the user uses the pause function in the player itself, the notification player comes back. The correct way it should work is that once the stop button is pressed and the player presses play again, the notification player should reappear as opposed to when calling the pause function.

@monkeyswarm
Copy link
Collaborator

I'm assuming you are referring to Android notifications in this case.

It's up to the developer to respond to the notification buttons, and to display the notification when it isn't displayed.

If you are calling AudioSystem.instance.stopBackgroundDisplay() on tapping the notification 'stop' button, then, on resuming playback, you must call AudioSytem.instance.setMetadata() and setPlaybackState() in order for the notification to show up again.

@am2074
Copy link
Author

am2074 commented Aug 11, 2020

I see. I noticed this problem is apparent in my app, but this problem is also present in this plugin's Example app too, where in this plugin's example, setPlayback() and and setMetaData() are called in the example's "_resumeBackgroundAudio()" Future function, but still fails to get back the notification player once stopBackgroundDisplay() has been called. The notification bar still only appears when pause is played after pressing the stop.

Also, thanks for the quick reply.

@monkeyswarm
Copy link
Collaborator

What device and version of Android are you seeing this on?

@am2074
Copy link
Author

am2074 commented Aug 11, 2020

I'm using a emulation for the Pixel 2.

After just looking around and testing the example, it seems that the resume function retrieves the notification player after stopping will sometimes work and sometimes it won't. I notice that the chance of it not happening occurs more when stopping using the notification player while the audio is still playing.

@am2074
Copy link
Author

am2074 commented Aug 11, 2020

Also forgot to mention that I'm using API Level 28

@monkeyswarm
Copy link
Collaborator

I start the example app, tap play button in card #4. Open the notification and hit 'stop', and wait a second for the notification to go away, then return to the app and hit that same 'play' button in card #4.

I'm getting a full-on crash when I do this on 8.1 on a Nexus 5x. Seems to work ok on a newer device on Android 10 (but perhaps there's a race condition that makes it succeed). I will investigate.

====
08-11 19:05:18.070 16166 16166 I AudiofileplayerService: onStartCommand
08-11 19:05:18.083 1830 1830 E StatusBar: couldn't inflate view for notification com.google.flutter.plugins.audiofileplayer_example/0xd431
08-11 19:05:18.083 1830 1830 E StatusBar: java.lang.IllegalArgumentException: setShowActionsInCompactView: action 0 out of bounds (max -1)
08-11 19:05:18.083 1830 1830 E StatusBar: at android.app.Notification$MediaStyle.makeMediaContentView(Notification.java:6767)
08-11 19:05:18.083 1830 1830 E StatusBar: at android.app.Notification$MediaStyle.makeContentView(Notification.java:6685)
08-11 19:05:18.083 1830 1830 E StatusBar: at android.app.Notification$Builder.createContentView(Notification.java:4431)
08-11 19:05:18.083 1830 1830 E StatusBar: at com.android.systemui.statusbar.notification.NotificationInflater.createContentView(NotificationInflater.java:486)
08-11 19:05:18.083 1830 1830 E StatusBar: at com.android.systemui.statusbar.notification.NotificationInflater.createRemoteViews(NotificationInflater.java:162)
08-11 19:05:18.083 1830 1830 E StatusBar: at com.android.systemui.statusbar.notification.NotificationInflater.-wrap1(Unknown Source:0)
08-11 19:05:18.083 1830 1830 E StatusBar: at com.android.systemui.statusbar.notification.NotificationInflater$AsyncInflationTask.doInBackground(NotificationInflater.java:593)
08-11 19:05:18.083 1830 1830 E StatusBar: at com.android.systemui.statusbar.notification.NotificationInflater$AsyncInflationTask.doInBackground(NotificationInflater.java:574)
08-11 19:05:18.083 1830 1830 E StatusBar: at android.os.AsyncTask$2.call(AsyncTask.java:333)
08-11 19:05:18.083 1830 1830 E StatusBar: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
08-11 19:05:18.083 1830 1830 E StatusBar: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
08-11 19:05:18.083 1830 1830 E StatusBar: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
08-11 19:05:18.083 1830 1830 E StatusBar: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
08-11 19:05:18.083 1830 1830 E StatusBar: at java.lang.Thread.run(Thread.java:764)
08-11 19:05:18.083 1830 1830 W StatusBar: removeNotification for unknown key: 0|com.google.flutter.plugins.audiofileplayer_example|54321|null|10098
08-11 19:05:18.084 767 3449 D NotificationService: onNotification error pkg=com.google.flutter.plugins.audiofileplayer_example tag=null id=54321; will crashApplication(uid=10098, pid=16166)
08-11 19:05:18.085 564 3271 D audio_hw_primary: enable_audio_route: usecase(1) apply and update mixer path: low-latency-playback
08-11 19:05:18.085 564 3271 D audio_route: Apply path: low-latency-playback
08-11 19:05:18.085 16166 16166 D AndroidRuntime: Shutting down VM
08-11 19:05:18.086 16166 16166 E AndroidRuntime: FATAL EXCEPTION: main
08-11 19:05:18.086 16166 16166 E AndroidRuntime: Process: com.google.flutter.plugins.audiofileplayer_example, PID: 16166
08-11 19:05:18.086 16166 16166 E AndroidRuntime: android.app.RemoteServiceException: Bad notification posted from package com.google.flutter.plugins.audiofileplayer_example: Couldn't inflate contentViewsjava.lang.IllegalArgumentException: setShowActionsInCompactView: action 0 out of bounds (max -1)
08-11 19:05:18.086 16166 16166 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1768)
08-11 19:05:18.086 16166 16166 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
08-11 19:05:18.086 16166 16166 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
08-11 19:05:18.086 16166 16166 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6494)
08-11 19:05:18.086 16166 16166 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
08-11 19:05:18.086 16166 16166 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
08-11 19:05:18.086 16166 16166 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
08-11 19:05:18.088 1830 1830 W StatusBar: removeNotification for unknown key: 0|com.google.flutter.plugins.audiofileplayer_example|54321|null|10098
08-11 19:05:18.090 767 3483 W ActivityManager: Force finishing activity com.google.flutter.plugins.audiofileplayer_example/.MainActivity

@am2074
Copy link
Author

am2074 commented Aug 12, 2020

Cool.

I tried it on the Android 10, and it seems to better than on the version I was previously using. However, the error I described earlier will sometimes still occur. I will try it on an actual device to see if this also the case and will share my findings.

@am2074
Copy link
Author

am2074 commented Aug 12, 2020

Just finished trying it on an actual android device which is a Pixel 3 that is on Android 10. The app crashes in both mine and the examples right after pressing the 'stop' button on the notification player.

Here is the error from the example app tested on an actual device:

D/AndroidRuntime( 8763): Shutting down VM
E/AndroidRuntime( 8763): FATAL EXCEPTION: main
E/AndroidRuntime( 8763): Process: example, PID: 8763
E/AndroidRuntime( 8763): android.app.RemoteServiceException: Bad notification(tag=null, id=54321) posted from package example, crashing app(uid=10243, pid=8763): Couldn't inflate contentViewsjava.lang.IllegalArgumentException: setShowActionsInCompactView: action 0 out of bounds (max -1)
E/AndroidRuntime( 8763): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1945)
E/AndroidRuntime( 8763): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime( 8763): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime( 8763): at android.app.ActivityThread.main(ActivityThread.java:7356)
E/AndroidRuntime( 8763): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 8763): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime( 8763): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

@monkeyswarm
Copy link
Collaborator

I just made a fix and published it as version 1.3.2. Please try that and let me know if it fixes the issue for you.

@am2074
Copy link
Author

am2074 commented Aug 12, 2020

Awesome. I'm reporting no problems so far when I try it on an actual device with the new update.

Thank you very much, I appreciate the quick responses.

@am2074 am2074 closed this as completed Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants