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:

  1. 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.

  2. 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.

  3. 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.

  4. 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!