How can I schedule ads in an HLS stream?
Generated on 7/31/2024
1 search
To schedule ads in an HLS stream, you can use HLS interstitials. Here’s a brief overview of how you can do it:
-
Specify the Start Date: You can schedule an interstitial (ad) at a specific point in your content by specifying the start date in the content's program date time. For example, to schedule an ad 5 seconds into the content, you would set the start date to 5 seconds in the program date time. The primary content will play up to 5 seconds, then the interstitial URL will play, and finally, playback will resume with the primary content after the interstitial completes.
-
Integrated Timeline API: Apple has introduced a new AV Foundation API called Integrated Timeline, which provides a data model for timing and sequence of playback of content with interstitials. This API allows you to build new UI experiences and enable seamless navigation in and out of interstitials.
-
Signaling Interstitials: You can signal interstitials on the timeline using the new HLS syntax. For example, you can mark interstitials as points or ranges on the transport bar. When the playback reaches these points, the playhead stops, plays the interstitial, and then resumes the primary content.
-
SharePlay Support: You can also enable SharePlay support for interstitial assets by marking them as not variable in the API.
For a detailed explanation and examples, you can refer to the session Enhance ad experiences with HLS interstitials from WWDC 2024.
Relevant Sessions
If you need more specific details or examples, feel free to ask!
Discover media performance metrics in AVFoundation
Discover how you can monitor, analyze, and improve user experience with the new media performance APIs. Explore how to monitor AVPlayer performance for HLS assets using different AVMetricEvents, and learn how to use these metrics to understand and triage player performance issues.
Enhance ad experiences with HLS interstitials
Explore how HLS Interstitials can help you seamlessly insert advertisements into your HLS content. We’ll also show you how to use integrated timeline to tune your UI experience and build SharePlay for interstitials.