-jio-start-block-type-3
Instream audio ads seamlessly integrate within your app's audio content, offering various formats like pre-roll, mid-roll, and post-roll.
Complete GETTING STARTED section and INITIALIZE SDK section before starting this section.
-jio-end-block-type-3
-jio-start-block-type-2
-jio-style-title
Cache instream audio ads by initializing a JioAdView
, setting up an ad delegate, creating an ad container, adding the ad view, and initiating the caching process with a single call to jioAdView?.cacheAd()
jioAdView = JioAdView(adSpotId: "<ADSPOT_KEY_GOES_HERE>", adType: .instreamAudio, delegate: self, forPresentionClass: self, publisherContainer: adContainer)
jioAdView?.setCustomView(container: CustomContainer) // For custom layout
jioAdView?.cacheAd()
-jio-style-title
Load the instream audio ad when it's in the prepared state, utilizing adView.loadAd()
for rendering.
extension InstreamVC : JIOAdViewProtocol {
func onAdPrepared(adView: JioAdView) {
self.showToast(message: "onAdDataPrepared")
adView.loadAd()
}
}
-jio-end-block-type-2
-jio-start-block-type-2
-jio-style-title
Destroy the instream audio ad object by calling adView?.invalidateAd()
in your activity to ensure proper cleanup during the activity lifecycle.
self.adView?.invalidateAd()
self.adView = nil
-jio-style-title
Use the below APIs to pause or resume Instream Audio Ad
jioAdView?.pauseAd()
jioAdView?.resumeAd()
-jio-end-block-type-2