diff --git a/MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs b/MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs index 37a4ee10..55442ca2 100644 --- a/MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs +++ b/MediaManager/Platforms/Android/Player/AndroidMediaPlayer.cs @@ -166,6 +166,8 @@ protected virtual void Initialize() .Build(); Player.SetAudioAttributes(audioAttributes, true); + Player.SetHandleAudioBecomingNoisy(true); + Player.SetHandleWakeLock(true); PlayerEventListener = new PlayerEventListener() { @@ -280,6 +282,7 @@ public virtual void ConnectMediaSession() PlaybackPreparer = new MediaSessionConnectorPlaybackPreparer(Player, MediaSource); MediaSessionConnector.SetPlayer(Player); + MediaSessionConnector.SetPlaybackPreparer(PlaybackPreparer); } public override async Task Play(IMediaItem mediaItem) @@ -338,7 +341,7 @@ public override Task SeekTo(TimeSpan position) public override Task Stop() { - Player.Stop(); + Player.Stop(true); return Task.CompletedTask; } diff --git a/MediaManager/Platforms/Android/Player/PlaybackPreparer.cs b/MediaManager/Platforms/Android/Player/PlaybackPreparer.cs index 63c1ae20..95684be3 100644 --- a/MediaManager/Platforms/Android/Player/PlaybackPreparer.cs +++ b/MediaManager/Platforms/Android/Player/PlaybackPreparer.cs @@ -26,7 +26,15 @@ protected MediaSessionConnectorPlaybackPreparer(IntPtr handle, JniHandleOwnershi { } - public long SupportedPrepareActions => MediaSessionConnector.IPlaybackPreparer.Actions; + //public long SupportedPrepareActions => MediaSessionConnector.IPlaybackPreparer.Actions; + public long SupportedPrepareActions => + PlaybackStateCompat.ActionPrepare | + PlaybackStateCompat.ActionPrepareFromMediaId | + PlaybackStateCompat.ActionPrepareFromSearch | + PlaybackStateCompat.ActionPrepareFromUri | + PlaybackStateCompat.ActionPlayFromMediaId | + PlaybackStateCompat.ActionPlayFromSearch | + PlaybackStateCompat.ActionPlayFromUri; public bool OnCommand(IPlayer p0, IControlDispatcher p1, string p2, Bundle p3, ResultReceiver p4) {