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.
There are three requirements to use a MediaTailor stream with THEOplayer:
mediatailor
feature flag set.src
is set to the session initialization URL. mediatailor
. If everything is set up correctly, THEOplayer will play the stream and send the necessary tracking beacons.
const player = new THEOplayer.Player(element, {
libraryLocation: 'path/to/theoplayer',
license: 'your-license-here',
...
});
player.source = {
sources: [
{
src: '<mediatailorURL>/v1/session/<hashed-account-id>/<origin-id>/<asset-id>',
integration: 'mediatailor'
}
]
}
The scope of the MediaTailor integration for now is limited to sending the tracking beacons. This encapsulates only the events that can be sent with the default implementation of THEOplayer. For example skipping an ad is not yet supported so the events that correspond to skipping an ad will never occur.
At the moment there is a limitation to HLS where the tracking beacons are sometimes sent with small offsets. We are aware of this issue and will be fixing this in the future. DASH does work as expected.
Seeking is only disabled during an ad, no logic is in place for playing an ad if the user seeked past it.
To use a MediaTailor stream with THEOplayer on Unified Android SDK, first import our MediaTailor module dependency in your build.gradle
file.
implementation 'com.theoplayer.theoplayer-sdk-android:unified:+'
implementation 'com.theoplayer.theoplayer-sdk-android:unified-ads-mediatailor:+' // add MediaTailor dependency
Then, add the MediaTailor integration to the Player
MediaTailorIntegration mediaTailor = MediaTailorIntegrationFactory.createMediaTailorIntegration(theoPlayerView);
theoPlayerView.getPlayer().addIntegration(mediaTailor);
Finally, set a MediaTailorSource to play.
MediaTailorSource mediaTailorSource = new MediaTailorSource.Builder()
.src("<mediatailorURL>/v1/session/<hashed-account-id>/<origin-id>/<asset-id>")
.build();
SourceDescription sourceDescription = new SourceDescription.Builder()
.sources(mediaTailorSource)
.build();
theoPlayerView.getPlayer().setSource(sourceDescription);
For the Webview based SDK, make sure to have a THEOplayer build with the mediatailor
feature flag set.
And then set a MediaTailorSource to play similar to the Unified Android SDK shown above.
To use a MediaTailor stream with THEOplayer on the iOS SDK, you have to:
mediatailor
flag enabled (similarly to the other SDKs) player.source = SourceDescription(
source: MediaTailorSource(
src: "<mediatailorURL>/v1/session/<hashed-account-id>/<origin-id>/<asset-id>",
type: "application/x-mpegurl"
)
)
Note that the MediaTailor URL must have the same structure as described above (Web SDK). Different URL structures may result in playback errors.