Java 类com.google.android.exoplayer2.source.MediaPeriod 实例源码

项目:videoPickPlayer    文件:ExoPlayerImplInternal.java   
private void handlePeriodPrepared(MediaPeriod period) throws ExoPlaybackException {
  if (loadingPeriodHolder == null || loadingPeriodHolder.mediaPeriod != period) {
    // Stale event.
    return;
  }
  loadingPeriodHolder.handlePrepared(loadingPeriodHolder.startPositionUs, loadControl);
  if (playingPeriodHolder == null) {
    // This is the first prepared period, so start playing it.
    readingPeriodHolder = loadingPeriodHolder;
    setPlayingPeriodHolder(readingPeriodHolder);
    if (playbackInfo.startPositionUs == C.TIME_UNSET) {
      // Update the playback info when seeking to a default position.
      playbackInfo = new PlaybackInfo(playingPeriodHolder.index,
          playingPeriodHolder.startPositionUs);
      resetRendererPosition(playbackInfo.startPositionUs);
      updatePlaybackPositions();
      eventHandler.obtainMessage(MSG_POSITION_DISCONTINUITY, playbackInfo).sendToTarget();
    }
    updateTimelineState();
  }
  maybeContinueLoading();
}
项目:transistor    文件:ExoPlayerImplInternal.java   
public MediaPeriodHolder(Renderer[] renderers, RendererCapabilities[] rendererCapabilities,
    long rendererPositionOffsetUs, TrackSelector trackSelector, LoadControl loadControl,
    MediaSource mediaSource, Object periodUid, int index, MediaPeriodInfo info) {
  this.renderers = renderers;
  this.rendererCapabilities = rendererCapabilities;
  this.rendererPositionOffsetUs = rendererPositionOffsetUs;
  this.trackSelector = trackSelector;
  this.loadControl = loadControl;
  this.mediaSource = mediaSource;
  this.uid = Assertions.checkNotNull(periodUid);
  this.index = index;
  this.info = info;
  sampleStreams = new SampleStream[renderers.length];
  mayRetainStreamFlags = new boolean[renderers.length];
  MediaPeriod mediaPeriod = mediaSource.createPeriod(info.id, loadControl.getAllocator());
  if (info.endPositionUs != C.TIME_END_OF_SOURCE) {
    ClippingMediaPeriod clippingMediaPeriod = new ClippingMediaPeriod(mediaPeriod, true);
    clippingMediaPeriod.setClipping(0, info.endPositionUs);
    mediaPeriod = clippingMediaPeriod;
  }
  this.mediaPeriod = mediaPeriod;
}
项目:Exoplayer2Radio    文件:ExoPlayerImplInternal.java   
private void handlePeriodPrepared(MediaPeriod period) throws ExoPlaybackException {
  if (loadingPeriodHolder == null || loadingPeriodHolder.mediaPeriod != period) {
    // Stale event.
    return;
  }
  loadingPeriodHolder.handlePrepared();
  if (playingPeriodHolder == null) {
    // This is the first prepared period, so start playing it.
    readingPeriodHolder = loadingPeriodHolder;
    resetRendererPosition(readingPeriodHolder.startPositionUs);
    setPlayingPeriodHolder(readingPeriodHolder);
  }
  maybeContinueLoading();
}
项目:Exoplayer2Radio    文件:ExoPlayerImplInternal.java   
private void handleContinueLoadingRequested(MediaPeriod period) {
  if (loadingPeriodHolder == null || loadingPeriodHolder.mediaPeriod != period) {
    // Stale event.
    return;
  }
  maybeContinueLoading();
}
项目:K-Sonic    文件:ExoPlayerImplInternal.java   
private void handlePeriodPrepared(MediaPeriod period) throws ExoPlaybackException {
  if (loadingPeriodHolder == null || loadingPeriodHolder.mediaPeriod != period) {
    // Stale event.
    return;
  }
  loadingPeriodHolder.handlePrepared();
  if (playingPeriodHolder == null) {
    // This is the first prepared period, so start playing it.
    readingPeriodHolder = loadingPeriodHolder;
    resetRendererPosition(readingPeriodHolder.startPositionUs);
    setPlayingPeriodHolder(readingPeriodHolder);
  }
  maybeContinueLoading();
}
项目:K-Sonic    文件:ExoPlayerImplInternal.java   
private void handleContinueLoadingRequested(MediaPeriod period) {
  if (loadingPeriodHolder == null || loadingPeriodHolder.mediaPeriod != period) {
    // Stale event.
    return;
  }
  maybeContinueLoading();
}
项目:K-Sonic    文件:DashMediaSource.java   
@Override
public MediaPeriod createPeriod(int periodIndex, Allocator allocator, long positionUs) {
  EventDispatcher periodEventDispatcher = eventDispatcher.copyWithMediaTimeOffsetMs(
      manifest.getPeriod(periodIndex).startMs);
  DashMediaPeriod mediaPeriod = new DashMediaPeriod(firstPeriodId + periodIndex, manifest,
      periodIndex, chunkSourceFactory, minLoadableRetryCount, periodEventDispatcher,
      elapsedRealtimeOffsetMs, loaderErrorThrower, allocator);
  periodsById.put(mediaPeriod.id, mediaPeriod);
  return mediaPeriod;
}
项目:K-Sonic    文件:SsMediaSource.java   
@Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) {
  Assertions.checkArgument(index == 0);
  SsMediaPeriod period = new SsMediaPeriod(manifest, chunkSourceFactory, minLoadableRetryCount,
      eventDispatcher, manifestLoaderErrorThrower, allocator);
  mediaPeriods.add(period);
  return period;
}
项目:videoPickPlayer    文件:ExoPlayerImplInternal.java   
public MediaPeriodHolder(Renderer[] renderers, RendererCapabilities[] rendererCapabilities,
    TrackSelector<T> trackSelector, MediaSource mediaSource, MediaPeriod mediaPeriod,
    Object uid, long positionUs) {
  this.renderers = renderers;
  this.rendererCapabilities = rendererCapabilities;
  this.trackSelector = trackSelector;
  this.mediaSource = mediaSource;
  this.mediaPeriod = mediaPeriod;
  this.uid = Assertions.checkNotNull(uid);
  sampleStreams = new SampleStream[renderers.length];
  mayRetainStreamFlags = new boolean[renderers.length];
  startPositionUs = positionUs;
}
项目:videoPickPlayer    文件:DashMediaSource.java   
@Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) {
  DashMediaPeriod mediaPeriod = new DashMediaPeriod(firstPeriodId + index, manifest, index,
      chunkSourceFactory, minLoadableRetryCount, eventDispatcher, elapsedRealtimeOffsetMs, loader,
      allocator);
  periodsById.put(mediaPeriod.id, mediaPeriod);
  return mediaPeriod;
}
项目:videoPickPlayer    文件:SsMediaSource.java   
@Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) {
  Assertions.checkArgument(index == 0);
  SsMediaPeriod period = new SsMediaPeriod(manifest, chunkSourceFactory, minLoadableRetryCount,
      eventDispatcher, manifestLoader, allocator);
  mediaPeriods.add(period);
  return period;
}
项目:transistor    文件:FakeSimpleExoPlayer.java   
@Override
public void onPrepared(MediaPeriod mediaPeriod) {
  try {
    initializePlaybackLoop();
  } catch (ExoPlaybackException e) {
    handlePlayerError(e);
  }
}
项目:transistor    文件:MediaSourceTestRunner.java   
/**
 * Calls {@link MediaSource#createPeriod(MediaSource.MediaPeriodId, Allocator)} on the playback
 * thread, asserting that a non-null {@link MediaPeriod} is returned.
 *
 * @param periodId The id of the period to create.
 * @return The created {@link MediaPeriod}.
 */
