Hello there,
in our team we were requested to add the possibility to manually select the video quality. I know that HLS is an adaptive stream and that depending on the network condition it choose the best quality that fits to the current situation.
I also tried some setting with preferredMaximumResolution and preferredPeakBitRate but none of them worked once the user was watching the steam. I also tried something like replacing the currentPlayerItem with the new configuration but anyway this only allowed me to downgrade the quality of the video. When I wanted to set it for example to 4k it did not change to that track event if I set a very high values to both params mentioned above.
My question is if there is any method which would allow me to force certain quality from the manifest file. I already have some kind of extraction which can parse the manifest file and provide me all the available information but I couldn't still figure out how to make the player reproduce specific stream with my desired quality from the available playlist.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Is there any way of discovering the name of the device when the user started to cast to it? The only thing I found was this
let route = AVAudioSession.sharedInstance().currentRoute
for output in route.outputs where output.portType == .airPlay {
infoDict["deviceName"] = output.portName
infoDict["portType"] = output.portType.rawValue
}
but the output.portName returns the portType instead of the portName.
Hello,
I just implemented the feature for downloading the HLS content and the offline playback. However, we offer a custom UI which also provides the possibility to select the subtitles and audios.
My problem is that among this available tracks appears also the audios and subtitles which were not downloaded.
This is the code which I use for downloading the conten:
swift
let urlAsset = AVURLAsset(url: source.url)
var selectedOptions: [AVMediaSelection] = []
if let subtitles = urlAsset.mediaSelectionGroup(forMediaCharacteristic: .legible),
let subtitleOption = subtitles.options.first(where: { $0.extendedLanguageTag == preferences.textLanguage }) {
let mutableMediaSelection = urlAsset.preferredMediaSelection.mutableCopy() as? AVMutableMediaSelection
mutableMediaSelection?.select(subtitleOption, in: subtitles)
selectedOptions.append(mutableMediaSelection!)
}
if var audios = urlAsset.mediaSelectionGroup(forMediaCharacteristic: .audible),
let audioOption = audios.options.first(where: { $0.extendedLanguageTag == preferences.audioLanguage }) {
let mutableMediaSelection = urlAsset.preferredMediaSelection.mutableCopy() as? AVMutableMediaSelection
mutableMediaSelection?.select(audioOption, in: audios)
selectedOptions.append(mutableMediaSelection!)
}
let mediaSelections: AVMediaSelection = selectedOptions.isEmpty ? urlAsset.preferredMediaSelection : selectedOptions.first!
guard let task = assetDownloadURLSession.aggregateAssetDownloadTask(with: urlAsset,
mediaSelections: selectedOptions,
assetTitle: source.metadata.title,
assetArtworkData: nil,
options: nil)
It works fine and downloads what I want.
My problem is that I use this code to retrieve the list of available audios and subtitles for the downloaded asset and it keeps returning me all the audios and subtitles (even the ones I did not download):
swift
let availableSubtitles = playerItem.asset.mediaSelectionGroup(forMediaCharacteristic: .legible)
let availableAudioTracks = playerItem.asset.mediaSelectionGroup(forMediaCharacteristic: .audible)
Is there any way how to filter only the downloaded items? I know that the native AVPlayerViewController does filter them but I can't figure out how.