swift AVPlayerViewController视频播放

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视频播放)