3

How can I able to set low or high quality video withstreaming video with AVPlayer?

My code is as follow:

self.videoPlayerItem = [AVPlayerItem playerItemWithURL:videoUrl];

    videoPlayer = [AVPlayer playerWithPlayerItem:self.videoPlayerItem];
    videoPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
    CGRect frame = self.frame;
    videoPlayerLayer = [AVPlayerLayer layer];
    [videoPlayerLayer setPlayer:videoPlayer];
    [videoPlayerLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];

Thanks for your time

user2526811
  • 1,233
  • 4
  • 20
  • 54
  • I guess this is only one possible solution to switch URLs: http://stackoverflow.com/questions/24790126/avplayer-switching-stream-quality-while-playing – Injectios Nov 08 '16 at 10:23
  • @Injectios, I don't have separate URL for low quality I have just one URL. – user2526811 Nov 08 '16 at 10:30

1 Answers1

1

You can lower the video quality/bitrate by setting AVPlayerItem's preferredPeakBitRate.

Re-set it to zero to get the usual "highest quality/bitrate supported by your connection" behaviour.

N.B. A bitrate less than or equal to preferredPeakBitRate must be available for this to work, e.g. in an HLS stream.

Rhythmic Fistman
  • 34,352
  • 5
  • 87
  • 159