【问题标题】:WARNING: AVF context unavailable for +[MRAVOutputContext sharedAudioPresentationContext]_block_invoke Swift警告:+[MRAVOutputContext sharedAudioPresentationContext]_block_invoke Swift 的 AVF 上下文不可用
【发布时间】:2019-08-17 14:10:56
【问题描述】:

您好,我正在尝试使用以下方法在收藏视图单元格中播放视频:Link

当我运行我的应用程序视频播放成功。 再次完成视频后,我们按下开始按钮,它崩溃了。并显示以下错误。

WF: _WebFilterIsActive returning: NO

警告:AVF 上下文无法用于 +[MRAVOutputContext sharedAudioPresentationContext]_block_invoke

我编写以下代码。

  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
            if collectionView == self.video_collectionview
            { 
                // For videoCollectionView
                let videocell = collectionView.dequeueReusableCell(withReuseIdentifier: "VideoCollectionViewCell", for: indexPath)as! VideoCollectionViewCell
                 videocell.videotitle.text = videotitle[indexPath.row]
                videocell.videotime.text = videotime[indexPath.row]
                let myVideoURL = videourls[indexPath.row]
                videocell.videoview.loadVideoURL(myVideoURL as URL)
               // videocell.videoview.layer.cornerRadius = 15

                return videocell
            }
        }

  func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        if collectionView == video_collectionview
         {  
            let videocell = collectionView.dequeueReusableCell(withReuseIdentifier: "VideoCollectionViewCell", for: indexPath)as! VideoCollectionViewCell
            let myVideoURL = videourls[indexPath.row]
            videocell.videoview.loadVideoURL(myVideoURL as URL)
        }
    }

【问题讨论】:

    标签: ios swift video youtube


    【解决方案1】:

    需要安装 XCDYouTubeKit pod 文件。

    在 select row 方法中是否使用 videoid 参数调用了此函数。

    func playVideo(videoid:String) {
    
            let playerViewController = AVPlayerViewController()
            self.present(playerViewController, animated: true, completion: nil)
    
            XCDYouTubeClient.default().getVideoWithIdentifier(videoid) { (video: XCDYouTubeVideo?, error: Error?) in
                if let streamURL = video?.streamURLs[XCDYouTubeVideoQuality.HD720.rawValue] {
                    playerViewController.player = AVPlayer(url: streamURL)
                    playerViewController.player?.play()
                } else {
                    self.dismiss(animated: true, completion: nil)
                }
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-18
      • 2023-03-30
      • 1970-01-01
      • 2013-11-15
      • 2012-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多