Playing mid-roll audio ads via IMA SDK in iOS

896 views
Skip to first unread message

Lech Pawlak

unread,
Feb 14, 2020, 8:22:10 AM2/14/20
to Interactive Media Ads SDK
Hey 

I want to build a mechanism for playing audio ads (VAST) in my playback app. I use the IMA SDK's player (passing the ad tag as with video ads). The flow looks like this:
1. My apps plays music using its player (AVPlayer)
2. At the appropriate moment (when I want to present an ad to a user) I pause the player, and use IMA SDK to request and play the audio ad
3. I resume my apps's player

As I have to play the jingle sounds before and after any ad, I created an instance of AVQueuePlayer (this is not the one that plays music in my app -- this one is only for playing jingle sounds and I also pass it to IMAAVPlayerContentPlayhead) with two items-jingle sounds-inserted. I observe when the first one finishes (then I'm ready to play the ad). 

The problem is that when I call contentComplete() (after the pre jingle sound finished playing) nothing happens - the sdk doesn't load and play any ad.
Should I pause the player inside the contentDidFinishPlaying(_ notification:) method and call the start() method on adsManager object instead? Is this the correct approach? I will only add that I would like to play jingle sounds only when the loader successfully loads all the ad before.

IMA SDK

unread,
Feb 14, 2020, 3:58:55 PM2/14/20
to lechroch...@gmail.com, ima...@googlegroups.com
Hi Lech,

Thank you for reaching out to us. We were not able to download the sample app you shared, the download status gets stuck at 20% every time (see screenshot attached). The contentDidFinishPlaying method notifies the IMA SDK that the video content is done playing so the SDK can request and display a Post-Roll. If you have a Post-Roll in your ad response it should be displayed automatically. Do you have a Post-Roll in your VMAP ad? Can you share the ad tag you were using when you encountered this issue?

Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5001UV0o2W:ref
download-stuck.png

Lech Pawlak

unread,
Feb 16, 2020, 4:34:49 PM2/16/20
to Interactive Media Ads SDK
Hello,


Best regards,
Tomek

IMA SDK

unread,
Feb 17, 2020, 2:41:42 AM2/17/20
to lechroch...@gmail.com, ima...@googlegroups.com
Hi Tomek,

Thank you for providing the project file. However, I'm getting a post_advert_audio.mp3: No such file or directory (in target 'MidrollAudioAdsExample' from project 'MidrollAudioAdsExample') error on my end. It seems that you didn't upload the necessary file (mp3) for the project to run. With this, could you please check the project and include the file that is needed to the project? Rest assured that the shared file (e.g assets) will be not shared externally and for investigative purposes only.

Regards,
Teejay Pimentel

Lech Pawlak

unread,
Feb 24, 2020, 4:27:47 AM2/24/20
to Interactive Media Ads SDK
Hi,

here is the fixed project with all the needed resources https://www.dropbox.com/sh/fzoovwd3gnz8665/AAAgejJxhsIH_QUYd67SOhifa?dl=0 

IMA SDK

unread,
Feb 24, 2020, 7:56:42 AM2/24/20
to lechroch...@gmail.com, ima...@googlegroups.com

Hi Lech,

 

Thanks for getting back to us and for sharing the file. I was able to download the project file and build the app on my end (please see attached screenshot). However, upon testing the app, the pre jingle sound doesn't play and it appeared to be nothing happens after clicking the play button.

 

For us to investigate further, would you be able to recreate your implementation with our basic sample app with minimal code modifications? This will help us to compare your implementation against our sample app and to check where the issue is occurring.

 

Also, please note that calling contentComplete() will signal the SDK to play post-rolls, if any are scheduled. With this, could you confirm if your ad tag does contain post-roll ads?

 

Regards,

Sherwin Diesta

testAppBuild.jpg

Lech Pawlak

unread,
Feb 24, 2020, 10:32:52 AM2/24/20
to Interactive Media Ads SDK
Hi,

let's break down this problem into small issues.

Firstly, I would like to show you the problem I have when passing a "fake" UIView instance to IMAAdDisplayContainer's constructor (I'm doing it because I use the IMA SDK only to play audio ads; also my class that is responsible for playing these ads does not inherit from UIViewController). What I changed in the code from your sample project is:
-- replaced your sample ad tag with mine
-- added an instance of UIView (called fakeView) that I pass later to IMAAdDisplayContainer's constructor

