Audio Ads

Enhance your app's monetization potential with InMobi's cutting-edge Audio Ads feature. With InMobi's SDK support for Audio Ads, you can seamlessly integrate high-quality, targeted audio advertisements into your app's audio content. Engage your users with relevant and captivating audio messages that fit seamlessly within their experience.

Set up Audio Ad

  1. From the left navigation, select Inventory Inventory Settings.
  2. Search for the app or website you would like to create a placement for and click + Add a placement.
  3. Click Select Ad Unit and select Audio Icon.
  4. Click Add a placement to start setting up your Audio settings. After you create the audio placement, you can see the placement ID.

Add Audio Ad to Your App

Ensure you have updated the InMobi Android SDK to version 10.5.7 or above. Creating an InMobiAudio object before SDK initialization throws an error.

Add An Audio Slot in Code

To add an Audio ad in the Android code, create an InMobiAudio instance:

val inmobiAudioAd = InMobiAudio(this, AUDIO_PLACEMENT_ID);

You can create an audio container anywhere on the screen with a 70p x 70px size, preferably, and add it to the view hierarchy:

val adContainer = findViewById<RelativeLayout>(<ad-container-id>) 
adContainer.removeAllViews() 
adContainer.addView(inmobiAudioAd) 
inmobiAudioAd.setAudioSize(70, 70)

Load Audio Ad

To request an interstitial ad, call the load() method on the InMobiAudio instance:

inmobiAudioAd.load()

If the onAdLoadSucceeded event is generated, you can show the ad after this by calling show() on the InMobiAudio instance.

Note

  • If new instances are created for every audio ad, ensure load() is called with every InMobiAudio instance.
  • Ensure the InMobi SDK is initialized successfully before calling load().

Show Audio Ad

To show an audio ad, call show() on the InMobiAudio instance after the onAdLoadSucceeded the SDK has generated an event.

inmobiAudioAd.setListener(object: AudioAdEventListener(){ 
    override fun onAdLoadSucceeded(p0: InMobiAudio?, p1: AdMetaInfo) { 
        super.onAdLoadSucceeded(p0, p1) 
        inmobiAudioAd.show(); 
    } 
}

Optimization

Listen for Audio Ad Lifecycle Events

If you want to listen to key events in the audio ad lifecycle, you can implement the AudioAdEventListener interface. A sample implementation is shown below.

val audioAdEventListener = object : AudioAdEventListener() {    
    /**  
     * Called to notify that an ad was received successfully but is not ready to be ayed yet.  
     *  
     * @param ad   Represents the ad which was loaded or preloaded  
     * @param info Represents the ad meta information  
     */  
    override fun onAdFetchSuccessful(ad: InMobiAudio, info: AdMetaInfo) {    
    }    
    /**  
     * Called to notify that an ad preload has failed.  
     *  
     * @param ad     Represents the [InMobiAudio] ad which was preloaded  
     * @param status Represents the [InMobiAdRequestStatus] status containing error reason  
     */  
    override fun onAdFetchFailed(ad: InMobiAudio, status: InMobiAdRequestStatus) {    
    }    
    /**  
     * Called to notify that an ad was successfully loaded and is ready to be displayed.  
     *  
     * @param ad   Represents the ad which was loaded  
     * @param info Represents the ad meta information  
     */  
    override fun onAdLoadSucceeded(ad: InMobiAudio, info: AdMetaInfo) {    
    }    
    /**  
     * Called to notify that a request to load an ad failed.  
     *  
     * @param ad     Represents the ad which failed to load  
     * @param status Represents the [InMobiAdRequestStatus] status containing error reason  
     */  
    override fun onAdLoadFailed(ad: InMobiAudio, status: InMobiAdRequestStatus) {    
    }    
    /**  
     * Called to notify that the banner ad has expanded  
     *  
     * @param ad Represents the [InMobiAudio] ad which was expanded  
     */  
    override fun onAdDisplayed(ad: InMobiAudio) {  
    }    
    /**  
     * Called to indicate that a request to show an ad (by calling [InMobiAudio.show]  
     * failed. You should call [InMobiAudio.load] to request for a fresh ad.  
     *  
     * @param ad Represents the [InMobiAudio] ad which failed to show  
     */  
    override fun onAdDisplayFailed(ad: InMobiAudio) {  
    }
    /**  
     * Called to notify that inmobi has logged an impression for the ad  
     *  
     * @param ad     Represents the ad which was impressed  
     */  
    override fun onAdImpression(ad: InMobiAudio) {  
    }    
    /**  
     * Called to notify that the Audio status has changed  
     *  
     * @param ad Represents the [InMobiAudio] ad  
     * @param audioStatus Represents the [AudioStatus] of the current playing ad  
     */  
    override fun onAudioStatusChanged(ad: InMobiAudio, audioStatus: AudioStatus) {    
    }    
    /**  
     * Called to notify that the user interacted with the ad.  
     *  
     * @param ad     Represents the ad on which user clicked  
     * @param params Represents the click parameters  
     */  
    override fun onAdClicked(ad: InMobiAudio, params: Map<Any, Any>) {    
    }    
    /**  
     * Called to notify that a reward was unlocked.  
     *  
     * @param ad      Represents the [InMobiAudio] ad for which rewards was unlocked  
     * @param rewards Represents the rewards unlocked  
     */  
    override fun onUserLeftApplication(ad: InMobiAudio) {    
    }    
    /**  
     * Called to notify that the User is about to return to the application after closing d.  
     *  
     * @param ad Represents the [InMobiAudio] ad which was closed  
     */  
    override fun onAdDismissed(ad: InMobiAudio) {    
    }  
}  
 
audioAd.setListener(audioAdEventListener)

Note

The bid value can be accessed from the AdMetaInfo object’s bid field.

Destroy Audio Object

You can release the resources after showing an audio ad by calling destroy. You may call the function on receiving AudioStatus.Completed in onAudioStatusChanged function callback in the listener.

  1. Remove the ad view from the view hierarchy
  2. De-reference the listeners
  3. Other clean-ups.
inmobiAudioAd.destroy()

Integrate Rewarded Audio Icons

Set up Audio Ad

  1. From the left navigation select Inventory Inventory Settings.
  2. Search for the app or website you would like to create a placement for and click + Add a placement.
  3. Click Select Ad Unit and select Rewarded Audio.
  4. Click Add a placement to start setting up your rewarded video settings. After you create the rewarded video placement, you can see the placement ID.

Add Rewarded Audio Ad to Your App

The implementation for Rewarded Audio Icon ads closely resembles that of Audio Icons.

You are expected to present a prompt to users, seeking their opt-in prior to displaying the rewarded audio icon ad. The InMobi SDK also offers the onRewardsUnlocked event for Rewarded ads. However, you can retain the flexibility to determine the timing of user rewards using various event callbacks.

inmobiAudioAd.setListener(object: AudioAdEventListener(){ 
    override fun onRewardsUnlocked(ad: InMobiAudio, rewards: Map<Any, Any>) { 
        super.onRewardsUnlocked(ad, rewards) 
        // pass rewards to the user 
    } 
}

Test Integration

Using sandbox ads, you can assess the placement and refine the user experience. This involves configuring the placement in Test Mode, setting it as 'Global' within the placement settings. It's important to ensure that you set the device volume to a sufficient level to ensure ad playback.

For those employing manual SDK integration, it's imperative to initialize the InMobi SDK within the mediation debugger to ensure seamless operation and accurate evaluation.

On This Page

Last Updated on: 22 Aug, 2023