-jio-start-block-type-2
-jio-style-title
JioReel, also called as Jio SSAI(Server-side ad insertion) is a combination of manifest manipulation, ad server communication, and ad bitrate and resolution normalization, all of which happens on the server-side before presenting a manifest to clients. Server-side ad insertion may also be referred to as dynamic ad insertion, or ad stitching.
Complete GETTING STARTED section and INITIALIZE SDK section before starting this section
-jio-style-title
Call below API to initialize JioReel Plugin
-jio-tables
Config Params | Description |
---|---|
Player Name | provides player name |
Player version | provides player version |
jioReelListener | provides ad detection and stream url callbacks |
url | provides view url |
metadata | provides map of meta data |
Timeout | this is optional, pass an integer value of timeout in seconds |
val jioReelPlugin = JioReelPlugin(context)
val metaData: MutableMap < String, String > = mutableMapOf()
metaData.set("age", "25")
metaData.set("gender", "M")
jioReelPlugin.init(
PlayerName.ExoPlayer, ExoPlayerLibraryInfo.VERSION,
jioReelListener, url, metaData, adspotId, 20)
As a success onStreamReady(streamUrl: String?)
callback is given along with stream url/media url.
-jio-style-title
Call the below API once you get stream URL from onStreamReady ()
callback and app exoplayer is initialized
val jioreelConfig = JioReelConfig.config(this, jioReelListener)
JioReelConfig.setPlayer(exoPlayer)
jioreelConfig.SDKInit()
If you do not want to pass exoplayer instance you can pass the manifest as
exoPlayer?.addListener(object : Player.Listener {
override fun onTimelineChanged(timeline: Timeline, reason: Int) {
super.onTimelineChanged(timeline, reason)
if (exoPlayer!!.playWhenReady) {
jioReelConfig?.setManifest(exoPlayer?.currentManifest)
}
}
})
jioReelListener = object: JioReelListener {
override fun onAdMediaStart(adMetaData: JioReelAdMetaData ? ) {
println("onAdMediaStart ".plus(adMetaData))
}
override fun onAdChange(adMetaData: JioReelAdMetaData ? ) {
if (adMetaData != null)
println("onAdChange ".plus(adMetaData))
else println("onAdChange ad slate detected")
}
override fun onAdMediaEnd() {
println("onAdMediaEnd")
}
override fun onStreamReady(streamUrl: String ?) {
println("onStreamReady streamUrl: $streamUrl")
}
override fun onAdError(errorCode: Int ? , errorMsg : String ? ) {
println("onAdError: $errorCode, $errorMsg")
}
//Needed when player instance is not passed
override fun onAdDetection(isDetecting: Boolean) {
if (isDetecting) {
val window: Timeline.Window = Timeline.Window()
if (!exoPlayer!!.currentTimeline
.isEmpty
) {
exoPlayer!!.
currentTimeline
.getWindow(
exoPlayer!!.currentMediaItemIndex, window)
//For Spot Ad override fun onAdSlotStart(creativeId:String,companionAd:String){ }
//For Spot Adoverride fun onAdSlotEnd(creativeId: String){}
jioReelConfig?.playerTime(window.currentUnixTimeMs, exoPlayer!!.currentLiveOffset);
}
}
}
}
-jio-style-title
-jio-tables
Callbacks | Description |
---|---|
onAdMediaStart> | triggered when ad is detected in an ad pod. |
onAdChange | triggered for 2nd, 3rd ...so on for next consecutive ads in ad pod. |
onAdMediaEnd | triggered when all ads are completed in ad pod. |
onStreamReady | triggered on successful response of API where you get the playback URL to be passed on to player. |
onAdError | error thrown for timeout or any exception during API call |
onAdDetection | this will only be called if exoplayer instance is not passed to SDK. And you need to send the window current time and player offset in playerTime() |
JioReelAdMetaData will consist of the following information
-jio-tables
MetaData | Description |
---|---|
adId | unique ID associated to ad |
adTitle | title of ad |
adIndex | index of ad in ap pod |
adDuration | duration of ad in seconds |
isClickable | if an ad has click url value will be true and you can show visit advertiser button on UI. |
jioReelAdParameter | will have information for CTA buttons like CTA text, CTA text color, CTA background color and so on |
videoCtaText | primary CTA text |
videoButtonColor | primary CTA button color |
adTitle | ad title |
videoCtaColor | primary CTA text color |
iconUrl | primary CTA icon URL |
adDescription | ad description |
titleTextColor | ad title text color |
descriptionTextColor | ad description text color |
secondaryCtaText | secondary CTA text |
secondaryCtaTextColor | secondary CTA text color |
secondaryCtaButtonColor | secondary CTA button color |
secondaryCtaUrl | secondary CTA URL |
secondaryCtaUrlTracker | secondary CTA tracker URL |
openInApp | Instead opening in browser, this flag if enabled, opens within the App |
ctaUrl | has deep link and fallback url |
-jio-style-title
Click handling is supported internally by SDK. You will get a boolean value “isClickable” in the callbacks onAdMediaStart and onAdChange. As per that you can show the “Visit Advertiser” button on UI.
You get additional information for click in AdParams object like ctatext, ctacolor etc.
private fun setCTAButton(isClickUrl: Boolean, adMetaData: JioReelAdMetaData) {
if (isClickUrl) {
if (adMetaData.jioReelAdParameter != null) {
if (adMetaData.jioReelAdParameter?.videoCtaText != null)
binding.primaryCta.text = adMetaData.jioReelAdParameter?.videoCtaText
if (adMetaData.jioReelAdParameter?.videoCtaColor != null)
binding.primaryCta.setTextColor(Color.parseColor(adMetaData.jioReelAdParameter?.videoCtaColor))
if (adMetaData.jioReelAdParameter?.videoButtonColor != null)
binding.primaryCta.setBackgroundColor(Color.parseColor(adMetaData.jioReelAdParameter?.videoButtonColor))
if (adMetaData.jioReelAdParameter?.secondaryCtaUrl != null) {
binding.secondaryCTA.visibility = View.VISIBLE
if (adMetaData.jioReelAdParameter?.secondaryCtaTextColor != null)
binding.secondaryCTA.setTextColor(Color.parseColor(adMetaData.jioReelAdParameter?.secondaryCtaTextColor))
if (adMetaData.jioReelAdParameter?.secondaryCtaButtonColor != null)
binding.secondaryCTA.setBackgroundColor(
Color.parseColor(
adMetaData.jioReelAdParameter?.secondaryCtaButtonColor
)
)
if (adMetaData.jioReelAdParameter?.secondaryCtaText != null)
binding.secondaryCTA.text =
adMetaData.jioReelAdParameter?.secondaryCtaText
} else {
binding.secondaryCTA.visibility = View.GONE
}
} else {
binding.secondaryCTA.visibility = View.GONE
}
binding.primaryCta.visibility = View.VISIBLE
} else {
binding.primaryCta.visibility = View.GONE
binding.secondaryCTA.visibility = View.GONE
}
}
Click redirection is handled from SDK. On CTA click you will have to call the method “handleAdClick”
which has parameters current ad meta data and boolean denoting primary/secondary CTA click
binding.primaryCta.setOnClickListener {
if (metaData != null)
jioReelPlugin?.handleAdClick(metaData, true)
}
binding.secondaryCTA.setOnClickListener {
if (metaData != null)
jioReelPlugin?.handleAdClick(metaData, false)
}
-jio-style-title
Call the below API to stop tracking from JioReel Plugin. It should be called inside onStop() of activity/fragment
jioReelPlugin?.onStop()
-jio-style-title
fireClickTrackers() is deprecated since version 1.0 and is replaced with handleAdClick() from version 1.1
-jio-style-title
-jio-tables
Error Code | Error Message | Error Description |
---|---|---|
s101 | Stream view url cannot be empty | init view url must not be empty |
s102 | Headers cannot be null for VOD stream type | For VOD stream headers cannot be null |
s103 | Headers markers cannot be empty | For VOD stream headers markers cannot be empty |
s104 | Headers content URL cannot be empty | For VOD stream headers content URL cannot be empty |
s105 | Malformed URL Observed: | Malformed URL |
s106 | Socket Timeout while network call | Socket timeout |
s107 | Unable to connect while network call. | Connection refused |
s108 | SSLPeerUnverifiedException while network call. | SSL peer unverified |
s109 | IOException while network call. | IO error |
s110 | Unknown exception while network call. | Unknown error |
-jio-style-title
Refer Companion section.
-jio-end-block-type-2