播放本地video(swift)

前端之家收集整理的这篇文章主要介绍了播放本地video(swift)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

播放本地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()
}
原文链接:https://www.f2er.com/swift/324652.html

猜你在找的Swift相关文章