-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
Version 1.1.1 does not create player in Notification Manager on Android 12 #877
Comments
same here, updated to Android 12. Got the player playing the media, but I can't see anything in the notification area. |
It's probably due to lie in the MediaBrowserService not creating the notification correctly due to Google having removed parts of code there that initialize the NotificationListener which in term starts the notification. |
Thanks @ArchangelWTF for fixing it, but with current version (using .net 6) how can I use it for Xamarin Forms? If yes hope you give me some tutorial. |
If you need backwards compatibility for now for a Xamarin Forms app your best bet would be to create a Fork branched off of this commit 24cf94f and manually do the change my PR did to the MediaBrowserService and then compile it for yourself to use in XF |
@ArchangelWTF I forked the recent changes and packed the required libs with your changes. It is still not working in Android 12. |
@arahmancsd I did more or less the same at https://github.com/janwiebe-jump/XamarinMediaManager/tree/xamarin-android-12 |
@ArchangelWTF, I tried your suggestion and found that the PlayerNotificationManager.Builder method needed to pass 4 parameters, so I fixed it as follows: |
@janwiebe-jump, I tried using your version and to be able to build I also had to remove some targets like in the above comment (I don't know if it caused any errors). However, it still doesn't create player in notification manager, I tested it on Oneplus and Xiaomi phones running Android 12. |
hmm, my version doesn't work either unfortunately. Playing doesn't start. |
@janwiebe-jump you can try workaround from #876 |
To add some details to this issue: MediaManager 1.1.1 has a dependency on NuGet package Xam.Plugins.Android.ExoPlayer.UI 2.11.8, a wrapper around the Android ExoPlayer component. ExoPlayer 2.11 does not pass a required flag (FLAG_IMMUTABLE) when creating a broadcast intent, so on Android 12 (API 31) the player does not start a foreground service as it should. This issue is a problem only when playing longish audio tracks. The app may work just fine when playing tracks of 10-15 minutes (depending on the device) or less. However, when playing longer tracks, if the device goes to sleep or the user navigates away from the app, after a certain point the OS kills the app because XMM has not started the foreground service that allows the app to continue running. For those of us with media players that need to play long audio tracks, it's a real showstopper. I tried checking out the commit recommended as a starting point above (24cf94f). This commit has a dependency on ExoPlayer 2.14.6, which should be compatible with Android 12. The first hurdle: I was unable to get the sample projects to build in VS 2022. The projects have errors related to MvvmCross logging similar to those I reported in #857. After attempting to address those, other errors cropped up and I gave up on the sample projects entirely, since it appears they're not in a usable state. I created a Xamarin Forms project, referenced the MediaManager project, and added a Button to the MainPage that plays a clip. When I click the button, an exception is thrown from OnPrepare() in MediaManager\Platforms\Android\Player\PlaybackPreparer.cs:
So, it appears that particular commit of XMM is not in a working state. I tried updating the project to reference ExoPlayer 2.16.1, but I got build errors indicating that version does not support Xamarin Forms. @martijn00, any suggestions for getting this component working on Android 12+ would be most welcome. Those of us who are using it for media players that play long tracks are stuck - unable to release a new version of our app that works properly due to Google's current API requirements for app updates in Google Play. I understand you're focused on getting XMM ported to Maui and may not have cycles to devote to getting it working yourself. But you might have an idea that could be helpful to those of us looking for a solution to the current impasse. For those who are interested in the test I did, it's available here: https://github.com/sschaub/XamarinMediaManager/tree/android12-patch |
@sschaub That exception is very similar to the one thrown here: Baseflow/ExoPlayerXamarin#137 which I've put a workaround for in that issue, I suppose you could try that or something similar and see if it works without throwing that exception then. |
@ArchangelWTF Thanks for the tip! I really appreciate your quick response. I added the methods your workaround suggests to
with the error:
This is the same error that is causing the problem with XMM 1.1.1. Not sure what to do about it in this particular scenario, since Also, I noticed that video playback is not working. I hear the audio of the video, but the video itself does not appear. |
I've commited some fixes based on this. At least it compiles now. It would be great if someone can write the renderer to Maui. |
Hello @martijn00 @ArchangelWTF Please, our app in production is current crashing for android 12+ users. Throwing this error:
Please, I am willing to pay to have a NuGet version that fixed this. It's super urgent. I already tried building this but I am getting compile error on my Mac. Looking forward to your positive feedback. |
@irediaes If you are not concerned about the notification manager, things should be straightforward. I did update it without having the notification manager yet but working on my local version to solve the notification manager issue. If you have a custom renderer or wherever you use those two flags in your Android Project (I used it in several places for notifications) So you should change them to the followings;
|
I am having compiling issues on my Mac msbuild while building local version.
Please can you share the compile NuGet of this plugin if you have one. |
Update: I did some workaround and I was able to by-pass this issue with same Nuget version that was throw the error. I was able to build for target SDK API 31+ |
Currently, there's an issue with playing longer audio tracks that is more than 15-30min duration. Everything still points back to the plugin. |
@irediaes oh wow! |
This I was doing, directly fixing the issue by referencing the library as a project. |
@zohaibshahzad1990 I did a workaround on the app that got it working instead of the app crashing instantly when launched. At least, users can use the app and play the audios. |
I have had some success creating a patched version of XMM based on commit 24cf94f that seems to work on Android 12. Here are the specific changes I made: @martijn00, if you wanted to create a nuget release that would allow current Xamarin users to get their projects working with Android 12+, if you created a branch at that commit, I could submit a PR. |
@sschaub I think a lot of people are still using Xamarin while waiting for MAUI to be more stable, so it would be great if you could update this package for Xamarin for about 6-12 months. |
@sschaub I have been working on the ExoPlayer bindings for Xamarin for the latest version of ExoPlayerXamarin (2.18.7) at https://github.com/janwiebe-jump/ExoPlayerXamarin |
@copang I agree that it would be very helpful if this project could support Xamarin at least until its announced end of life of May 1, 2024 (https://dotnet.microsoft.com/en-us/platform/support/policy/xamarin). However I don't know what would be involved in having one code base support both Xamarin and MAUI. One issue is that current versions of the ExoPlayer bindings for Xamarin are compatible only with MAUI. |
@sschaub I'm currently working on a way to make the ExoPlayer bindings from the main repository build for both MAUI and MonoAndroid at the moment so that there shouldn't be need for any forks of that repository to keep updating ExoPlayer, as for how such backwards compatibility could be implemented in XamarinMediaManager I would have no idea. |
@ArchangelWTF That's great news! |
The samples are up and running again. On Android Native sample i can use Exoplayer, but on the Maui sample something still doesn't work, but it shows. Let me know if anyone finds a clue. |
Did anyone Figure out how to actually create player notification for android 12+ ? |
@EchoSKSh @ArXamB I was able to solve the problem by forking the XMM project and patching it for Xamarin. Here is my patched version: https://github.com/sschaub/XamarinMediaManager/commits/android12-patch-with-exoplayer2.14 |
even with this patch, still not working here is the details #893 |
@abdoutech93 I was able to fix this issue and it is working fine for me. You can check this repo - https://github.com/EchoSKSh/MediaManagerCustom |
@EchoSKSh I think this repo is private !! I would also specify that I'm trying to play an hls stream. |
Same, any update about it !!!? |
I use my own branch currently, that is suitable for targetSdk 32: Not sure if HLS is working though, I only use it to play MP3 files |
You could use mine as well. It also supports HLS but is based on ExoPlayer 2.14.6 at the moment and it is working fine on Android 12 and earlier. You can find it here: https://github.com/BajakiGabesz/XamarinMediaManager/tree/xamarin-1.1.3 |
If anyone has done fixes, please contribute back as well so the MAUI version stays up-to-date. |
@martijn00 Maybe it would be an idea to create a Xamarin based branch on XamarinMediaManager so that we can merge all these forks we have floating around into one single codebase under one single nuget package much like we have done for ExoPlayer? |
Fine with me! |
Can you share me your workarounds? |
🔙 Regression
I'm using version 1.1.1 and it can work with Android 12, however I noticed that it doesn't create player in notification manager like previous versions (1.0.9), this results in audio only being playable in background about 15-30m and then will be stopped.
Devices running Android lower than 12 still work properly. This issue only occurs on devices running Android 12.
Old (and correct) behavior
Current behavior
Configuration
Xamarin.Forms 5.0.0.2515
Plugin.MediaManager.Forms 1.1.1
Version: 1.1.1
Platform:
The text was updated successfully, but these errors were encountered: