美文网首页
Lesson3 - video

Lesson3 - video

作者: 茗涙 | 来源:发表于2018-03-19 11:52 被阅读7次

效果图

QQ20180319-115036.gif

项目代码地址

添加播放器步骤

//定义一个视频文件路径
        let filePath = Bundle.main.path(forResource: "video", ofType: "mp4")
        let videoURL = URL(fileURLWithPath: filePath!)
        //定义一个视频播放器,通过本地文件路径初始化
        playerView = AVPlayer(url: videoURL)
        //设置大小和位置(全屏)
        let playerLayer = AVPlayerLayer(player: playerView)
        playerLayer.frame = self.view.bounds
        //添加到界面上
//        self.view.layer.addSublayer(playerLayer)

        playViewController.player = playerView
        self.present(playViewController, animated: true) {
            self.playViewController.player?.play()
        }

相关文章

网友评论

      本文标题:Lesson3 - video

      本文链接:https://www.haomeiwen.com/subject/hnhrqftx.html