Java Code Examples for com.google.android.exoplayer2.Timeline#EMPTY

The following examples show how to use com.google.android.exoplayer2.Timeline#EMPTY . 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: AnalyticsCollector.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/** Updates the queue with a newly created media period. */
public void onMediaPeriodCreated(int windowIndex, MediaPeriodId mediaPeriodId) {
  int periodIndex = timeline.getIndexOfPeriod(mediaPeriodId.periodUid);
  boolean isInTimeline = periodIndex != C.INDEX_UNSET;
  MediaPeriodInfo mediaPeriodInfo =
      new MediaPeriodInfo(
          mediaPeriodId,
          isInTimeline ? timeline : Timeline.EMPTY,
          isInTimeline ? timeline.getPeriod(periodIndex, period).windowIndex : windowIndex);
  mediaPeriodInfoQueue.add(mediaPeriodInfo);
  mediaPeriodIdToInfo.put(mediaPeriodId, mediaPeriodInfo);
  lastPlayingMediaPeriod = mediaPeriodInfoQueue.get(0);
  if (mediaPeriodInfoQueue.size() == 1 && !timeline.isEmpty()) {
    lastReportedPlayingMediaPeriod = lastPlayingMediaPeriod;
  }
}
 
Example 2
Source File: PlaybackStatsListener.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Finishes all pending playback sessions. Should be called when the listener is removed from the
 * player or when the player is released.
 */
public void finishAllSessions() {
  // TODO: Add AnalyticsListener.onAttachedToPlayer and onDetachedFromPlayer to auto-release with
  // an actual EventTime. Should also simplify other cases where the listener needs to be released
  // separately from the player.
  HashMap<String, PlaybackStatsTracker> trackerCopy = new HashMap<>(playbackStatsTrackers);
  EventTime dummyEventTime =
      new EventTime(
          SystemClock.elapsedRealtime(),
          Timeline.EMPTY,
          /* windowIndex= */ 0,
          /* mediaPeriodId= */ null,
          /* eventPlaybackPositionMs= */ 0,
          /* currentPlaybackPositionMs= */ 0,
          /* totalBufferedDurationMs= */ 0);
  for (String session : trackerCopy.keySet()) {
    onSessionFinished(dummyEventTime, session, /* automaticTransition= */ false);
  }
}
 
Example 3
Source File: DefaultPlaybackSessionManager.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/** Creates session manager. */
public DefaultPlaybackSessionManager() {
  window = new Timeline.Window();
  period = new Timeline.Period();
  sessions = new HashMap<>();
  currentTimeline = Timeline.EMPTY;
}
 
Example 4
Source File: AnalyticsCollector.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/** Updates the queue with a newly created media period. */
public void onMediaPeriodCreated(int windowIndex, MediaPeriodId mediaPeriodId) {
  boolean isInTimeline = timeline.getIndexOfPeriod(mediaPeriodId.periodUid) != C.INDEX_UNSET;
  MediaPeriodInfo mediaPeriodInfo =
      new MediaPeriodInfo(mediaPeriodId, isInTimeline ? timeline : Timeline.EMPTY, windowIndex);
  mediaPeriodInfoQueue.add(mediaPeriodInfo);
  mediaPeriodIdToInfo.put(mediaPeriodId, mediaPeriodInfo);
  if (mediaPeriodInfoQueue.size() == 1 && !timeline.isEmpty()) {
    updateLastReportedPlayingMediaPeriod();
  }
}
 
Example 5
Source File: AnalyticsCollector.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/** Updates the queue with a newly created media period. */
public void onMediaPeriodCreated(int windowIndex, MediaPeriodId mediaPeriodId) {
  boolean isInTimeline = timeline.getIndexOfPeriod(mediaPeriodId.periodUid) != C.INDEX_UNSET;
  MediaPeriodInfo mediaPeriodInfo =
      new MediaPeriodInfo(mediaPeriodId, isInTimeline ? timeline : Timeline.EMPTY, windowIndex);
  mediaPeriodInfoQueue.add(mediaPeriodInfo);
  mediaPeriodIdToInfo.put(mediaPeriodId, mediaPeriodInfo);
  if (mediaPeriodInfoQueue.size() == 1 && !timeline.isEmpty()) {
    updateLastReportedPlayingMediaPeriod();
  }
}
 
Example 6
Source File: AnalyticsCollector.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
public MediaPeriodQueueTracker() {
  mediaPeriodInfoQueue = new ArrayList<>();
  mediaPeriodIdToInfo = new HashMap<>();
  period = new Period();
  timeline = Timeline.EMPTY;
}
 
Example 7
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public MediaPeriodQueueTracker() {
  activeMediaPeriods = new ArrayList<>();
  period = new Period();
  timeline = Timeline.EMPTY;
}
 
Example 8
Source File: AnalyticsCollector.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public MediaPeriodQueueTracker() {
  activeMediaPeriods = new ArrayList<>();
  period = new Period();
  timeline = Timeline.EMPTY;
}
 
Example 9
Source File: AnalyticsCollector.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public MediaPeriodQueueTracker() {
  mediaPeriodInfoQueue = new ArrayList<>();
  mediaPeriodIdToInfo = new HashMap<>();
  period = new Period();
  timeline = Timeline.EMPTY;
}
 
Example 10
Source File: AnalyticsCollector.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public MediaPeriodQueueTracker() {
  mediaPeriodInfoQueue = new ArrayList<>();
  mediaPeriodIdToInfo = new HashMap<>();
  period = new Period();
  timeline = Timeline.EMPTY;
}