zoukankan      html  css  js  c++  java
  • swift UIview上添加视频播放

    1.

        /// 是否显示过广告
        private lazy var isLoadAV = false
        /// 15秒宣传视频
        private var play: AVPlayer?
        
        /// 宣传视频背景
        private lazy var logoView : UIView = {
            let v = JYUIModel.createView()
            v.backgroundColor = UIColor.orange
            return v
        }()
        

    2.

        /// 添加宣传视频
        private func addPromotionalVideo(){
            if let filePath = Bundle.main.path(forResource: "测试视频", ofType: "mp4")  {
                let videoUrl = URL(fileURLWithPath: filePath)
                let playerItem = AVPlayerItem(url: videoUrl)
                play = AVPlayer(playerItem: playerItem)
                let player = AVPlayerLayer(player: play)
                if #available(iOS 11.0, *) {
                    player.frame = CGRect(x: 0, y: 0,  JYScreenWidth, height: JYScreenHeight - 183 - view.safeAreaInsets.bottom)
                } else {
                    player.frame = CGRect(x: 0, y: 0,  JYScreenWidth, height: JYScreenHeight - 183)
                }
                logoView.layer.addSublayer(player)
                play?.play()
                isLoadAV = true
            }
        }

    3.

        override func viewDidLayoutSubviews() {
            super.viewDidLayoutSubviews()
            if isLoadAV == false{
                addPromotionalVideo()
            }
        }
  • 相关阅读:
    dnsever 邮件记录
    用于显示上个月和下个月_PHP
    JSON学习
    ASP生成新会员编号
    godaddy_关于产品退款
    Switch Case语句中多个值匹配同一个代码块的写法
    网闸与防火墙的比较
    bench.sh 跑分测速
    Kcptun加速SS
    linux 安全狗
  • 原文地址:https://www.cnblogs.com/qingzZ/p/10592144.html
Copyright © 2011-2022 走看看