Skip to content

Support changing ad break positions #5067

Closed

Activity

  1. tonihei commented on Nov 7, 2018

    @tonihei
    Collaborator

    The midroll position is defined in the data of your ad tag uri (at 15 seconds in the example you provided).

    If your question is related to configure the server to generate these ad tags, that goes beyond what we can answer here. I suppose the server should know the content duration before generating ad tags for it. @andrewlewis may be able to clarify if that's wrong.

    If the problem is that you don't control the content but need to know the duration before constructing the AdsMediaSource, then it's just not possible without loading at least some part of the media. We plan to release a metadata extractor some time soon which helps you with that. Until then, you can just prepare the media without ads in the background and wait until the duration becomes known.

  2. self-assigned this
    on Nov 7, 2018
  3. Romantic-LiXuefeng commented on Nov 7, 2018

    @Romantic-LiXuefeng
    Author

    @tonihei This is my use case:
    Our Ad server and content server is separate, the ad server can't get the content duration advance. the ad server only provide the pre_ad ,mid_ad,post_ad 's url and duration. Where to insert the mid_ad
    is decided by the player. But we can't new the AdPlaybackState if we don't known the mid_ad insert position.
    This is my test code:

    1. I used a FixedAdsLoader that configure the play ads from given URLs known in advance. I just use the C.TIME_UNSET as the mid_ad place holder

    // init the ad playback state with adGroupTimesUs
    adPlaybackState = new AdPlaybackState(0, C.TIME_UNSET);
    // add the uri of the first ad of the pre_ad group
    adPlaybackState = adPlaybackState.withAdUri(0, 0, Uri.parse("www.xxx.com/test.m3u8"));
    // add the uri of the first ad of the mid_ad group
    adPlaybackState = adPlaybackState.withAdUri(1, 0, Uri.parse("https:www.xxx.com/dizzy.mp4"));
    // pass to AdsLoader.EventListener
    updateAdPlaybackState();

    1. prepare the media without ads in the background and wait until the duration becomes known.
    2. when onTimelineChanged() the content duration is known, we update the mid_ad group timeUS.

    Modifying the code like this, we are not sure if it will affect the playback process of the player. Help you give some advice.
    questions:
    If the mid_ad insert position is less than the player buffer position.Will it cause problems?

  4. tonihei commented on Nov 7, 2018

    @tonihei
    Collaborator

    Thanks for the clarification.

    Using C.TIME_UNSET as the ad group position is probably not a good idea because we don't support that in the player. Also, we currently don't support changing the ad position dynamically. However, we are planning to add support for this soon anyway and we can use this issue to track this.

    Besides that, you could try to wrap the content source in a another media source which lets you access the content timeline: new AdsMediaSource(new WrapperSource(contentMediaSource), ...)
    The wrapper source can implemented similar to the deprecated ImaAdsMediaSource but with a custom callback or access method to the timeline of content source. That allows you to wait until the content timeline is ready (but before the final timeline is published) and to create the AdPlaybackState only then.

  5. Romantic-LiXuefeng commented on Nov 8, 2018

    @Romantic-LiXuefeng
    Author

    @tonihei As you said, i custom a wrapper source to container the content media source.

    @OverRide
    public void onSourceInfoRefreshed(MediaSource source, Timeline timeline, Object manifest) {
    Assertions.checkArgument(timeline.getPeriodCount() == 1);
    long durationUs = timeline.getWindow(0,new Timeline.Window()).durationUs;
    if (durationUs != C.TIME_UNSET){
    Log.e(TAG,"the content duration = [" + durationUs + "]");
    refreshSourceInfo(timeline, manifest);
    }else {
    // wait the content duration
    Log.e(TAG,"the content duration has not known");
    }
    }
    #######
    In the callback {onSourceInfoRefreshed}, The HLS format could get the durations when the callback was called, but the mp4 format could get the duration. Is there any way to get the ExtractMediaSource duration ?

  6. tonihei commented on Nov 8, 2018

    @tonihei
    Collaborator

    Is there any way to get the ExtractMediaSource duration?

    Not yet, sorry. This is an enhancement currently tracked by #4727.

  7. changed the title [-]Question: Before the content has been played, I can't get the duration of the content,how to decide the mid ad insert position? [/-] [+]Support changing ad break positions[/+] on Feb 8, 2019
  8. added a commit that references this issue on May 11, 2021
  9. christosts commented on Aug 9, 2021

    @christosts
    Contributor

    Closing issue as it has been marked fixed in 08fb7bd. The commit will be included in release 2.15.0

  10. locked and limited conversation to collaborators on Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions