MediaTailor on Android
AWS Elemental MediaTailor is a service that provides scalable ad insertion and channel assembly. It is able to serve targeted ad content to viewers and create linear streams while maintaining broadcast quality in over-the-top (OTT) video applications. It supports HLS and DASH for both VOD and live workflows.
At the moment of writing only linear ads are supported, but it is possible to expand it to non-linear and companion ads as well.
Configuration
To use a MediaTailor stream with THEOplayer on Android SDK, first import our MediaTailor module dependency in your build.gradle file.
implementation 'com.theoplayer.theoplayer-sdk-android:core:+'
implementation 'com.theoplayer.theoplayer-sdk-android:integration-ads-mediatailor:+' // add MediaTailor dependency
Then, add the MediaTailor integration to the Player.
If you're using automatic integrations, you can skip this step.
val theoplayerView = THEOplayerView(context)
val mediaTailorIntegration = MediaTailorIntegrationFactory.createMediaTailorIntegration(theoPlayerView);
theoplayerView.player.addIntegration(mediaTailorIntegration)
Finally, set a MediaTailorSource to play.
val mediaTailorSource = MediaTailorSource(src = "<mediatailorURL>/v1/session/<hashed-account-id>/<origin-id>/<asset-id>")
theoplayerView.player.source = SourceDescription(listOf(mediaTailorSource))
// or using the Builder pattern
val mediaTailorSource = MediaTailorSource
.Builder("<mediatailorURL>/v1/session/<hashed-account-id>/<origin-id>/<asset-id>")
.build()
theoplayerView.player.source = SourceDescription
.Builder(mediaTailorSource)
.build()
Optionally, you can pass parameters regarding e.g. session data and device type by using the adsParams property, as
described in the MediaTailor documentation.
val adsParams = emptyMap<String, String>().toMutableMap()
adsParams["param1"] = "value1"
adsParams["param2"] = "value 2"
val mediaTailorSource = MediaTailorSource(
src = "<mediatailorURL>/v1/session/<hashed-account-id>/<origin-id>/<asset-id>",
adParams = adsParams // Note the deprecated parameter name
)
// or using the Builder pattern
val mediaTailorSource = MediaTailorSource
.Builder("<mediatailorURL>/v1/session/<hashed-account-id>/<origin-id>/<asset-id>")
.adsParams(adsParams)
.build()
The source definition currently still uses the deprecated adParams property. This will be
replaced by the adsParams property in a future version.