I am using the following code:
override func viewDidLayoutSubviews() {
        UIApplication.shared.keyWindow?.addSubview(attachmentsView)
        attachmentsView.frame.size = CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
        attachmentsView.isHidden = true
    }
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
            if((info[UIImagePickerControllerMediaType] as? String) == "public.movie" )
            {
                if let file = info[UIImagePickerControllerMediaURL] as? NSURL
                {
                    let av = AVPlayerViewController()
                    let player = AVPlayer(url: file as URL)
                    av.player = player
                    av.view.frame = attachmentsView.frame
                    av.modalPresentationStyle = UIModalPresentationStyle.fullScreen
                    self.addChildViewController(av)
                    attachmentsView.isHidden = false
                    attachmentsView.addSubview(av.view)
                    av.didMove(toParentViewController: self)
                }
            }
}
Error that I am getting:
 I am not able to understand why I am getting this error. Please help me understand the situation and avoid this error. Thanks.
I am not able to understand why I am getting this error. Please help me understand the situation and avoid this error. Thanks.
