Skip to content

Commit

Permalink
Merge pull request #887 from ArchangelWTF/patch_notification
Browse files Browse the repository at this point in the history
Fix so that Android Notification spawns
  • Loading branch information
martijn00 authored Jan 24, 2023
2 parents 9a9716f + c771457 commit d5f0174
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MediaManager/MediaManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<None Remove="Platforms\Android\**\*.cs" />
<Compile Include="Platforms\Android\**\*.cs" />
<AndroidResource Include="Resources\**\*.xml" SubType="Designer" Generator="MSBuild:UpdateAndroidResources" />
<AndroidResource Include="Platforms\Android\Resources\**\*.xml" SubType="Designer" Generator="MSBuild:UpdateAndroidResources" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer" Version="2.18.8" />
<!--<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Cast" Version="2.11.8" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Leanback" Version="2.11.8" />-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions MediaManager/Platforms/Android/Resources/values/string.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<string name="XamarinMediaManagerName">Xamarin Media Manager</string>
<string name="XamarinMediaManagerDescription">Media player for .NET MAUI</string>
</resources>

0 comments on commit d5f0174

Please sign in to comment.