简体   繁体   中英

Switching bitrates of HLS stream in ios AVPlayer

I need to switch specific bitrate in HLS stream. To set the bitrate I am using the below property during initialisation.

let playerItem = AVPlayerItem(url: streamUrl)
playerItem.preferredPeakBitRate = 240
player = AVPlayer(playerItem: playerItem)

But during the playback, if I am trying to set another bitrate using below code

self.playerController?.player?.currentItem?.preferredPeakBitRate = 1500

The stream is not switching to 720p.

Stream contains both the bitrates and works fine with whatever bitrate I provide during initialisation.

If I'm not mistaken, the preferredPeakBitRate is measured in bits per second and not resolution. After reviewing an Apple Developer video it seems that it's actually kilobits per second but the documentation states otherwise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM