قالب وردپرس درنا توس
Home / IOS Development / ios – The video is not displayed correctly on the preview control

ios – The video is not displayed correctly on the preview control



I currently have 2 VC one for handling the video recording and the other for previewing the video on another VC. So when I start holding a button on the screen, it will start recording, but instead it will do nothing for a few seconds and then only segues to a blank controller that should have contained the recorded video. I should note that this code is a complete project that I tried to add to an empty Xcode, so I think it's an integration problem. So the question is what goes wrong? Why does this happen and how can I fix it? Suggestions for more information to give you welcome

A link to the entire project is here.

Bellow finds VideoPlayback VC:

class VideoPlayback: UIViewController {

  // receives URL video value from VideoViewController
was videoURL: URL!

// place where video is displayed
@IBOutlet weak was video view: UIView!

let offPlayer = AVPlayer ()

private var playerQueue: AVQueuePlayer!
private was playerItem1
: AVPlayerItem! private was playerLooper: AVPlayerLooper! private were playerLayer: AVPlayerLayer! override func viewDidLoad () { super.viewDidLoad () print (offPlayer, "offPlayer") print ("videoURL", videoURL) playerItem1 = AVPlayerItem (URL: videoURL as URL) print (playerItem1, "player item 1") playerQueue = AVQueuePlayer (playerItem: playerItem1) print (player queue, player queue) playerLayer = AVPlayerLayer (player: playerQueue) print (playerLayer, "playerLayer") playerLooper = AVPlayerLooper (player: playerQueue, templateItem: playerItem1) print (player looper, player looper) playerLayer.frame = view.bounds playerLayer.videoGravity = AVLayerVideoGravity.resizeAspectFill videoView.layer.insertSublayer (playerLayer, at: 0) view.layoutIfNeeded () self.playerQueue? Protect your Nintendo DS () }

}

Bellow finds the method that I think has something to do with the problem:

  func fileOutput (_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection] error: Error?) {
print ("START end")


if (wrong! = null) {
print ("Incorrect movie recording:  (error! .ocalizedDescription)")
} other {

print ("start second end")

leave videoRecorded = outputURL! as URL

performSegue (withIdentifier: "showVideo", sender: videoRecorded)
print ("start second end")

}
}


Source link