【发布时间】:2020-08-15 12:30:42
【问题描述】:
我正在尝试使用此处提到的苹果文档 - https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/MediaPlaybackGuide/Contents/Resources/en.lproj/HTTPLiveStreaming/HTTPLiveStreaming.html
将 HLS 流下载到我的 iPhone 上即使是 2 分钟的小视频也需要大约 3-4 分钟才能下载,我的互联网连接速度很快,所以这不是问题。
我想知道在下载时是否需要下载或指定任何特定的流?我的 m3u8 中的流是 320p、720p、1080p。是不是全部都下载了,所以要花那么多时间?
这就是我设置代码以下载 hls 的方式 -
let urlConfiguration = URLSessionConfiguration.background(withIdentifier: downloadIdentifier)
// Create a new AVAssetDownloadURLSession with background configuration, delegate, and queue
let assetDownloadSession = AVAssetDownloadURLSession(configuration: urlConfiguration,
assetDownloadDelegate: self,
delegateQueue: OperationQueue.main)
let asset = AVURLAsset(url: URL(string: assetUrl)!)
// Create new AVAssetDownloadTask for the desired asset
let avAssetDownloadTask = assetDownloadSession?.makeAssetDownloadTask(asset: asset,
assetTitle: title,
assetArtworkData: nil,
options: nil)
// Start task and begin download
avAssetDownloadTask?.resume()
【问题讨论】:
标签: ios swift http-live-streaming m3u8 urlsession