title: AVPlayer blank video: playing sound but no video
body: <p><a href="https://stackoverflow.com/questions/16802630/avplayer-video-blank-but-hear-sound">This question</a> has the same problem, but the solutions didn't work.</p>
  
  <p>The <code>AVPlayer</code> sometimes plays a blank video: there is sound but no video.</p>
  
  <p>While blank videos were played, we printed the frame and status of the player. The frame was non-zero and was correctly set. The status was also <code>readyToPlay</code>. The <code>play</code> function is also invoked on the main thread.</p>
  
  <p>In other words, the frame for the player layer is valid, and the player is also ready to play. Yet no video appears, even though sound does.</p>
  
  <p>The issue seems to be a timing one. If we wait 5-10 seconds before playing the video, the video works fine each time.</p>
  
  <p>This issue appears on iOS 10, not iOS 8 or 9.</p>
  
  <p><a href="https://forums.developer.apple.com/thread/62521" rel="noreferrer">This thread</a> on the Apple forums suggests it might be a bug related to 
  <code>AVVideoCompositionCoreAnimationTool</code>, which we also use.</p>
  
  <p>Any solutions?</p>
  
  <p>This happens more often on iPhone 7 devices than iPhone 5s devices.</p>
  
  <p>Code:</p>
  
  <pre><code>fileprivate func playVideo(_ videoURL: String, prompt: String) {
      // Show &lt;playerView&gt;
      playerView.isHidden = false
  
      // Use new video in player
      playerItem = AVPlayerItem(url: URL(fileURLWithPath: videoURL))
  
  
      print("STATUS: \(player.status == AVPlayerStatus.readyToPlay). FRAME: \(playerLayer.frame). MAIN THREAD: \(Thread.isMainThread)")
  
  
      player.replaceCurrentItem(with: playerItem)
  
      // Start playing video
      player.seek(to: kCMTimeZero)
      player.actionAtItemEnd = .none
      player.play()
  }
  </code></pre>