0

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:

enter image description here I am not able to understand why I am getting this error. Please help me understand the situation and avoid this error. Thanks.

Enrik Qaz
  • 243
  • 4
  • 14
  • Possible duplicate of https://stackoverflow.com/questions/32860362/unable-to-simultaneously-satisfy-constraints-warnings-with-avplayerviewcontrolle not marking as duplicate yet though :) As far as I know its a bug at Apple end :) So simplest solution is to use AVPlayerLayer and implement controls on your own or use whatever workaround suggested in post above – Sandeep Bhandari Oct 15 '18 at 06:57
  • @SandeepBhandari, they are for Objective C. Can you help me solving the same for Swift? – Enrik Qaz Oct 15 '18 at 07:00
  • Solution is still the same in swift as well :) I remember finding an answer to similar question by matt lemme check if I can find that Ill post it here :) – Sandeep Bhandari Oct 15 '18 at 07:27

0 Answers0