Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow changes in ad group count and order (to support pause-roll ads). #5482

Open
levz opened this issue Feb 6, 2019 · 8 comments
Open

Allow changes in ad group count and order (to support pause-roll ads). #5482

levz opened this issue Feb 6, 2019 · 8 comments

Comments

@levz
Copy link

levz commented Feb 6, 2019

I wonder if there is a way of creating some custom media source with pause-roll support (pause-roll is an ad that is started when user resumes video from pause)?

AdsMediaSource does not support it and also is not accurate with delivering player states (#5209)

It seems that dynamic ConcatenatingMediaSource (combined from ClippingMediaSources with content and ad sources) might do the trick, but I'm not sure if there is a way to make player show the whole timebar for content instead of just timebar for current media source - is there a way?

Currently for post-roll I just save content position and load ad media and then reload content media back. But I would like to have that logic wrapped into custom media source to make my player code simpler.

@tonihei tonihei self-assigned this Feb 7, 2019
@tonihei
Copy link
Collaborator

tonihei commented Feb 7, 2019

As you already pointed out, there are two possible paths this can be implemented: as an AdsMediaSource or by manipulating a ConcatenatingMediaSource.

AdsMediaSource

Implementation: Write your own AdsLoader which published an AdPlaybackState with an ad break at the pause position after you receive the pause event.
Advantage: ad breaks nicely integrate in the UI and the way seeks are handled in the player etc.
Disadvantage: It requires two features in ExoPlayer which are not (yet) available:

  1. Changing the position of ad breaks and implicitly the duration of existing content pieces . That will be supported from 2.10. onwards (tracked by Support changing ad break positions #5067)
  2. Changing the number of ad groups in the AdPlaybackState . That is currently not supported and there are no immediate implementation plans for this (although we might look at this in the future). We can use this issue to track this as an enhancement, but it's likely to be low priority for now.

So if you can specifiy the number of total ad breaks in advance and then move them around (without chaning their order) this would potentially work from 2.10. onwards.

ConcatenatingMediaSource

Implementation: Wrap all content pieces in ClippingMediaSource (with initially unset end position of C.TIME_END_OF_SOURCE. When the pause event is received, change the end position to the current paused position, add a new ad media source to the playlist and after the ad another content piece (wrapped in clipping source so that it can be clipped later). Unfortunately, that will also only be supported in 2.10 (tracked by #3163).
Advantage: Super flexible when it comes to media composition and changes to the media composition.
Disadvantage: Timebar UI does not reflect content only. There is an option to show all windows, but that would include the ad duration and has its own problems when used with ExtractorMediaSource for example (improvement tracked by #4727). So you would need to fork DefaultTimeBar and PlayerControlView to implement your own logic showing the ad breaks and also translating time bar position to seek position.

@tonihei
Copy link
Collaborator

tonihei commented Feb 7, 2019

Enhancement added for the feature of changing the number (and order) of ad breaks in AdPlaybackState.
@andrewlewis : Is that already tracked somewhere else? If yes, please let me know.

@andrewlewis
Copy link
Collaborator

I don't think this is already tracked, so let's use this issue. Thanks!

@tonihei tonihei changed the title [QUESTION] What is the best way of implementing pause-roll? QUESTION: Insert pause-roll ads. ENHANCEMENT: Allow changes in ad group count and order. Feb 7, 2019
@levz
Copy link
Author

levz commented Feb 7, 2019

@tonihei
Many thanks for breaking this down so nicely.

I would like to try concatenating source approach with custom Timebar.

Implementation: Wrap all content pieces in ClippingMediaSource (with initially unset end position of C.TIME_END_OF_SOURCE. When the pause event is received, change the end position to the current paused position, add a new ad media source to the playlist and after the ad another content piece (wrapped in clipping source so that it can be clipped later). Unfortunately, that will also only be supported in 2.10 (tracked by #3163).

Can I simply remove current content piece and then immediately add content source clipped to pause time, pause-roll ad source, and next content source clipped to start from pause time? Will it help to get around #3163 without wating for 2.10?

@tonihei
Copy link
Collaborator

tonihei commented Feb 7, 2019

Can I simply remove current content piece and then immediately add content source clipped to pause time, pause-roll ad source, and next content source clipped to start from pause time?

Unfortunately, that won't work because the id of the currently played content will change and the player would assume the current content isn't there anymore. It will probably transition to the ENDED state in such a case.

@levz
Copy link
Author

levz commented Feb 7, 2019

@tonihei

Thanks, for clarifying. Will wait for 2.10 version then.

@tonihei tonihei changed the title QUESTION: Insert pause-roll ads. ENHANCEMENT: Allow changes in ad group count and order. Allow changes in ad group count and order (to support pause-roll ads). Feb 8, 2019
@ojw28 ojw28 removed the question label Apr 5, 2019
@wkarl
Copy link

wkarl commented Apr 21, 2020

@tonihei as 2.11.4 has been released by now I was wondering if this is likely to be implemented in the near future.
My use case is that I need to be able to insert midroll ads spontaneously during playback at short notice. I don't have any information about ad break positions at the start of the video (except for the preroll) but it would help me to have a re-usable ad break that I can move around as required.

Alternatively I'd be fine with a ConcatenatingMediaSource wrapping several ClippingMediaSources but I assume it is still not possible to adjust the duration of a ClippingMediaSource while it is playing (#3163).

Another option I was considering is to jump to the next child source when an ad break is coming, is there a way to do this? And will the next source always be pre-buffered or will buffering start only just before reaching the next playlist item? If this were possible I'd have a messed up timeline but I would rather implement my own mapping than having to change media sources for the transitions every time and thus causing a lot of buffering.

@tonihei
Copy link
Collaborator

tonihei commented Apr 21, 2020

This enhancement is unfortunately not on our agenda for now.
#3163 is still planned to be done, but not with a very high priority either.

The idea with jumping to the next source sounds like a good idea, but again depends on an unimplemented feature. #3327 is tracking the pre-buffering of the next item (before the currently playing one is finished buffering). This is an often requested feature and the one most likely to be implemented next (of these 3 features).

Sorry I can't be more helpful, but there doesn't seem to be an option to seamlessly support dynamic ad insertion for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants