问题描述
我使用此库来播放URL
中的视频,并且能够播放视频
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).
图书馆使用AVPlayer,如何使用AVPlayer改变质量?
Library uses AVPlayer and how can i change quality with AVPlayer?
我听过首选峰值速率,但我对此一无所知.
I listen about preferredPeakBitRate but I have no idea about it.
请帮助我该怎么做?
推荐答案
您不能直接在AVPlayer
上设置视频质量,但是,可以通过访问AVPlayerItem
上的videoComposition
属性来实现此目的,然后将其提供给AVPlayer
(例如,通过replaceCurrentItem:
方法或在AVPlayer初始化时).所以:
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:
- 创建或获取
AVPlayerItem
的AVVideoComposition
实例,并将其设置为frameDuration
,renderSize
和renderScale
属性.在文档中查看以获取更多信息. - 将其设置为您的电影"
videoComposition
属性,AVPlayerItem
实例(同样,请查看 docs 了解详情). - 在播放器中播放.
- Create or get you
AVPlayerItem
'sAVVideoComposition
instance, and set it'sframeDuration
,renderSize
andrenderScale
properties. Take a look in docs for more info. - Set it to your "movie"
videoComposition
property,AVPlayerItem
instance (again, look in docs for details). - 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.
这篇关于播放时如何更改AVPlayer视频质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!