我想在ios中播放直播/流媒体视频。我正在尝试使用AsyncDisplayKit,但无法播放视频。有没有这方面的图书馆?
DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async(execute: {
if self.mainNode == nil {
self.mainNode = ASDisplayNode()
self.videoNode = ASVideoNode()
self.videoNode!.frame = CGRect(x: 0.0, y: 0.0, width: self.bounds.width, height: self.bounds.height)
self.videoNode!.gravity = AVLayerVideoGravityResizeAspectFill
self.videoNode!.shouldAutoplay = true
self.videoNode!.shouldAutorepeat = false
self.videoNode!.muted = false
self.videoNode.delegate = self
self.videoNode.isUserInteractionEnabled = true
self.videoNode!.placeholderEnabled = true
DispatchQueue.main.async(execute: {
self.mainNode!.addSubnode(self.videoNode!)
self.addSubview(self.mainNode!.view)
})
}
self.videoNode?.asset = AVAsset(url: self.url)
DispatchQueue.main.async(execute: {
self.videoNode?.placeholderImage()
})
})发布于 2016-11-03 00:23:06
这里不需要使用AsyncDisplayKit。您可以使用原生AVPlayer或AVPlayerViewController流视频。
有关更多细节,请访问:How to play video with AVPlayerViewController (AVKit) in Swift
https://stackoverflow.com/questions/40384457
复制相似问题