AVPlayerViewController doesn't play local videos

前端 未结 1 1164
梦谈多话
梦谈多话 2021-01-29 05:16

I have added a DemoVideo.mp4 in my project and added it to copy resource file. But when i run the app it doesn\'t play my video. Here is my method.

private func          


        
1条回答
  •  深忆病人
    2021-01-29 05:49

     let path : String = Bundle.main.path(forResource: "charlie", ofType: "mp4")!
     let movieurl : URL = URL(fileURLWithPath: path)
     let movie : AVPlayerViewController = AVPlayerViewController()
     movie.view.frame = self.view.bounds
    
     let player : AVPlayer = AVPlayer(url: movieurl)
     movie.player = player
    
     self.view.addSubview(movie.view)
     player.play()
    

    0 讨论(0)
提交回复
热议问题