com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime Java Examples

The following examples show how to use com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime. 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: DefaultPlaybackSessionManager.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void handleTimelineUpdate(EventTime eventTime) {
  Assertions.checkNotNull(listener);
  Timeline previousTimeline = currentTimeline;
  currentTimeline = eventTime.timeline;
  Iterator<SessionDescriptor> iterator = sessions.values().iterator();
  while (iterator.hasNext()) {
    SessionDescriptor session = iterator.next();
    if (!session.tryResolvingToNewTimeline(previousTimeline, currentTimeline)) {
      iterator.remove();
      if (session.isCreated) {
        if (session.sessionId.equals(activeSessionId)) {
          activeSessionId = null;
        }
        listener.onSessionFinished(
            eventTime, session.sessionId, /* automaticTransitionToNextPlayback= */ false);
      }
    }
  }
  handlePositionDiscontinuity(eventTime, Player.DISCONTINUITY_REASON_INTERNAL);
}
 
Example #2
Source File: DefaultPlaybackSessionManager.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void updateSessions(EventTime eventTime) {
  boolean isObviouslyFinished =
      eventTime.mediaPeriodId != null
          && currentMediaPeriodId != null
          && eventTime.mediaPeriodId.windowSequenceNumber
              < currentMediaPeriodId.windowSequenceNumber;
  if (!isObviouslyFinished) {
    SessionDescriptor descriptor =
        getOrAddSession(eventTime.windowIndex, eventTime.mediaPeriodId);
    if (!descriptor.isCreated) {
      descriptor.isCreated = true;
      Assertions.checkNotNull(listener).onSessionCreated(eventTime, descriptor.sessionId);
      if (activeSessionId == null) {
        updateActiveSession(eventTime, descriptor);
      }
    }
  }
}
 
Example #3
Source File: DefaultPlaybackSessionManager.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@RequiresNonNull("listener")
private void updateActiveSession(EventTime eventTime, SessionDescriptor sessionDescriptor) {
  currentMediaPeriodId = eventTime.mediaPeriodId;
  if (sessionDescriptor.isCreated) {
    activeSessionId = sessionDescriptor.sessionId;
    if (!sessionDescriptor.isActive) {
      sessionDescriptor.isActive = true;
      listener.onSessionActive(eventTime, sessionDescriptor.sessionId);
    }
  }
}
 
Example #4
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onLoadError(
    int windowIndex,
    @Nullable MediaPeriodId mediaPeriodId,
    LoadEventInfo loadEventInfo,
    MediaLoadData mediaLoadData,
    IOException error,
    boolean wasCanceled) {
  EventTime eventTime = generateEventTime(windowIndex, mediaPeriodId);
  for (AnalyticsListener listener : listeners) {
    listener.onLoadError(eventTime, loadEventInfo, mediaLoadData, error, wasCanceled);
  }
}
 
Example #5
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onVideoDisabled(DecoderCounters counters) {
  // The renderers are disabled after we changed the playing media period on the playback thread
  // but before this change is reported to the app thread.
  EventTime eventTime = generateLastReportedPlayingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onDecoderDisabled(eventTime, C.TRACK_TYPE_VIDEO, counters);
  }
}
 
Example #6
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
  EventTime eventTime = generatePlayingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onShuffleModeChanged(eventTime, shuffleModeEnabled);
  }
}
 
Example #7
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onAudioInputFormatChanged(Format format) {
  EventTime eventTime = generateReadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onDecoderInputFormatChanged(eventTime, C.TRACK_TYPE_AUDIO, format);
  }
}
 
Example #8
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onAudioSinkUnderrun(
    int bufferSize, long bufferSizeMs, long elapsedSinceLastFeedMs) {
  EventTime eventTime = generateReadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onAudioUnderrun(eventTime, bufferSize, bufferSizeMs, elapsedSinceLastFeedMs);
  }
}
 
