From c771457f4926cdd1aae16fffd5b7a841bded7e4f Mon Sep 17 00:00:00 2001 From: Archangel Date: Tue, 24 Jan 2023 12:03:20 +0100 Subject: [PATCH] Fix so that Android Notification spawns --- MediaManager/MediaManager.csproj | 2 +- .../Android/MediaSession/MediaBrowserService.cs | 10 +++++----- .../Platforms/Android/Resources/values/string.xml | 5 +++++ 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 MediaManager/Platforms/Android/Resources/values/string.xml diff --git a/MediaManager/MediaManager.csproj b/MediaManager/MediaManager.csproj index 06eba545..03ad1e3f 100644 --- a/MediaManager/MediaManager.csproj +++ b/MediaManager/MediaManager.csproj @@ -77,7 +77,7 @@ - + diff --git a/MediaManager/Platforms/Android/MediaSession/MediaBrowserService.cs b/MediaManager/Platforms/Android/MediaSession/MediaBrowserService.cs index 2bea52ab..92304244 100644 --- a/MediaManager/Platforms/Android/MediaSession/MediaBrowserService.cs +++ b/MediaManager/Platforms/Android/MediaSession/MediaBrowserService.cs @@ -4,6 +4,7 @@ using Android.Runtime; using Android.Support.V4.Media; using Android.Support.V4.Media.Session; +using AndroidX.Core.App; using AndroidX.Core.Content; using AndroidX.Media; using AndroidX.Media.Session; @@ -100,10 +101,9 @@ protected virtual void PrepareMediaSession() protected virtual void PrepareNotificationManager() { MediaDescriptionAdapter = new MediaDescriptionAdapter(); - PlayerNotificationManager = new Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager.Builder( - this, - ForegroundNotificationId, - ChannelId) + PlayerNotificationManager = new Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager.Builder(this, ForegroundNotificationId, ChannelId) + .SetChannelNameResourceId(Resource.String.XamarinMediaManagerName) + .SetChannelDescriptionResourceId(Resource.String.XamarinMediaManagerDescription) .SetMediaDescriptionAdapter(MediaDescriptionAdapter) .SetNotificationListener(NotificationListener) .Build(); @@ -136,10 +136,10 @@ protected virtual void PrepareNotificationManager() PlayerNotificationManager.SetUsePlayPauseActions(MediaManager.Notification.ShowPlayPauseControls); //PlayerNotificationManager.SetUseNavigationActions(MediaManager.Notification.ShowNavigationControls); PlayerNotificationManager.SetSmallIcon(MediaManager.NotificationIconResource); + PlayerNotificationManager.SetPriority(NotificationCompat.PriorityLow); //Must be called to start the connection (MediaManager.Notification as Notifications.NotificationManager).Player = MediaManager.Player; - //PlayerNotificationManager.SetPlayer(MediaManager.AndroidMediaPlayer.Player); } public override StartCommandResult OnStartCommand(Intent startIntent, StartCommandFlags flags, int startId) diff --git a/MediaManager/Platforms/Android/Resources/values/string.xml b/MediaManager/Platforms/Android/Resources/values/string.xml new file mode 100644 index 00000000..b1ebb295 --- /dev/null +++ b/MediaManager/Platforms/Android/Resources/values/string.xml @@ -0,0 +1,5 @@ + + + Xamarin Media Manager + Media player for .NET MAUI + \ No newline at end of file