Expand my Community achievements bar.

Join us January 15th for an AMA with Champion Achaia Walton, who will be talking about her article on Event-Based Reporting and Measuring Content Groups!
SOLVED

Sending Pings Every Second for Pre-Roll Ads in LIVE Content with Adobe Media SDK

Avatar

Level 1

Good afternoon,

 

I would like to send a ping to the Media SDK every time a pre-roll ad is playing. Here’s the flow: I pause the main video, play the pre-roll ads, and send pings every second.

 

According to the document below, I can set the granular value to true, which enables pinging every second, but it only works for VODs. I need this to work for LIVE content as well.

 

Do you know if any limitations prevent this from working with LIVE content? If there’s a recommended workaround, that would also be helpful.


Language: Swift
Xcode 16.1
AEPMedia version: 5.0.1

Thank you in advance!

https://developer.adobe.com/client-sdks/solution/adobe-media-analytics/migration-guide/#granular-ad-...

1 Accepted Solution

Avatar

Correct answer by
Adobe Champion

Hello  @LEANDROOL ,

Sending pings to the Media SDK during a pre-roll ad in a live stream can indeed be challenging, especially since, as you’ve seen, the granularAdTrackingEnabled setting only supports pings every second for VOD, not for live streams. This limitation is due to how the SDK handles live data.


However, there’s a workaround that can get you close to what you need. By setting up a manual ping loop to run every second during the ad, you can achieve a similar effect. In Swift, you can use a repeating timer that triggers the trackEvent method at one-second intervals for the ad’s duration.

Here’s the general idea:

  • Start a Timer: When the pre-roll ad starts, set up a timer to fire each second.
  • Send Events: Each time the timer fires, call your trackEvent method to log each “ping” with Adobe Media Analytics.
  • Stop the Timer: Once the ad ends or is interrupted, stop the timer.

Here’s a basic example in Swift :

 

 

var adPingTimer: Timer?

func startAdPing() {
    adPingTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] _ in
        // Use your custom tracking method or event
        MediaTracker.trackEvent(.adStart) // Adjust the event as needed
    }
}

func stopAdPing() {
    adPingTimer?.invalidate()
    adPingTimer = nil
}

 

 

 

This setup relies on the app’s client-side control to keep timing in sync, so while it might not match native VOD tracking exactly, it’s a reliable workaround that has worked well in similar cases.

Let me know if this helps get things up and running!

 

View solution in original post

2 Replies

Avatar

Correct answer by
Adobe Champion

Hello  @LEANDROOL ,

Sending pings to the Media SDK during a pre-roll ad in a live stream can indeed be challenging, especially since, as you’ve seen, the granularAdTrackingEnabled setting only supports pings every second for VOD, not for live streams. This limitation is due to how the SDK handles live data.


However, there’s a workaround that can get you close to what you need. By setting up a manual ping loop to run every second during the ad, you can achieve a similar effect. In Swift, you can use a repeating timer that triggers the trackEvent method at one-second intervals for the ad’s duration.

Here’s the general idea:

  • Start a Timer: When the pre-roll ad starts, set up a timer to fire each second.
  • Send Events: Each time the timer fires, call your trackEvent method to log each “ping” with Adobe Media Analytics.
  • Stop the Timer: Once the ad ends or is interrupted, stop the timer.

Here’s a basic example in Swift :

 

 

var adPingTimer: Timer?

func startAdPing() {
    adPingTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] _ in
        // Use your custom tracking method or event
        MediaTracker.trackEvent(.adStart) // Adjust the event as needed
    }
}

func stopAdPing() {
    adPingTimer?.invalidate()
    adPingTimer = nil
}

 

 

 

This setup relies on the app’s client-side control to keep timing in sync, so while it might not match native VOD tracking exactly, it’s a reliable workaround that has worked well in similar cases.

Let me know if this helps get things up and running!

 

Avatar

Administrator

@LEANDROOL Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!