How to use IMA iOS SDK to play pre-roll video ad with MPMoviePlayerController in swift

1,570 views
Skip to first unread message

Vipul Kumar

unread,
Feb 18, 2015, 5:41:26 AM2/18/15
to ima...@googlegroups.com
I am working with iOS project  in swift language. I need to implement DFP pre roll video ad to play of each video. I use the MPMoviePlayerController to play the main video. Then to use IMA SDK to play pre roll ad in MPMoviePlayerController. Please  provide sample code with play pre roll ad in MPMoviePlayerController using swift or Objective C
 I following this link but not completely

Thanks

Shawn Busolits (IMA SDK Team)

unread,
Feb 18, 2015, 10:04:48 AM2/18/15
to ima...@googlegroups.com
Hi Vipul,

We currently don't have any examples working in swift with the MPMoviePlayerController, though the workflow for the SDK will be the same. The only difference is that instead of using an IMAAVPlayerContentPlayhead, you'll need to implement an IMAContentPlayhead of your own. You should be able to just change the syntax in the code snippets from Objective-C to swift. Did you run into any specific problems working through the quickstart?

Thanks,
Shawn Busolits
IMA SDK Team
Message has been deleted
Message has been deleted

Vipul Kumar

unread,
Feb 19, 2015, 2:03:02 AM2/19/15
to ima...@googlegroups.com
Hello Sir,
  I am confused to how to own implement IMAContentPlayhead to MPMoviePlayerController so you can provide us some example code for IMAContentPlayhead with MPMoviePlayerController in Objective C.

Thanks.

Shawn Busolits (IMA SDK Team)

unread,
Feb 19, 2015, 9:56:09 AM2/19/15
to ima...@googlegroups.com
Hi Vipul,

The Google Media Framework for iOS actually implements IMAContentPlayhead, you can see the code for that here. The change you'd need to make is that instead of listening for currentMediaTimeDidChange on an instance of GMFPlayerViewController, you'll need to use NSTimer to poll the current time of the MPMoviePlayerController on some interval of your choosing (I'd recommend no less frequently than once per second). If you have any other questions let us know!

Thanks,
Shawn Busolits
IMA SDK Team

Vipul Kumar

unread,
Feb 20, 2015, 2:24:55 AM2/20/15
to ima...@googlegroups.com
Hello Sir,
               I want to know another one things  iOS IMA SDK support to Swift or not ?
               Please reply as soon as possible. 
Thanks.

Shawn Busolits (IMA SDK Team)

unread,
Feb 20, 2015, 10:55:34 AM2/20/15
to ima...@googlegroups.com
Hi Vipul,

We have not fully tested the SDK with swift, however I have heard from publishers who are using it with swift. It should only be syntactically different than Objective-C.

Thanks,
Shawn Busolits
IMA SDK Team

Vipul Kumar

unread,
Feb 20, 2015, 11:10:57 AM2/20/15
to ima...@googlegroups.com
Hello Sir,
              Thanks a lot.

Shivprakash Yadav

unread,
Oct 15, 2015, 3:54:58 AM10/15/15
to Interactive Media Ads SDK
I m using Mpmovieplayercontroller.Pre rolls are working but mid rolls not playing .Please help me how to implement IMAContentPlayhead in my code.
If any sample code pls share to me.

Shawn Busolits (IMA SDK Team)

unread,
Oct 15, 2015, 2:17:00 PM10/15/15
to Interactive Media Ads SDK
Hi Shivprakash,

We have a sample implementation for this in the GMF for iOS. You can see that implementation here. You'll have to substitute in an MPMoviePlayerController for the GMFPlayerviewController that sample is using. If you have any other questions let us know!

Thanks,
Shawn Busolits
IMA SDK Team

Karen Anne Tolentino

unread,
Oct 30, 2015, 4:05:59 AM10/30/15
to Interactive Media Ads SDK
Hi Shawn,

Should I just replace GMFPlayerViewController with MPMoviePlayerViewController? Then add the implementation and header files to my project, and call it like the IMAAVPlayerContentPlayhead?

Shawn Busolits (IMA SDK Team)

unread,
Oct 30, 2015, 11:21:37 AM10/30/15
to Interactive Media Ads SDK
Hi Karen,

I'd recommend using our samples to see how to integrate MPMoviePlayerController (they currently use AVPlayer, but you can swap in MPMoviePlayerController instead). You should use the GMF code just to see how to write your own IMAContentPlayhead. GMF player has a lot of overhead that in general you don't need to worry about, which is why I'd recommend the samples for reference for anything but content playhead. If you have any other questions let us know!

Thanks,
Shawn Busolits
IMA SDK Team

Siddaraju S

unread,
Mar 8, 2018, 11:03:26 PM3/8/18
to Interactive Media Ads SDK
Dear IMA SDK team,

I have a doubt in similar lines. For Pre-roll Ads is the Ad played by IMA SDK or AD played by the player like AV Player or MP MoviePlayerController.
Does IMA SDK just monitors the current duration of the content video played by AV Player  ? If so how does it inform the Player to play Mid Roll Ad in between.

Please clarify.

Regards
Siddaraju

Chris Feldman (IMA SDK Team)

unread,
Mar 12, 2018, 3:02:00 PM3/12/18
to Interactive Media Ads SDK
Hi,

The IMA SDK uses a content playhead tracker to monitor the content (link):

In order to play mid-rolls, the SDK needs to track the current position of your video content. For it to do this you'll need to create a class that implements IMAContentPlayhead. If you're using an AVPlayer, the SDK provides the IMAAVPlayerContentPlayhead class which does this for you. If you're not using AVPlayer, you'll need to implement IMAContentPlayhead on a class of your own. The below snippet shows how to set up a playhead tracker for an implementation that is using an AVPlayer.

In order to use MoviePlayerController, you'll need to implement IMAContentPlayhead as stated above. Please start a new thread if there is anything else you need. For tracking purposes, we try not to re-open very old threads like this one.

Regards,
Chris Feldman
IMA SDK Team

rak...@infiniteit.biz

unread,
Aug 6, 2018, 6:19:26 AM8/6/18
to Interactive Media Ads SDK
Hi sir,

To get the ads using IMA SDK, do I need to register somewhere? how will I get those Links to play the ads? There are hardcoded links in the Demo project like "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&" +

    "iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&" +

    "output=vast&unviewed_position_start=1&" +

    "cust_params=deployment%3Ddevsite%26sample_ct%3Dskippablelinear&correlator=".

How to generate the above link?

ima-sdk-adv...@google.com

unread,
Aug 6, 2018, 2:09:51 PM8/6/18
to ima...@googlegroups.com
Hi,

The IMA SDK will allow you to make ad requests to any VAST compliant ad server. We recommend DoubleClick for Publishers or AdSense.

Regards,
Chris Feldman
IMA SDK Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+ page:
    http://googleadsdeveloper.blogspot.com
    https://plus.google.com/115658573333388777174/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

--
You received this message because you are subscribed to the Google Groups "Interactive Media Ads SDK" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ima-sdk+unsubscribe@googlegroups.com.
To post to this group, send email to ima...@googlegroups.com.
Visit this group at https://groups.google.com/group/ima-sdk.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages