How can i change AVPlayer Video Quality while playing

故事扮演 提交于 2020-01-01 06:56:29

问题


I used this library for playing video from URL, and I am able to play video.

Now I want to change the currently playing video quality like (low, medium, high).

Library uses AVPlayer and how can i change quality with AVPlayer?

I listen about preferred​Peak​Bit​Rate but I have no idea about it.

Please help me how can i do that?


回答1:


You cannot set video quality directly on the AVPlayer, however, you can do this by accessing videoComposition property on AVPlayerItem which is then supplied to AVPlayer (via for example replaceCurrentItem: method or on AVPlayer initialization). So:

  1. Create or get you AVPlayerItem's AVVideoComposition instance, and set it's frameDuration, renderSize and renderScale properties. Take a look in docs for more info.
  2. Set it to your "movie" videoComposition property, AVPlayerItem instance (again, look in docs for details).
  3. Play that in your player.

If you want to do this on the fly while playing movie, adjustments of time for player item should be done I guess.



来源:https://stackoverflow.com/questions/43095311/how-can-i-change-avplayer-video-quality-while-playing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!