Hi
I'm using the iOS11 `AVAggregateAssetDownloadTask` API to download an HLS AVAsset with differents subtitles.
Here's the code to create a download task:
downloadTask = self.session.aggregateAssetDownloadTask(with: urlAsset,
mediaSelections: mediaSelections,
assetTitle: "my downloads",
assetArtworkData: nil,
options: [AVAssetDownloadTaskMinimumRequiredMediaBitrateKey: 2000000])
To create the media selection array, I'm duplicating the urlAsset's `preferredMediaSelection` and select the subtitles I want to download.
Here's the code:
let preferredMediaSelection = asset.urlAsset.preferredMediaSelection
var mediaSelections: [AVMediaSelection] = []
if let group = asset.urlAsset.mediaSelectionGroup(forMediaCharacteristic: .legible) {
group.options.forEach { option in
guard let mediaSelection = preferredMediaSelection.mutableCopy() as? AVMutableMediaSelection else { return }
mediaSelection.select(option, in: group)
mediaSelections.append(mediaSelection)
}
}
But the session download the whole video for each media selections, instead of downloading the video once, then the french subs, then the english ones, etc...
How to download multiple subtitles (or audio) and the video once?
Thanks