Baseflow / XamarinMediaManager

Cross platform Xamarin plugin to play and control Audio and Video
https://baseflow.com
MIT License
762 stars 305 forks source link

unable to play fullscreen video in ios with xamarin shell on ios 15+ #854

Closed developerfiveneosoftware closed 1 year ago

developerfiveneosoftware commented 2 years ago

🐛 Bug Report

Unable to play video full screen with xamarin shell project on ios 15.3.

This looks very similar to a bug that was previously raised. https://github.com/Baseflow/XamarinMediaManager/issues/629

I am using Xamarin forms.

I have the Nav bar visible.

I am attempting to play a HLS video. This works fine initially and the controls show/respond. If I click the full screen option the video does not render and the an error in the logs appear.

Warning: <MediaManager_Platforms_Ios_Video_PlayerViewController: 0x7f930c93de00> is trying to enter full screen, but is not in its view's window's view controller hierarchy. This results in undefined behavior..

Expected behavior

The video should open in full screen and play.

Reproduction steps

Create a Shell tab project within xamarin forms

PAGE XML

<mm:VideoView 
                x:Name="video"
                VerticalOptions="FillAndExpand"
                HorizontalOptions="FillAndExpand" />

Page Code Behind

protected async override void OnAppearing()
        {
            base.OnAppearing();

            Xamarin.Essentials.DeviceDisplay.KeepScreenOn = true;

            CrossMediaManager.Current.Init();

            var item = await CrossMediaManager.Current.Extractor.CreateMediaItem("https://multiplatform-f.akamaihd.net/i/multi/will/bunny/big_buck_bunny_,640x360_400,640x360_700,640x360_1000,950x540_1500,.f4v.csmil/master.m3u8");
            item.MediaType = MediaType.Hls;

            await CrossMediaManager.Current.Play(item);
        }

This is my first time raising something here. Let me know if I have missed anything or need to add more detail etc.

Configuration

Plugin.MediaManger.Forms 1.1 Xamarn.Forms 5.0.0.7757 Xamairn.Essentials 1.7.1

Platform:

profilen commented 1 year ago

@developerfiveneosoftware I had the same problem. In my case I was stopping and disposing the player in OnDisappearing(). However, this doesn't work since OnDisappearing() is called when you going into Fullscreen.

developerfiveneosoftware commented 1 year ago

@profilen Thanks. I created a separate video player for ios and android. Android uses exoplayer and ios uses the AVPlayer.

I then used dependecy injection to select the correct player based on platform. (It's similar to what the media manager does under the hood.)

The ios AVPlayer handles the fullscreen and airplay etc.

This was my first ticket and bug report, so not sure of the process.

Do you want me to close the bug, or is that something someone else should do?