Mid-Roll Video Ads integration in AVPlayer

Hi, I have to integrate Mid-Roll video Ads in AVPlayer with custom UI.
I have all the information of videos ads line video ads urls and time when to play the ads etc.
What is the best way to integrate these ads in AVPlayer ?

Hi @taimoorsuleman, welcome to the community! I would look into AVQueuePlayer which would allow you to create a queue of videos since you already have the ad urls. With the urls you could create an array and then possibly use the insert(_:at:) method to go through the videos.


Hi @gdelarosa, thanks for your response. AVQueuePlayer will add videos sequential order, but i want to show ads in mid of videos like facebook and youtube are doing.

Hi @taimoorsuleman You can simply observe the playback time for which you want to inject your mid-roll video ads, pause the video currently playing at a certain time interval, then overlay the UI with another player for the mid-roll ads, and once finished, discard the overlay and resume playing the original video.

@halkibsi yes i can do like this… but i need generic solution just like ExoPlayer doing in android.
ExoPlayer Supports videos ads it just need ads file and thats it.

This topic was automatically closed after 166 days. New replies are no longer allowed.