I noticed that after these modifications the problem with the events inside the adsManager(_ adsManager:, didReceive event:) method occurred -- some events are much delayed. When I validate my tags via https://developers.google.com/interactive-media-ads/docs/sdks/html5/vastinspector?hl=pl all seems to be fine.

Here is the link to the modified sample project: https://www.dropbox.com/sh/c1hzb3rijhosjmu/AAAxxh4t8RHbLxDnkmUUa2Iha?dl=0

Tomek

IMA SDK

unread,
Feb 24, 2020, 3:20:53 PM2/24/20
to lechroch...@gmail.com, ima...@googlegroups.com
Hi Lech,

I was able to reproduce the behavior that you encountered with your implementation, when I run your demo app with the fakeView,  some ad events are delayed. However, the issue is not with the IMA SDK, as per the documentation of the IMAAdDisplayContainer the a video view must be passed in its construction during its initialization. The fakeview is breaking the SDK AdManager's functioning, we would recommend you to use the video view instead of the fake view. You can try to hide the video view from the screen during the ad playback if it the behavior you're looking for.

Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5001UV0o2W:ref

IMA SDK

unread,
Feb 24, 2020, 5:51:14 PM2/24/20
to lechroch...@gmail.com, ima...@googlegroups.com
Hi Lech,

I was able to reproduce the behavior that you encountered with your implementation, when I run your demo app with the fakeView,  some ad events are delayed. However, the issue is not with the IMA SDK, as per the documentation of the IMAAdDisplayContainer the a video view must be passed in its construction during its initialization. The fakeview is breaking the SDK AdManager's functioning, we would recommend you to use the video view instead of the fake view. You can try to hide the video view from the screen during the ad playback if it the behavior you're looking for.
If you want to integrate Audio ad playback in your app, we would recommend you to follow the Background Audio Ad Playback implementation guide.

Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5001UV0o2W:ref

Lech Pawlak

unread,
Feb 25, 2020, 5:47:37 AM2/25/20
to Interactive Media Ads SDK
Thank you for your explanation, now I understand. :)

Lech Pawlak

unread,
Mar 2, 2020, 5:59:02 AM3/2/20
to Interactive Media Ads SDK
Hi,

is the ALL_ADS_COMPLETED event always sent by the sdk after the adsManager(_ adsManager: IMAAdsManager!, didReceive error: IMAAdError!) methods is invoked (in case of error)?

IMA SDK

unread,
Mar 2, 2020, 3:41:31 PM3/2/20
to lechroch...@gmail.com, ima...@googlegroups.com
Hi,

The IMA SDK doesn't fire the ALL_ADS_COMPLETED event when the IMAAdError event is fired. However, if the requested ad is of
VMAP type, the IMA SDK will fire the LOG event if an error occurs during any of the ad breaks then will fire the ALL_ADS_COMPLETED event when all the ad breaks are completed.


Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5001UV0o2W:ref

Lech Pawlak

unread,
Mar 3, 2020, 7:32:43 AM3/3/20
to Interactive Media Ads SDK
Hi, 

i have another problem at the moment. Please open the sample project: https://www.dropbox.com/sh/p6jw092rt1sl3ka/AAAnwNv7uV3pV0-16Z9NOO0Aa?dl=0

 What I changed in the project is:
-- replaced your tag with mine
-- set the project to play sound in the background mode
-- hid videoView by setting its isHidden flag to true (because I want to present audio ads; this solution was recommended by you in the previous messages)

The problem is that when after the app's launch we go rapidly to the background mode the events sent by adsManager are delayed (or stopped for a while; and are sent just when the app goes back to the foreground). 

Lech Pawlak

unread,
Mar 3, 2020, 8:15:51 AM3/3/20
to Interactive Media Ads SDK
I will only add that I noticed the same behavior when it comes to the adsManagerDidRequestContentResume(_ adsManager: IMAAdsManager!) method -- its called right after the back goes to foreground.

IMA SDK

unread,
Mar 3, 2020, 3:16:23 PM3/3/20
to lechroch...@gmail.com, ima...@googlegroups.com
Hi,

