Sending Pings Every Second for Pre-Roll Ads in LIVE Content with Adobe Media SDK | Community
Skip to main content
November 11, 2024
Solved

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

  • November 11, 2024
  • 1 reply
  • 681 views

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-tracking

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Bhoomika_S

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!

 

1 reply

Bhoomika_S
Adobe Champion
Bhoomika_SAdobe ChampionAccepted solution
Adobe Champion
November 11, 2024

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!

 

Jagpreet_Singh_
Community Manager
Community Manager
November 14, 2024

@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!