title: AVPlayerViewController Video Worked on iOS 11, 12 but Not iOS 13 With iPhone 11
body: <p>I'm receiving a strange bug where my background video plays as expected on  <code>iOS 13</code> <strong>iPhone 8</strong>, <strong>iPhone 8+</strong>, <strong>iPhone 11</strong> simulator (and device) but does NOT play on  <code>iOS 13</code> <strong>iPhone 11 Pro</strong> or <strong>iPhone 11 Pro Max</strong> simulator.</p>
  
  <p>I reference the <code>VideoSplashViewController</code> below in a separate landing page view controller.</p>
  
  <p><strong>VideoSplashViewController</strong></p>
  
  <pre class="lang-swift prettyprint-override"><code>import UIKit
  import MediaPlayer
  import AVKit
  
  public enum ScalingMode {
    case resize
    case resizeAspect
    case resizeAspectFill
  }
  
  open class VideoSplashViewController: UIViewController {
  
    fileprivate let moviePlayer = AVPlayerViewController()
    fileprivate var moviePlayerSoundLevel: Float = 1.0
    open var contentURL: URL? {
      didSet {
        setMoviePlayer(contentURL!)
      }
    }
  
    open var videoFrame: CGRect = CGRect()
    open var startTime: CGFloat = 0.0
    open var duration: CGFloat = 0.0
    open var backgroundColor: UIColor = UIColor.white {
      didSet {
        view.backgroundColor = backgroundColor
      }
    }
    open var sound: Bool = true {
      didSet {
        if sound {
          moviePlayerSoundLevel = 1.0
        }else{
          moviePlayerSoundLevel = 0.0
        }
      }
    }
    open var alpha: CGFloat = CGFloat() {
      didSet {
        moviePlayer.view.alpha = alpha
      }
    }
    open var alwaysRepeat: Bool = true {
      didSet {
        if alwaysRepeat {
          NotificationCenter.default.addObserver(self,
            selector: #selector(VideoSplashViewController.playerItemDidReachEnd),
            name: NSNotification.Name.AVPlayerItemDidPlayToEndTime,
            object: moviePlayer.player?.currentItem)
        }
      }
    }
    open var fillMode: ScalingMode = .resizeAspectFill {
      didSet {
        switch fillMode {
        case .resize:
          moviePlayer.videoGravity = AVLayerVideoGravity(rawValue: AVLayerVideoGravity.resize.rawValue)
        case .resizeAspect:
          moviePlayer.videoGravity = AVLayerVideoGravity(rawValue: AVLayerVideoGravity.resizeAspect.rawValue)
        case .resizeAspectFill:
          moviePlayer.videoGravity = AVLayerVideoGravity(rawValue: AVLayerVideoGravity.resizeAspectFill.rawValue)
        }
      }
    }
  
    override open func viewDidAppear(_ animated: Bool) {
  
    }
  
      var coverView = UIView()
  
      override open func viewWillAppear(_ animated: Bool) {
          super.viewWillAppear(animated)
  
  
          view.backgroundColor = UIColor.white
  
          moviePlayer.view.frame = videoFrame
          moviePlayer.view.backgroundColor = UIColor.white
  
          moviePlayer.showsPlaybackControls = false
          view.addSubview(moviePlayer.view)
          view.sendSubviewToBack(moviePlayer.view)
  
          coverView.frame = CGRect.init(x: 0, y: 0, width: 500, height: 500)
          coverView.backgroundColor = UIColor.white
          coverView.layer.zPosition = 11;
          coverView.isUserInteractionEnabled = false
          moviePlayer.view.addSubview(coverView)
  
          UIView.animate(withDuration: 2) {
              self.coverView.backgroundColor = UIColor(hue: 0.5194, saturation: 0.4, brightness: 0.94, alpha: 0.1)
              }
  
          _ = try? AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback, mode: .default, options: .mixWithOthers)
  
      }
  
    override open func viewWillDisappear(_ animated: Bool) {
      super.viewDidDisappear(animated)
      NotificationCenter.default.removeObserver(self)
      moviePlayer.view.backgroundColor = UIColor.white
    }
  
    fileprivate func setMoviePlayer(_ url: URL){
      let videoCutter = VideoCutter()
      videoCutter.cropVideoWithUrl(videoUrl: url, startTime: startTime, duration: duration) { (videoPath, error) -&gt; Void in
        if let path = videoPath as URL? {
          DispatchQueue.global().async {
            DispatchQueue.main.async {
              self.moviePlayer.player = AVPlayer(url: path)
              self.moviePlayer.player?.play()
              self.moviePlayer.player?.volume = self.moviePlayerSoundLevel
              //added to mute
              self.moviePlayer.player?.isMuted = true
            }
          }
        }
      }
    }
  
    override open func viewDidLoad() {
      super.viewDidLoad()
      moviePlayer.view.backgroundColor = UIColor.white
    }
  
    override open func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
    }
  
    @objc func playerItemDidReachEnd() {
      moviePlayer.player?.seek(to: CMTime.zero)
      moviePlayer.player?.play()
    }
  }
  
  </code></pre>
  
  <p>This is the code called on my main landing page view.</p>
  
  <p><strong>Code Called In Separate VideoSplashViewController inherited VC</strong> </p>
  
  <pre class="lang-swift prettyprint-override"><code>    func setupVideoBackground() {
          let url = URL(fileURLWithPath: Bundle.main.path(forResource: "timelapse_clouds_compress", ofType: "mp4")!)
  
          // setup layout
          videoFrame = self.view.frame
          fillMode = .resizeAspectFill
          alwaysRepeat = true
          sound = true
          startTime = 2.0
          alpha = 0.8
  
          contentURL = url
          view.isUserInteractionEnabled = true
      }
  </code></pre>
  
  <p>Part of me suspects this is a simulator issue because I see no alerts or errors in XCode and the video works as expected on a real iPhone 8+ iOS 13. Will try to test on a real iPhone 11 Pro Max soon but would appreciate any help!</p>