title: How to freeze the view until a certain value is true?
body: <p>I have an app where a user can hold a button to take a video. However when they do so and then let go, the new layer, with the video playback, does not apear instantly. Instead there is a very short delay where you can see the camera still showing what the camera sees after the user has let go of the button. When the delay finishes the video instantly shows up and starts playing. How can I instead make the first frame of the video apear before its ready to play so that its there just for a moment before it starts playing? See snapchats video taking functionality to see what I mean</p>
  
  <p>I believ that the way to fix this is to somhow add teh sublayer with teh first frame instantly, however I have not been able to find our how exactly i coudl do this </p>
  
  <p><strong>Bellow is my code:</strong>    </p>
  
  <pre><code>        func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) {
  
              if (error != nil) {
                  print("Error recording movie11: \(error!.localizedDescription)")
              } else {
                  newViewVideoPlayback()
  
                  switchIcon.isHidden = true
                  switchWhiteUI.isHidden = true
                  switchCamButton.isHidden = true
                  camWhiteLine.isHidden = true
  
                  let videoRecorded = outputURL! as URL
  
                  playerQueue = AVQueuePlayer(playerItem: AVPlayerItem(url: videoRecorded))
                  self.playerQueue?.play()
  
                  playerLayer = AVPlayerLayer(player: playerQueue)
                  playerLayer.frame = (camPreview?.bounds)!
                  playerLayer?.layoutIfNeeded()
                  playerLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill
  
                  camPreview?.layer.insertSublayer(playerLayer, above: previewLayer)
  
                  playerItem1 = AVPlayerItem(url: videoRecorded)
  
                  playerLooper = AVPlayerLooper(player: playerQueue, templateItem: playerItem1)
  
                  if !captureSession.isRunning {
                      DispatchQueue.global(qos: .background).async {
                          self.startRunningCaptureSession()
                      }
                  }
              }
          }
  
  
  //Bellow is teh long tap method 
          @objc func longTap(_ sender: UIGestureRecognizer) {
          print("Long tap")
  
          self.numForVid = numForVid + 1 //shud change this number stuff
          print("\(numForVid)")
  
          cameraButton.isHidden = true
  
          if sender.state == .ended {
              print("UIGestureRecognizerStateEnded")
              //stopSession()
              stopRecording()
          }
          else if sender.state == .began {
              print("UIGestureRecognizerStateBegan.")
              //Do Whatever You want on Began of Gesture
              startCapture()
          }
      }
  </code></pre>