Focusing on .net Maui Media Element Android fullscreen Video Issue Which is not currently supported by .net Maui MediaElement.
A custom Device Orientation Service was created in order to override and manupulate orientation on the go.
namespace MElemetModified.Services;
public partial class DeviceOrientationService{
public partial void SetDeviceOrientation(DisplayOrientation displayOrientation);
}
and this method needs to inherited into All platforms.
namespace MElemetModified.Services;
public partial class DeviceOrientationService{
private static readonly IReadOnlyDictionary<DisplayOrientation, ScreenOrientation> _androidDisplayOrientationMap =
new Dictionary<DisplayOrientation, ScreenOrientation>{
[DisplayOrientation.Landscape] = ScreenOrientation.Landscape,
[DisplayOrientation.Portrait] = ScreenOrientation.Portrait,
};
public partial void SetDeviceOrientation(DisplayOrientation displayOrientation){
var currentActivity = ActivityStateManager.Default.GetCurrentActivity();
if (currentActivity is not null)
if (_androidDisplayOrientationMap.TryGetValue(displayOrientation, out ScreenOrientation screenOrientation))
currentActivity.RequestedOrientation = screenOrientation;
}
}
namespace MElemetModified.Services;
public partial class DeviceOrientationService{
public partial void SetDeviceOrientation(DisplayOrientation displayOrientation){}
}
As it can be seen In other platform specific codes the method can be kept empty.
Finally, for in the media visualization page it is necessary to define platform wise condtions as iOS has no issue regarding video fullscreen.
#if ANDROID
// Make Fullscreen Button visible
#elif IOS
// keep Fullscreen Button hidden
#endif