Add ad insertion discontinuity reason.

This it to distinguish between actual period transitions and the
transitions occuring to and from ads within one timeline period.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=181606023
This commit is contained in:
tonihei 2018-01-11 07:30:25 -08:00 committed by Oliver Woodman
parent 214d46d957
commit f977ba256f
4 changed files with 24 additions and 13 deletions

View file

@ -9,6 +9,10 @@
* Add optional parameter to `stop` to reset the player when stopping.
* Add a reason to `EventListener.onTimelineChanged` to distinguish between
initial preparation, reset and dynamic updates.
* Add `Player.DISCONTINUITY_REASON_AD_INSERTION` to the possible reasons
reported in `Eventlistener.onPositionDiscontinuity` to distinguish
transitions to and from ads within one period from transitions between
periods.
* Replaced `ExoPlayer.sendMessages` with `ExoPlayer.createMessage` to allow
more customization of the message. Now supports setting a message delivery
playback position and/or a delivery handler.

View file

@ -528,6 +528,8 @@ import java.util.Locale;
return "SEEK";
case Player.DISCONTINUITY_REASON_SEEK_ADJUSTMENT:
return "SEEK_ADJUSTMENT";
case Player.DISCONTINUITY_REASON_AD_INSERTION:
return "AD_INSERTION";
case Player.DISCONTINUITY_REASON_INTERNAL:
return "INTERNAL";
default:

View file

@ -1448,11 +1448,15 @@ import java.util.Collections;
// If we advance more than one period at a time, notify listeners after each update.
maybeNotifyPlaybackInfoChanged();
}
int discontinuityReason =
playingPeriodHolder.info.isLastInTimelinePeriod
? Player.DISCONTINUITY_REASON_PERIOD_TRANSITION
: Player.DISCONTINUITY_REASON_AD_INSERTION;
playingPeriodHolder.release();
setPlayingPeriodHolder(playingPeriodHolder.next);
playbackInfo = playbackInfo.fromNewPosition(playingPeriodHolder.info.id,
playingPeriodHolder.info.startPositionUs, playingPeriodHolder.info.contentPositionUs);
playbackInfoUpdate.setPositionDiscontinuity(Player.DISCONTINUITY_REASON_PERIOD_TRANSITION);
playbackInfoUpdate.setPositionDiscontinuity(discontinuityReason);
updatePlaybackPositions();
advancedPlayingPeriod = true;
}

View file

@ -251,31 +251,32 @@ public interface Player {
*/
int REPEAT_MODE_ALL = 2;
/**
* Reasons for position discontinuities.
*/
/** Reasons for position discontinuities. */
@Retention(RetentionPolicy.SOURCE)
@IntDef({DISCONTINUITY_REASON_PERIOD_TRANSITION, DISCONTINUITY_REASON_SEEK,
DISCONTINUITY_REASON_SEEK_ADJUSTMENT, DISCONTINUITY_REASON_INTERNAL})
@IntDef({
DISCONTINUITY_REASON_PERIOD_TRANSITION,
DISCONTINUITY_REASON_SEEK,
DISCONTINUITY_REASON_SEEK_ADJUSTMENT,
DISCONTINUITY_REASON_AD_INSERTION,
DISCONTINUITY_REASON_INTERNAL
})
public @interface DiscontinuityReason {}
/**
* Automatic playback transition from one period in the timeline to the next. The period index may
* be the same as it was before the discontinuity in case the current period is repeated.
*/
int DISCONTINUITY_REASON_PERIOD_TRANSITION = 0;
/**
* Seek within the current period or to another period.
*/
/** Seek within the current period or to another period. */
int DISCONTINUITY_REASON_SEEK = 1;
/**
* Seek adjustment due to being unable to seek to the requested position or because the seek was
* permitted to be inexact.
*/
int DISCONTINUITY_REASON_SEEK_ADJUSTMENT = 2;
/**
* Discontinuity introduced internally by the source.
*/
int DISCONTINUITY_REASON_INTERNAL = 3;
/** Discontinuity to or from an ad within one period in the timeline. */
int DISCONTINUITY_REASON_AD_INSERTION = 3;
/** Discontinuity introduced internally by the source. */
int DISCONTINUITY_REASON_INTERNAL = 4;
/**
* Reasons for timeline and/or manifest changes.