文件的url路径是//// var / mobile / Containers / Data / Application / <> / Documents / IMG_2792.MP4
func playVideo(videoURL: String){
if let video_URL = documentsUrl.appendingPathComponent(videoURL) as? URL{
let player = AVPlayer(url: video_URL)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = self.vid_player!.bounds
self.vid_player?.layer.addSublayer(playerLayer)
player.play()
}
}
您是否尝试将视频文件放入捆绑资源中并从中获取视频?
尝试一下:使用fileURLWithPath