播放本地video(swift)
- 1.定义AVPlayer
var playViewController = AVPlayerViewController()
var playerView = AVPlayer()
- 2.初始化AVPlayer
let path = NSBundle.mainBundle().pathForResource("player",ofType: "mp4")
playerView = AVPlayer(URL: NSURL(fileURLWithPath: path!))
playViewController.player = playerView
self.presentViewController(playViewController,animated: true) {
self.playViewController.player?.play()
}