public MediaPeriod createPeriod(final MediaPeriodId periodId) {
  final MediaPeriod[] holder = new MediaPeriod[1];
  runOnPlaybackThread(new Runnable() {
    @Override
    public void run() {
      holder[0] = mediaSource.createPeriod(periodId, allocator);
    }
  });
  assertNotNull(holder[0]);
  return holder[0];
}
项目:transistor    文件:MediaSourceTestRunner.java   
/**
 * Calls {@link MediaSource#releasePeriod(MediaPeriod)} on the playback thread.
 *
 * @param mediaPeriod The {@link MediaPeriod} to release.
 */
public void releasePeriod(final MediaPeriod mediaPeriod) {
  runOnPlaybackThread(new Runnable() {
    @Override
    public void run() {
      mediaSource.releasePeriod(mediaPeriod);
    }
  });
}
项目:transistor    文件:MediaSourceTestRunner.java   
private void assertPrepareAndReleasePeriod(MediaPeriodId mediaPeriodId) {
  MediaPeriod mediaPeriod = createPeriod(mediaPeriodId);
  ConditionVariable preparedCondition = preparePeriod(mediaPeriod, 0);
  assertTrue(preparedCondition.block(TIMEOUT_MS));
  // MediaSource is supposed to support multiple calls to createPeriod with the same id without an
  // intervening call to releasePeriod.
  MediaPeriod secondMediaPeriod = createPeriod(mediaPeriodId);
  ConditionVariable secondPreparedCondition = preparePeriod(secondMediaPeriod, 0);
  assertTrue(secondPreparedCondition.block(TIMEOUT_MS));
  // Release the periods.
  releasePeriod(mediaPeriod);
  releasePeriod(secondMediaPeriod);
}
项目:transistor    文件:FakeMediaSource.java   
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator) {
  Assert.assertTrue(preparedSource);
  Assert.assertFalse(releasedSource);
  Assertions.checkIndex(id.periodIndex, 0, timeline.getPeriodCount());
  FakeMediaPeriod mediaPeriod = createFakeMediaPeriod(id, trackGroupArray, allocator);
  activeMediaPeriods.add(mediaPeriod);
  createdMediaPeriods.add(id);
  return mediaPeriod;
}
项目:transistor    文件:FakeMediaSource.java   
@Override
public void releasePeriod(MediaPeriod mediaPeriod) {
  Assert.assertTrue(preparedSource);
  Assert.assertFalse(releasedSource);
  FakeMediaPeriod fakeMediaPeriod = (FakeMediaPeriod) mediaPeriod;
  Assert.assertTrue(activeMediaPeriods.remove(fakeMediaPeriod));
  fakeMediaPeriod.release();
}
项目:transistor    文件:DashMediaSource.java   
@Override
public MediaPeriod createPeriod(MediaPeriodId periodId, Allocator allocator) {
  int periodIndex = periodId.periodIndex;
  EventDispatcher periodEventDispatcher = eventDispatcher.copyWithMediaTimeOffsetMs(
      manifest.getPeriod(periodIndex).startMs);
  DashMediaPeriod mediaPeriod = new DashMediaPeriod(firstPeriodId + periodIndex, manifest,
      periodIndex, chunkSourceFactory, minLoadableRetryCount, periodEventDispatcher,
      elapsedRealtimeOffsetMs, loaderErrorThrower, allocator);
  periodsById.put(mediaPeriod.id, mediaPeriod);
  return mediaPeriod;
}
项目:transistor    文件:ExoPlayerImplInternal.java   
private void handlePeriodPrepared(MediaPeriod period) throws ExoPlaybackException {
  if (loadingPeriodHolder == null || loadingPeriodHolder.mediaPeriod != period) {
    // Stale event.
    return;
  }
  loadingPeriodHolder.handlePrepared();
  if (playingPeriodHolder == null) {
    // This is the first prepared period, so start playing it.
    readingPeriodHolder = loadingPeriodHolder;
    resetRendererPosition(readingPeriodHolder.info.startPositionUs);
    setPlayingPeriodHolder(readingPeriodHolder);
  }
  maybeContinueLoading();
}
项目:transistor    文件:ExoPlayerImplInternal.java   
private void handleContinueLoadingRequested(MediaPeriod period) {
  if (loadingPeriodHolder == null || loadingPeriodHolder.mediaPeriod != period) {
    // Stale event.
    return;
  }
  maybeContinueLoading();
}
项目:transistor    文件:SsMediaSource.java   
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator) {
  Assertions.checkArgument(id.periodIndex == 0);
  SsMediaPeriod period = new SsMediaPeriod(manifest, chunkSourceFactory, minLoadableRetryCount,
      eventDispatcher, manifestLoaderErrorThrower, allocator);
  mediaPeriods.add(period);
  return period;
}
项目:Exoplayer2Radio    文件:HlsMediaSource.java   
@Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) {
  Assertions.checkArgument(index == 0);
  return new HlsMediaPeriod(playlistTracker, dataSourceFactory, minLoadableRetryCount,
      eventDispatcher, allocator, positionUs);
}
项目:Exoplayer2Radio    文件:HlsMediaSource.java   
@Override
public void releasePeriod(MediaPeriod mediaPeriod) {
  ((HlsMediaPeriod) mediaPeriod).release();
}
项目:Exoplayer2Radio    文件:ExoPlayerImplInternal.java   
@Override
public void onPrepared(MediaPeriod source) {
  handler.obtainMessage(MSG_PERIOD_PREPARED, source).sendToTarget();
}
项目:Exoplayer2Radio    文件:ExoPlayerImplInternal.java   
@Override
public void onContinueLoadingRequested(MediaPeriod source) {
  handler.obtainMessage(MSG_SOURCE_CONTINUE_LOADING_REQUESTED, source).sendToTarget();
}
项目:K-Sonic    文件:ExoPlayerImplInternal.java   
@Override
public void onPrepared(MediaPeriod source) {
  handler.obtainMessage(MSG_PERIOD_PREPARED, source).sendToTarget();
}
项目:K-Sonic    文件:ExoPlayerImplInternal.java   
@Override
public void onContinueLoadingRequested(MediaPeriod source) {
  handler.obtainMessage(MSG_SOURCE_CONTINUE_LOADING_REQUESTED, source).sendToTarget();
}
项目:K-Sonic    文件:HlsMediaSource.java   
@Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) {
  Assertions.checkArgument(index == 0);
  return new HlsMediaPeriod(playlistTracker, dataSourceFactory, minLoadableRetryCount,
      eventDispatcher, allocator, positionUs);
}
项目:K-Sonic    文件:HlsMediaSource.java   
@Override
public void releasePeriod(MediaPeriod mediaPeriod) {
  ((HlsMediaPeriod) mediaPeriod).release();
}
项目:K-Sonic    文件:DashMediaSource.java   
@Override
public void releasePeriod(MediaPeriod mediaPeriod) {
  DashMediaPeriod dashMediaPeriod = (DashMediaPeriod) mediaPeriod;
  dashMediaPeriod.release();
  periodsById.remove(dashMediaPeriod.id);
}
项目:K-Sonic    文件:SsMediaSource.java   
@Override
public void releasePeriod(MediaPeriod period) {
  ((SsMediaPeriod) period).release();
  mediaPeriods.remove(period);
}
项目:videoPickPlayer    文件:ExoPlayerImplInternal.java   
@Override
public void onPrepared(MediaPeriod source) {
  handler.obtainMessage(MSG_PERIOD_PREPARED, source).sendToTarget();
}
项目:videoPickPlayer    文件:ExoPlayerImplInternal.java   
@Override
public void onContinueLoadingRequested(MediaPeriod source) {
  handler.obtainMessage(MSG_SOURCE_CONTINUE_LOADING_REQUESTED, source).sendToTarget();
}
项目:videoPickPlayer    文件:ExoPlayerImplInternal.java   
private void handleContinueLoadingRequested(MediaPeriod period) {
  if (loadingPeriodHolder == null || loadingPeriodHolder.mediaPeriod != period) {
    return;
  }
  maybeContinueLoading();
}
项目:videoPickPlayer    文件:HlsMediaSource.java   
@Override
public MediaPeriod createPeriod(int index, Allocator allocator, long positionUs) {
  Assertions.checkArgument(index == 0);
  return new HlsMediaPeriod(manifestUri, dataSourceFactory, minLoadableRetryCount,
      eventDispatcher, sourceListener, allocator, positionUs);
}
项目:videoPickPlayer    文件:HlsMediaSource.java   
@Override
public void releasePeriod(MediaPeriod mediaPeriod) {
  ((HlsMediaPeriod) mediaPeriod).release();
}
项目:videoPickPlayer    文件:DashMediaSource.java   
@Override
public void releasePeriod(MediaPeriod mediaPeriod) {
  DashMediaPeriod dashMediaPeriod = (DashMediaPeriod) mediaPeriod;
  dashMediaPeriod.release();
  periodsById.remove(dashMediaPeriod.id);
}
项目:videoPickPlayer    文件:SsMediaSource.java   
@Override
public void releasePeriod(MediaPeriod period) {
  ((SsMediaPeriod) period).release();
  mediaPeriods.remove(period);
}
项目:transistor    文件:ImaAdsMediaSource.java   
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator) {
  return adsMediaSource.createPeriod(id, allocator);
}
项目:transistor    文件:ImaAdsMediaSource.java   
@Override
public void releasePeriod(MediaPeriod mediaPeriod) {
  adsMediaSource.releasePeriod(mediaPeriod);
}