Hello,
Why am I getting the exception?
This exception is thrown by the third-party package, please see their source code- https://github.com/Baseflow/XamarinMediaManager/blob/develop/MediaManager/Platforms/Ios/Video/VideoView.cs#L36
Because you are using MonoGame
, and MonoGame
has its own method to get the current controller, the rootcontroller
will be null in MediaManager
.
For this, please contact the owners of MediaManager
to ask if there are any ways to avoid their GetCurrentUIViewController()
method and pass the gameController
of MonoGame.
(Note: Third-party tools are not supported on Q&A, please get further help from them)
In other way, you could try to present an AVPlayerViewController
(without MediaManager
package)
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
var player = new AVPlayer(NSUrl.FromString("https://videos.pexels.com/video-files/7356431/7356431-hd_1280_720_25fps.mp4"));
var PlayerViewController = new AVPlayerViewController();
PlayerViewController.Player = player;
var gameController = this.Services.GetService(typeof(UIViewController)) as UIViewController;
gameController.PresentViewController(PlayerViewController, true, null);
}
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.