XamarinMediaManager
XamarinMediaManager copied to clipboard
Xamairn.Forms iOS: Switching tabs would make the player black .
🐛 Bug Report
I have an app with multiple tabs one of them has the VideoView that plays the sample video automatically , when i switch to the next tab i can still hear the video playing . However, when i switch back to the video tab , the video is still playing (i can hear it) but I can see only black box instead of the actual video .
I think it has to do with what this link says https://stackoverflow.com/questions/21737017/avplayerlayer-blank-after-entering-background-while-being-in-a-hidden-controller/42822384#42822384
Note: This works on Android
Expected behavior
You can see the video when you switch back between the tabs
Reproduction steps
I have uploaded a sample project.
Configuration
Version: 0.8.9 MediaManagerSample.zip
Platform:
- [x] :iphone: iOS
- [ ] :robot: Android
- [ ] :checkered_flag: WPF
- [ ] :earth_americas: UWP
- [ ] :apple: MacOS
- [ ] :tv: tvOS
- [x] :monkey: Xamarin.Forms
Yes i noticed this issue too. It only happens on Forms, with iOS. The problem is that Forms doesn't pass on the viewcontroller events, which i use to hook up the videoview.
For now you can work around it by setting the videoview manually: https://github.com/martijn00/XamarinMediaManager#add-video-player-to-the-ui
Ok two questions :
- What is the difference between VideoView and VideoPlayer ? and why they are two different things ?
- regarding your workaround, if I have a Xamarin.Forms , how i would apply it ? is it kind of dependency service ?
-
VideoView is a custom view within MediaManager to show video. It adds some extra functionality so crossplatform works better. VideoPlayer is the native platform player that is used to playback the video.
-
This is where the view is added in Forms: https://github.com/martijn00/XamarinMediaManager/blob/develop/MediaManager.Forms/Platforms/Ios/VideoViewRenderer.cs
This is where the problem is: https://github.com/martijn00/XamarinMediaManager/blob/develop/MediaManager/Platforms/Ios/Video/VideoView.cs#L35
Superview?.NextResponder as UIViewController
is not a UIViewController but a UIView in Forms. Somehow i should be able to get a hold of the UIViewController and pass that, and then it would be fixed.
I'm running into this too... I'm also getting a hard crash with the video player... I'm trying to diagnosis it, but it straight up kills the app. I'm playing some music, then switch to playing a video and the app just dies. Only on iOS so I'm thinking there could be a relation.
I added the view render for iOS like shown in step 2
and also add MediaManager.CrossMediaManager.Current.MediaPlayer.VideoView = _videoView;
to assign the view, and set auto-attach to false but it doesn't seem to be making a difference, the screen is still black... it's quite possible I'm missing something.
However, in my use case, I have an grid and in 1 row I have an image view and the VideoView and only 1 visible at a time... so when a song is playing the album art is shown and the video player is hidden and when a video is played, the opposite is in effect.
Thanks, Rich
@martijn00 getting same issue even video view added manually to mediamanager. Any help on this? Thanks in advance
I'm also having this issue on Android. It seems that it's only possible to do
CrossMediaManager.Current.MediaPlayer.VideoView = _videoView;
Before SetNativeControl()
on Android.
After that it seems like you cannot detach it or attach a different VideoView.
make sure you have your videoview in an content video, then the video player will still visible