Java Code Examples for com.google.android.exoplayer2.Player#DISCONTINUITY_REASON_AD_INSERTION

The following examples show how to use com.google.android.exoplayer2.Player#DISCONTINUITY_REASON_AD_INSERTION . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventLogger.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private static String getDiscontinuityReasonString(@Player.DiscontinuityReason int reason) {
  switch (reason) {
    case Player.DISCONTINUITY_REASON_PERIOD_TRANSITION:
      return "PERIOD_TRANSITION";
    case Player.DISCONTINUITY_REASON_SEEK:
      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:
      return "?";
  }
}
 
Example 2
Source File: EventLogger.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private static String getDiscontinuityReasonString(@Player.DiscontinuityReason int reason) {
  switch (reason) {
    case Player.DISCONTINUITY_REASON_PERIOD_TRANSITION:
      return "PERIOD_TRANSITION";
    case Player.DISCONTINUITY_REASON_SEEK:
      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:
      return "?";
  }
}
 
Example 3
Source File: EventLogger.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private static String getDiscontinuityReasonString(@Player.DiscontinuityReason int reason) {
  switch (reason) {
    case Player.DISCONTINUITY_REASON_PERIOD_TRANSITION:
      return "PERIOD_TRANSITION";
    case Player.DISCONTINUITY_REASON_SEEK:
      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:
      return "?";
  }
}
 
Example 4
Source File: EventLogger.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private static String getDiscontinuityReasonString(@Player.DiscontinuityReason int reason) {
  switch (reason) {
    case Player.DISCONTINUITY_REASON_PERIOD_TRANSITION:
      return "PERIOD_TRANSITION";
    case Player.DISCONTINUITY_REASON_SEEK:
      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:
      return "?";
  }
}
 
Example 5
Source File: EventLogger.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private static String getDiscontinuityReasonString(@Player.DiscontinuityReason int reason) {
  switch (reason) {
    case Player.DISCONTINUITY_REASON_PERIOD_TRANSITION:
      return "PERIOD_TRANSITION";
    case Player.DISCONTINUITY_REASON_SEEK:
      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:
      return "?";
  }
}
 
Example 6
Source File: DefaultPlaybackSessionManager.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
public synchronized void handlePositionDiscontinuity(
    EventTime eventTime, @DiscontinuityReason int reason) {
  Assertions.checkNotNull(listener);
  boolean hasAutomaticTransition =
      reason == Player.DISCONTINUITY_REASON_PERIOD_TRANSITION
          || reason == Player.DISCONTINUITY_REASON_AD_INSERTION;
  Iterator<SessionDescriptor> iterator = sessions.values().iterator();
  while (iterator.hasNext()) {
    SessionDescriptor session = iterator.next();
    if (session.isFinishedAtEventTime(eventTime)) {
      iterator.remove();
      if (session.isCreated) {
        boolean isRemovingActiveSession = session.sessionId.equals(activeSessionId);
        boolean isAutomaticTransition = hasAutomaticTransition && isRemovingActiveSession;
        if (isRemovingActiveSession) {
          activeSessionId = null;
        }
        listener.onSessionFinished(eventTime, session.sessionId, isAutomaticTransition);
      }
    }
  }
  SessionDescriptor activeSessionDescriptor =
      getOrAddSession(eventTime.windowIndex, eventTime.mediaPeriodId);
  if (eventTime.mediaPeriodId != null
      && eventTime.mediaPeriodId.isAd()
      && (currentMediaPeriodId == null
          || currentMediaPeriodId.windowSequenceNumber
              != eventTime.mediaPeriodId.windowSequenceNumber
          || currentMediaPeriodId.adGroupIndex != eventTime.mediaPeriodId.adGroupIndex
          || currentMediaPeriodId.adIndexInAdGroup != eventTime.mediaPeriodId.adIndexInAdGroup)) {
    // New ad playback started. Find corresponding content session and notify ad playback started.
    MediaPeriodId contentMediaPeriodId =
        new MediaPeriodId(
            eventTime.mediaPeriodId.periodUid, eventTime.mediaPeriodId.windowSequenceNumber);
    SessionDescriptor contentSession =
        getOrAddSession(eventTime.windowIndex, contentMediaPeriodId);
    if (contentSession.isCreated && activeSessionDescriptor.isCreated) {
      listener.onAdPlaybackStarted(
          eventTime, contentSession.sessionId, activeSessionDescriptor.sessionId);
    }
  }
  updateActiveSession(eventTime, activeSessionDescriptor);
}