I'm using AVPlayer
to play youtube videos, for each youtube video id I retrieve a couple of stream urls in different qualities.
I want to play a particular stream quality according to the network state. For example if user is on 3G I want to play the lowest quality URL but if user moves to wifi I want to seamlessly switch to the better quality stream.
This is nothing new, youtube is doing that in their app and many others.
So I wonder what is the best way to do this kind of switching with AVPlayer
, I don't want the user to notice the switching as possible, without pausing the video playback or buffering.
Any advices?
I'm not sure if this kind of functionality is supported on the youtube servers or if I need to do it on client side.