Esempio n. 1
0
        public void Setup(CustomVideoLayer layer)
        {
            if (!IsSupported() || IsSetep)
            {
                return;
            }

            if (layer?.VideoLayer != null)
            {
                controller          = new AVPictureInPictureController(layer.VideoLayer);
                controller.Delegate = this;
            }

            layer.VideoLayerChanged += (AVPlayerLayer obj) => {
                if (!IsSupported())
                {
                    return;
                }
                bool isActive = controller?.PictureInPictureActive ?? false;
                if (isActive)
                {
                    controller?.StopPictureInPicture();
                }
                controller          = new AVPictureInPictureController(layer.VideoLayer);
                controller.Delegate = this;
                if (isActive)
                {
                    controller.StartPictureInPicture();
                }
            };
            IsSetep = true;
        }
Esempio n. 2
0
 public bool StartPictureInPicture()
 {
     if (!IsSupported() || controller == null)
     {
         return(false);
     }
     if (controller.PictureInPictureActive)
     {
         return(true);
     }
     controller.StartPictureInPicture();
     return(true);
 }
Esempio n. 3
0
 void togglePictureInPictureMode(UIButton sender)
 {
     // Toggle picture in picture mode.
     // If active, stop picture in picture and return to inline playback.
     // If not active, initiate picture in picture.
     // Both these calls will trigger delegate callbacks which should be used
     // to set up UI appropriate to the state of the application.
     if (pictureInPictureController.PictureInPictureActive)
     {
         pictureInPictureController.StopPictureInPicture();
     }
     else
     {
         pictureInPictureController.StartPictureInPicture();
     }
 }