How can I change Video Quality like YouTube?
Currently, I am playing with original quality and I am giving options like 360p, 480p, 720p for changing quality.
How can I change it?
You cant do that simply with AVplayer
. you require diffrent URL for different quality video. When user select other quality, you can switch to that video with replaceCurrentItemWithPlayerItem method fo AVPlayer.
AVPlayerItem *playeriem= [AVPlayerItem playerItemWithURL:urlOfSelectedQualityVideo];
[playeriem seekToTime:player.currentTime];
[player replaceCurrentItemWithPlayerItem:playeriem];
In order to do such things like converting video you should use FFmpeg library. Try to look for some libraries that use ffmpeg on github.
Like this one: https://github.com/iMoreApps/ffmpeg-avplayer-for-ios-tvos
You can't do that with AVPlayer. When just streaming you use M3U index files, TS files containing the video data and just switch streams.
Check out Apple's HLS Documentation and playlist Examples.
You can also create multiple renditions of m3u8 one with lower quality video bitrates say 128k to 650k and another one with 650k + to higher bitrates and use a higher quality stream URL suggested in the answer above
AVPlayerItem *playeriem= [AVPlayerItem playerItemWithURL:urlOfSelectedQualityVideo];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With