Android および古い IOS バージョンではすべて正常に動作しますが、IOS バージョン 13.5 を使用している場合、フルスクリーンに切り替えるとビデオがクラッシュします。アプリはクラッシュせず、例外もありません。フルスクリーンを終了して再生をもう一度押すと、ビデオを再開できます。IPhoneSimulator と実際のデバイスで、さまざまなデバイスと IOS バージョンでテストされています。また、ナビゲーションバーを非表示にして、さまざまな向きを試しました。
// ViewModel
private async void PlayVideo(object parameter)
{
PageManager.NavigateTo(typeof(VideoViewerPage));
CrossMediaManager.Current.MediaPlayer.VideoAspect = MediaManager.Video.VideoAspectMode.AspectFit;
CrossMediaManager.Current.MediaPlayer.ShowPlaybackControls = true;
if (Device.RuntimePlatform == Device.iOS)
{
await CrossMediaManager.Current.PlayFromResource(parameter.ToString());
}
else if(Device.RuntimePlatform == Device.Android)
{
Stream stream = DependencyService.Get<IReadFile>().Open(parameter.ToString());
await CrossMediaManager.Current.Play(stream, "Video");
}
}
// View
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mm="clr-namespace:MediaManager.Forms;assembly=MediaManager.Forms"
mc:Ignorable="d"
x:Class="SharedProject.Views.VideoViewerPage"
NavigationPage.HasNavigationBar="True">
<mm:VideoView VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"/>
</ContentPage>
// Codebehind of View
public VideoViewerPage()
{
InitializeComponent();
if (Device.RuntimePlatform == Device.Android)
{
NavigationPage.SetHasNavigationBar(this, false);
}
}
protected override void OnAppearing()
{
MessagingCenter.Send(this, "allowLandScapePortrait");
base.OnAppearing();
}
protected override void OnDisappearing()
{
MediaManager.CrossMediaManager.Current.Stop();
MessagingCenter.Send(this, "preventLandScape");
base.OnDisappearing();
}