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!
Solved! Go to Solution.
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:
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!
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:
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!
@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!