Example #9
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onAudioDisabled(DecoderCounters counters) {
  // The renderers are disabled after we changed the playing media period on the playback thread
  // but before this change is reported to the app thread.
  EventTime eventTime = generateLastReportedPlayingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onDecoderDisabled(eventTime, C.TRACK_TYPE_AUDIO, counters);
  }
}
 
Example #10
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onAudioSessionId(int audioSessionId) {
  EventTime eventTime = generateReadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onAudioSessionId(eventTime, audioSessionId);
  }
}
 
Example #11
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onAudioAttributesChanged(AudioAttributes audioAttributes) {
  EventTime eventTime = generateReadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onAudioAttributesChanged(eventTime, audioAttributes);
  }
}
 
Example #12
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onVolumeChanged(float audioVolume) {
  EventTime eventTime = generateReadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onVolumeChanged(eventTime, audioVolume);
  }
}
 
Example #13
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onVideoEnabled(DecoderCounters counters) {
  // The renderers are only enabled after we changed the playing media period.
  EventTime eventTime = generatePlayingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onDecoderEnabled(eventTime, C.TRACK_TYPE_VIDEO, counters);
  }
}
 
Example #14
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onAudioDecoderInitialized(
    String decoderName, long initializedTimestampMs, long initializationDurationMs) {
  EventTime eventTime = generateReadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onDecoderInitialized(
        eventTime, C.TRACK_TYPE_AUDIO, decoderName, initializationDurationMs);
  }
}
 
Example #15
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onBandwidthSample(int elapsedMs, long bytes, long bitrate) {
  EventTime eventTime = generateLoadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onBandwidthEstimate(eventTime, elapsedMs, bytes, bitrate);
  }
}
 
Example #16
Source File: AnalyticsCollector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private EventTime generateMediaPeriodEventTime(
    int windowIndex, @Nullable MediaPeriodId mediaPeriodId) {
  Assertions.checkNotNull(player);
  if (mediaPeriodId != null) {
    MediaPeriodInfo mediaPeriodInfo = mediaPeriodQueueTracker.getMediaPeriodInfo(mediaPeriodId);
    return mediaPeriodInfo != null
        ? generateEventTime(mediaPeriodInfo)
        : generateEventTime(Timeline.EMPTY, windowIndex, mediaPeriodId);
  }
  Timeline timeline = player.getCurrentTimeline();
  boolean windowIsInTimeline = windowIndex < timeline.getWindowCount();
  return generateEventTime(
      windowIsInTimeline ? timeline : Timeline.EMPTY, windowIndex, /* mediaPeriodId= */ null);
}
 
Example #17
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
  EventTime eventTime = generatePlayingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onPlaybackParametersChanged(eventTime, playbackParameters);
  }
}
 
Example #18
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onRenderedFirstFrame(Surface surface) {
  EventTime eventTime = generateReadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onRenderedFirstFrame(eventTime, surface);
  }
}
 
Example #19
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onUpstreamDiscarded(
    int windowIndex, @Nullable MediaPeriodId mediaPeriodId, MediaLoadData mediaLoadData) {
  EventTime eventTime = generateEventTime(windowIndex, mediaPeriodId);
  for (AnalyticsListener listener : listeners) {
    listener.onUpstreamDiscarded(eventTime, mediaLoadData);
  }
}
 
