Hello @Chris_Ching
I am trying to make my video to loop. This is from your “Custom Login” lesson. Here is the code.Any suggestions:
func setUpVideo() {
// Get path to the rescource in the bundle
let bundlePath = Bundle.main.path(forResource: "loginbg", ofType: "mov")
guard bundlePath != nil else {
return
}
// Create URL from the path
let url = URL(fileURLWithPath: bundlePath!)
// Create the video player item
let item = AVPlayerItem(url: url)
// Create the player
videoPlayer = AVQueuePlayer(playerItem: item)
// Create the layer
videoPlayerLayer = AVPlayerLayer(player: videoPlayer!)
// Adjust the size and frame
videoPlayerLayer?.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width+85, height: self.view.frame.size.height)
view.layer.insertSublayer(videoPlayerLayer!, at: 0)
// Add it to the view and play it
videoPlayer?.playImmediately(atRate: 0.5)