Forum Xamarin.Forms

AVPlayerViewController controls not working

I'm trying to create a custom renderer that will display videos on iOS using native controls. The code below plays the video, but the player controls aren't working right. The controls quickly disappear after the video starts playing and don't come back if I click on the video.

using System;
using AVFoundation;
using AVKit;
using Foundation;
using HelloWorld.iOS.CustomRenderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(HelloWorld.VideoView), typeof(VideoPageRenderer))]

namespace HelloWorld.iOS.CustomRenderers
    public class VideoPageRenderer: ViewRenderer
        protected override void OnElementChanged(ElementChangedEventArgs<View> e)
            this.BackgroundColor = UIKit.UIColor.Blue;
            Console.WriteLine("video view renderer");
            NSUrl videoURL = NSUrl.FromString("");
            var player = AVPlayer.FromUrl(videoURL);
            var playerViewController = new AVPlayerViewController();
            playerViewController.Player = player;
            playerViewController.View.Frame = this.Bounds;
            playerViewController.ShowsPlaybackControls = true;
Sign In or Register to comment.