Example #20
Source File: AnalyticsCollector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/** Returns a new {@link EventTime} for the specified timeline, window and media period id. */
@RequiresNonNull("player")
protected EventTime generateEventTime(
    Timeline timeline, int windowIndex, @Nullable MediaPeriodId mediaPeriodId) {
  if (timeline.isEmpty()) {
    // Ensure media period id is only reported together with a valid timeline.
    mediaPeriodId = null;
  }
  long realtimeMs = clock.elapsedRealtime();
  long eventPositionMs;
  boolean isInCurrentWindow =
      timeline == player.getCurrentTimeline() && windowIndex == player.getCurrentWindowIndex();
  if (mediaPeriodId != null && mediaPeriodId.isAd()) {
    boolean isCurrentAd =
        isInCurrentWindow
            && player.getCurrentAdGroupIndex() == mediaPeriodId.adGroupIndex
            && player.getCurrentAdIndexInAdGroup() == mediaPeriodId.adIndexInAdGroup;
    // Assume start position of 0 for future ads.
    eventPositionMs = isCurrentAd ? player.getCurrentPosition() : 0;
  } else if (isInCurrentWindow) {
    eventPositionMs = player.getContentPosition();
  } else {
    // Assume default start position for future content windows. If timeline is not available yet,
    // assume start position of 0.
    eventPositionMs =
        timeline.isEmpty() ? 0 : timeline.getWindow(windowIndex, window).getDefaultPositionMs();
  }
  return new EventTime(
      realtimeMs,
      timeline,
      windowIndex,
      mediaPeriodId,
      eventPositionMs,
      player.getCurrentPosition(),
      player.getTotalBufferedDuration());
}
 
Example #21
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) {
  mediaPeriodQueueTracker.onPositionDiscontinuity(reason);
  EventTime eventTime = generatePlayingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onPositionDiscontinuity(eventTime, reason);
  }
}
 
Example #22
Source File: AnalyticsCollector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public final void onDrmKeysRemoved() {
  EventTime eventTime = generateReadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onDrmKeysRemoved(eventTime);
  }
}
 
Example #23
Source File: AnalyticsCollector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public final void onDrmKeysRestored() {
  EventTime eventTime = generateReadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onDrmKeysRestored(eventTime);
  }
}
 
Example #24
Source File: AnalyticsCollector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public final void onDrmSessionManagerError(Exception error) {
  EventTime eventTime = generateReadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onDrmSessionManagerError(eventTime, error);
  }
}
 
Example #25
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onLoadStarted(
    int windowIndex,
    @Nullable MediaPeriodId mediaPeriodId,
    LoadEventInfo loadEventInfo,
    MediaLoadData mediaLoadData) {
  EventTime eventTime = generateEventTime(windowIndex, mediaPeriodId);
  for (AnalyticsListener listener : listeners) {
    listener.onLoadStarted(eventTime, loadEventInfo, mediaLoadData);
  }
}
 
Example #26
Source File: AnalyticsCollector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Notify analytics collector that a seek operation will start. Should be called before the player
 * adjusts its state and position to the seek.
 */
public final void notifySeekStarted() {
  if (!mediaPeriodQueueTracker.isSeeking()) {
    EventTime eventTime = generatePlayingMediaPeriodEventTime();
    mediaPeriodQueueTracker.onSeekStarted();
    for (AnalyticsListener listener : listeners) {
      listener.onSeekStarted(eventTime);
    }
  }
}
 
Example #27
Source File: AnalyticsCollector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public final void onBandwidthSample(int elapsedMs, long bytes, long bitrate) {
  EventTime eventTime = generateLoadingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onBandwidthEstimate(eventTime, elapsedMs, bytes, bitrate);
  }
}
 
Example #28
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void onLoadingChanged(boolean isLoading) {
  EventTime eventTime = generatePlayingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onLoadingChanged(eventTime, isLoading);
  }
}
 
Example #29
Source File: AnalyticsCollector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public final void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
  EventTime eventTime = generatePlayingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onPlaybackParametersChanged(eventTime, playbackParameters);
  }
}
 
Example #30
Source File: AnalyticsCollector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public final void onPositionDiscontinuity(@Player.DiscontinuityReason int reason) {
  mediaPeriodQueueTracker.onPositionDiscontinuity(reason);
  EventTime eventTime = generatePlayingMediaPeriodEventTime();
  for (AnalyticsListener listener : listeners) {
    listener.onPositionDiscontinuity(eventTime, reason);
  }
}