How to prevent Xamarin Community Toolkit MediaElement from requesting audio focus on Android

Matti Tornio 1 Reputation point
2021-06-13T16:29:08.023+00:00

Our fitness app uses MediaElement from Xamarin Community Toolkit to play instructional videos. These video files have no audio track but starting to play a video will still pause any music from other apps such as Spotify that is playing in the background. On iOS this is easy to fix but we haven't had any luck on Android yet.

Is there any easy way on Android to prevent Xamarin MediaElement (which is using Android MediaPlayer under the hood) from requesting audio focus when a video file starts playing? None of our videos have audio tracks and we already setting MediaElement's volume to zero, but neither of these fixes our problem.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,294 questions
{count} votes