AVPlayerInterstitialEvent Does Not Play For Live Playlist

I want to use AVPlayerInterstitialEvent to schedule a priority alert during Live content.

I set the interstitial event to the events property of AVPlayerInterstitialEventController but the primary content never switches to the event at the specified Date.

I am able to successfully set an event when the primary content is VOD and the event plays as expected.

I have confirmed:

  • The HLS playlist for the primary asset contains EXT-X-PROGRAM-DATE-TIME tag so the Event can be mapped into the primaryItem timeline.
  • The date property of the AVPlayerInterstitialEvent is sufficiently ahead (> 60 seconds) of the current playback time.
  • Using Charles Proxy, I do not see any player networking for the Event's URL.

Here is a code snippet to show how the event is created and scheduled:

let currentItem = player.currentItem

let event = AVPlayerInterstitialEvent(primaryItem: currentItem,
\identifier: evt.id,
date: evt.date,
templateItems: [AVPlayerItem(url: evt.url)],
restrictions: [],
resumptionOffset: CMTime.indefinite)

event.willPlayOnce = true
eventController.events = [event]

I have also attached example HLS for the Live content and Event.

Any help is appreciated.

After debugging this issue further, I have found that I can insert my Interstitial Event into a Live asset but only if it's scheduled with Join C ue. With this preferred position the event plays through and switches back to the live stream as expected.

However, with the C ue Position is .none, I cannot get the Interstitial Event to play when its scheduled ahead of the Content's Live Edge.

I've attached a screen shot of my player's transport bar. Setting the event has the affect of adding the "ad pod" to the transport bar which comes into view and moves towards the live point as the content progresses. But AVFoundation never switches to the Interstitial Event.

I am using a SwiftUI VideoPlayer for my UI and controls.

Another interesting thing I notice is anywhere from 5-10 seconds before my Event is scheduled to play, I see this console message:

[MADService] Client XPC connection invalidated

I am unable to find more information on this but it is consistent and perhaps related to my issue.

One more update.

I was able to get an AVPlayerInterstitialEvent to play on a LIVE asset but I needed to manipulate the HLS media playlist to do so. I used a Charles Proxy re-write and added a Date range tag to the media playlist, e.g.

#EXT-X-DATERANGE:ID="ad1",CLASS="com.apple.hls.interstitial",START-DATE="2023-04-25T19:13:00.000Z",DURATION=72.0,X-ASSET-URI="https://myEvent.m3u8",X-RESTRICT="SKIP,JUMP"

Here, I observed the same behavior as before where the ad pod was rendered and moved towards the live edge of my stream. This time the Player switched to the interstitial and I was able to watch the event and see it switch back.

My remaining Question is why doesn't this work with client-side scheduling? HLS playlist manipulation is somewhat tedious.

AVPlayerInterstitialEvent Does Not Play For Live Playlist
 
 
Q