I have implemented the VideoPlayer into my Xamarin Forms 4.5 app as described in this documentation: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/video-player/
Playing HLS videos is working nicely. However, when I exit from the full-screen mode on iOS, the sound of the video continues to play in the background and the app navigates back to the root of my MasterDetailsPage.
When I return to the page that opens the video player, the page app freezes.
Everything behaves normally if I play the videos without entering the video player's full-screen mode.
I'm using iOS SDK 13.4.
Update
I switched to the new Xamarin Forms MediaElement (https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/mediaelement).
Now the entire app crashes when I exit fullscreen.
I receive this warning when entering fullscreen:
*** Warning: <AVPlayerViewController: 0x7fcfe36bda00> is trying to enter full screen, but is not in its view's window's view controller hierarchy. This results in undefined behavior.
I receive this warning when exiting fullscreen:
*** Warning: <AVPlayerViewController: 0x7fcfe36bda00> is trying to exit full screen, but is not in its view's window's view controller hierarchy. This results in undefined behavior.
XAML Code:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyApp.Views.VideoPage">
<MediaElement x:Name="videoPlayer" ShowsPlaybackControls="True" />
</ContentPage>
C# Code:
using System.Collections.Generic;
using Xamarin.Forms;
namespace MyApp.Views
{
public partial class VideoPage : ContentPage
{
public VideoPage(Video videoItem)
{
InitializeComponent();
videoPlayer.Source = videoItem.Url;
}
}
}
Update #2:
I figured out the issue, but I do not have a fix. When exiting the VideoPlayer fullscreen mode, the OnAppearing() method of the MainPage is called.
Update #3:
Code sample and how to reproduce can be found in my GitHub issue: https://github.com/xamarin/Xamarin.Forms/issues/10169
OnDisappearing. - Lucas Zhang