Google IMA / DAI
The AmpIMA plugin offers a quick way to integrate AmpPlayer with the Interactive Media Ads by Google. This plugin will handle the interaction between the AmpPlayer with the plugin as well as the ads insertion or DAI stream playback.
If you desire to check out a basic implementation please refer to our application samples:
To manually install the plugin you’ll need to download our latest distribution. You’ll have to look for the
AmpIMA.framework and the
AmpCore.framework. You will also need the Google IMA SDK for iOS, you can download it on the iOS release page.
For tvOS you should include the
AmpCoreTV.framework and the
AmpIMATV.framework. The Google IMA SDK for tvOS will be required as well, you can download it on the tvOS release page.
|The latest version of the Google IMA SDK used by this plugin is 3.11.4 on iOS and 4.2.2 on tvOS . Newer versions may be used, but you may run into unexpected errors until an update is released.|
After aquiring the frameworks you can just drag them to you Xcode project directory.
The last step, is to mark every imported framework for
Embed & Sign in the project’s general tab.
If you don’t have CocoaPods installed, refer to the CocoaPods documentation. To use CocoaPods, first create a Podfile in the directory containing the Xcode project. For the AmpIMA plugin, the Podfile should look like this:
target "ProjectName" do use_frameworks! pod 'AmpCore' pod 'AmpIMA' pod 'GoogleAds-IMA-iOS-SDK' end
Once you have added the Podfile just run the command
pod install --repo-update in the directory it’s located. Once the command has been completed you should se a new
.xcworkspace file in your folder. Now you can start integrating the library.
You need a working implementation of the AmpPlayer before using this plugin. If you need the implementation guide for AmpPlayer please refer to our documentation.
The first step is to import the AmpIMA plugin. In the most likely scenario you will need the AmpCore library, and you may need the Google IMA SDK in specific cases.
import AmpCore import AmpIMA import GoogleInteractiveMediaAds
To use this plugin you should first initialize it. You need to specify the player being used as well as the view were the ads will be displayed.
let manager = AmpIMAManager(ampPlayer: player, videoView: player.playerView!)
|Do not create multiple instances of the AMPIMAManager. This could create unwanted behaviors since it wouldn’t be following Google’s recomendation against intancing more than one IMAAdsLoader.|
To request a DAI live or VoD stream you won’t need to call the
AmpPlayer.play(url:String) method. Instead use thismethod for requesting the DAI streams:
manager.requestVodStream(contentSourceID: "2528370", videoID: "tears-of-steel")
|You can also add a fallback URL on this methods so that if the stream couldn’t be loaded the fallback will still be played.|
To request IMA ads just send your Ad Tag provided by Google to this method.
This will request the ads and display them at the proper time.
This plugin will automatically hook the events from the IMA SDK, both client-side ads and DAI streams, and send the proper AMPPlayer Events. However, in case you want to handle yourself some of the events on IMA, we provide the means to do this by passing a valid delegate to the manager.
manager.imaDelegate = self manager.daiDelegate = self
This guide was written on 4/27/2020 and it’s last revision was made on 4/27/2020. If you need any additional support please contact us through our offical support email.