如何自动重播视频。例如,当视频完成后,我想再次自动播放视频。
这是我的代码:
videoURL = URL(string: video.url!)!
self.player = AVPlayer(url: videoURL!)
let videoLayer = AVPlayerLayer(player: self.player)
videoLayer.frame = view.bounds
videoLayer.videoGravity = .resizeAspectFill
self.videoSnap.layer.addSublayer(videoLayer)
let asset = AVURLAsset.init(url: videoURL!)
let duration = asset.duration.seconds
print(duration)
self.player.play()