7

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?

Amir Shabani
  • 3,857
  • 6
  • 30
  • 67
Kuldeep
  • 4,466
  • 8
  • 32
  • 59

3 Answers3

7

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];
PlusInfosys
  • 3,416
  • 1
  • 19
  • 33
3

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.

Oleh Zayats
  • 2,423
  • 1
  • 16
  • 26
2

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];