swift AVPlayerViewController视频播放
作者:
紫云夕月 | 来源:发表于
2021-11-19 10:16 被阅读0次import UIKit
import AVKit
class NetPlayerController: BaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
//网络视频地址
let netVideoPath = "https://video_shejigao.redocn.com/video/201806/20180606/Redcon_2018060510032115552514759.mp4"
let netVideoUrl = NSURL(string: netVideoPath)! as URL
let player = AVPlayer(url: netVideoUrl)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
//添加view播放的模式
self.addChild(playerViewController)
self.view.addSubview(playerViewController.view)
playerViewController.view.snp.makeConstraints { (make) in
make.top.equalTo(self.view)
make.left.equalTo(self.view)
make.right.equalTo(self.view)
make.bottom.equalTo(self.view)
}
}
}
本文标题:swift AVPlayerViewController视频播放
本文链接:https://www.haomeiwen.com/subject/knustrtx.html
网友评论