gpt4 book ai didi

ios - 播放直播新闻 - swift 3

转载 作者:行者123 更新时间:2023-11-30 12:56:01 25 4
gpt4 key购买 nike

我想在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()
})
})

最佳答案

这里不需要使用AsyncDisplayKit。您可以使用原生 AVPlayer 或 AVPlayerViewController 流视频。

了解更多详情:How to play video with AVPlayerViewController (AVKit) in Swift

关于ios - 播放直播新闻 - swift 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40384457/

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