gpt4 book ai didi

ios - 从容器中播放视频

转载 作者:行者123 更新时间:2023-11-29 05:33:17 25 4
gpt4 key购买 nike

我正在尝试播放 URL 中的视频。我正在传递视频 URL,但现在遇到的问题是我将视频容器传递到 UIView 中,因为我只想让它在容器中播放。现在视频无法播放。

 func setup() {
playervc.view.frame = vidContainer.bounds
self.addChild(playervc)
vidContainer.addSubview(playervc.view)
playervc.didMove(toParent: self)
playervc.player?.play()
}


extension ProfileVC: AVPlayerViewControllerDelegate {
private func videoPlayer(url: String) {
let videoURL = URL(string: url)
player = AVPlayer(url: videoURL!)
playervc = AVPlayerViewController()
playervc.delegate = self
playervc.player = player
}
}

最佳答案

playervc.videoPlayer(url: "Some Video URL")

在setup()中调用该函数

func setup(){

//This should be call in this function
playervc.videoPlayer(url: "Some Video URL")

playervc.view.frame = vidContainer.bounds
self.addChild(playervc)
vidContainer.addSubview(playervc.view)
playervc.didMove(toParent: self)
playervc.player?.play()

}

关于ios - 从容器中播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57325259/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com