ВНИМАНИЕ: контекст AVF недоступен для + [MRAVOutputContext sharedAudioPresentationContext] _block_invoke Swift - PullRequest
0 голосов
/ 27 марта 2019

Привет. Я пытаюсь воспроизвести видео в ячейках представления коллекции, используя: Ссылка

Когда я запускаю приложение, видео воспроизводится успешно. После повторного завершения видео мы снова нажимаем на кнопку «Пуск», он вылетает и показывает следующие ошибки.

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)
        }
    }

1 Ответ

0 голосов
/ 27 марта 2019

Необходимо установить файл модуля XCDYouTubeKit.

В выбранном методе строки вызовите эту функцию с параметром 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)
            }
        }
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...