Apologies for the confusion, your previous IMA set up suggested that you didn't want to use the videoview at all, this is the reason why I suggested that you try to hide it. However, you don't need to hide the video when you want to present audio ads using the Background Audio Ad Playback implementation, the IMA SDK hides it automatically. The IMA SDK is using the videoview to attach the Ad Ui (Audio or Video) that being said, it is not recommended to use a fakeview or hide videoview as these methods will affect the AdsManager's events. When you use the Background Audio Ad Playback implementation to present audio ads, the IMA SDK will render the Ad Ui on top of the content player and the ad events should fire as expected.


Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5001UV0o2W:ref

Lech Pawlak

unread,
Mar 3, 2020, 4:33:54 PM3/3/20
to Interactive Media Ads SDK
Hi, 

thank you for your reply.

We don't want to display any UIView while playing audio ads. That's why I hid videoView in the sample project as you recommended before (instead of passing a "fake" UIView which wasn't in the view hierarchy). This is totally fine in our case. The question is if this (hiding UIView taken from the view hierarchy, and later passing it as an argument to the IMAAdDisplayContainer's constructor) can affect adsManager's events / IMAAdsManagerDelegate's methods when our app is in the background mode. If that can happen and these events won't be sent correctly (or the delegate methods called) in the background mode, we cannot correctly implement a mechanism for playing audio ads because we have to know exactly when adsManager finishes playing them -- we resume our player (with radio stream) then. 

IMA SDK

unread,
Mar 4, 2020, 3:26:02 AM3/4/20
to lechroch...@gmail.com, ima...@googlegroups.com

Hi Lech,

 

Thank you for your response. Going back to the issue that you've encountered (events sent by adsManager are delayed). I've downloaded the project file that you've shared. I was able to reproduce this behavior by sending the app to background mode after launching. I made a simple tweak in your implementation by un-hiding the videoView; however, I've encountered the same issue. Thus, regardless of your implementation (hiding and un-hiding the videoView) the behavior would be the same on your scenario.

 

That being said, allow me to share this with the rest of the team for further checking and we'll get back to you once we have our findings.

 

Regards,

Sherwin Diesta

Lech Pawlak

unread,
Mar 6, 2020, 3:21:49 AM3/6/20
to Interactive Media Ads SDK
Hi,

do you already have any findings after the investigation of the problem?

IMA SDK

unread,
Mar 6, 2020, 7:31:51 AM3/6/20
to lechroch...@gmail.com, ima...@googlegroups.com

Hi Lech,

 

Thank you for following up on this. At the moment we do not have an update yet. However, rest assured, the team is actively looking into this issue and we'll let you know once we have an update.

Kordian Ledzion

unread,
Mar 24, 2020, 7:37:37 AM3/24/20
to Interactive Media Ads SDK
Hey, is there any update on the topic? 2 weeks actively looking into one bug is kind of a long time to be honest.

IMA SDK

unread,
Mar 24, 2020, 3:10:37 PM3/24/20
to kordian...@grupawp.pl, ima...@googlegroups.com
Hi,

Thank you for following up with support. We don’t have an update for you at this time, but I will come back to this thread as soon as I have more information.

Regards,
Arnaud Casame
IMA SDK Team


ref:_00D1U1174p._5001UV0o2W:ref
Message has been deleted

IMA SDK

unread,
Mar 6, 2023, 5:31:13 AM3/6/23
to dam...@mintflavour.com, ima...@googlegroups.com

Hi Damiano,

Can you confirm if you're looking to add background audio ad playback to your IMA SDK implementation? If yes, then kindly refer to this documentation: https://developers.google.com/interactive-media-ads/docs/sdks/ios/client-side/background_ad_playback

Let me know if you have any questions or if I misunderstood your concern, kindly elaborate and provide the following information:

  • SDK version used
  • Screenshots describing the issue
  • sample app where the issue is reproducible
  • steps to reproduce the issue


If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

  1. Navigate to https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=IMA+SDK&entry.460850823=5001U00000V0o2WQAR&entry.80707362=00028412
  2. Fill out all fields, and attach your file(s).
  3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.


Regards,

Google Logo IMA SDK Team


ref:_00D1U1174p._5001UV0o2W:ref
Reply all
Reply to author
Forward
0 new messages