Playlist with Ads - Wrap Playlist with 1 Ads Source.
See original GitHub issueI have 3 MediaItem
(s) in a playlist and I would like to wrap them with 1 Ad Playlist, i.e. the pre-roll plays before the first media item, the mid-rolls plays through the first, second and third media item and the end-roll plays at the end of the third media item.
I had a look at the documentation, and found that:
It’s possible to customize this behavior by passing an opaque ads identifier with which ad playback state for a given media item is linked, based on object equality. Here is an example where ad playback state is linked to the ad tag URI only, rather than the combination of the media ID and ad tag URI, by passing the ad tag URI as the ads identifier. The effect is that ads will load only once and the user will not see ads on the second item when playing the playlist from start to finish.
This customisation didn’t work for us, since no ads were played in the second item (the post-roll was triggered before the start of the second media item).
I also tried wrapping the 3 MediaItem
(s) in a ConcatenatingMediaSource
and then wrap the resulting ConcatenatingMediaSource
with an AdsMediaSource
. That didn’t work and threw an exception.
Is there any way to achieve this? Would I need to build my own AdsLoader
for this?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
I don’t think there are any alternative approaches that work at the moment – you’d need to work around the problem by splitting the ad tag as suggested above, or find a way to join the content pieces into one period. https://github.com/google/ExoPlayer/issues/3693 tracks removing the limitation that the content media source may only have one period.
@andrewlewis can you take a look and see if there are any alternative approaches here that I’ve missed?