com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener Java Examples

The following examples show how to use com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener. 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: SsMediaSource.java    From K-Sonic with MIT License 6 votes vote down vote up
private SsMediaSource(SsManifest manifest, Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory, SsManifestParser manifestParser,
    SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount,
    long livePresentationDelayMs, Handler eventHandler,
    AdaptiveMediaSourceEventListener eventListener) {
  Assertions.checkState(manifest == null || !manifest.isLive);
  this.manifest = manifest;
  this.manifestUri = manifestUri == null ? null
      : Util.toLowerInvariant(manifestUri.getLastPathSegment()).equals("manifest") ? manifestUri
          : Uri.withAppendedPath(manifestUri, "Manifest");
  this.manifestDataSourceFactory = manifestDataSourceFactory;
  this.manifestParser = manifestParser;
  this.chunkSourceFactory = chunkSourceFactory;
  this.minLoadableRetryCount = minLoadableRetryCount;
  this.livePresentationDelayMs = livePresentationDelayMs;
  this.eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  mediaPeriods = new ArrayList<>();
}
 
Example #2
Source File: HlsMediaSource.java    From K-Sonic with MIT License 5 votes vote down vote up
public HlsMediaSource(Uri manifestUri, HlsDataSourceFactory dataSourceFactory,
    int minLoadableRetryCount, Handler eventHandler,
    AdaptiveMediaSourceEventListener eventListener) {
  this.manifestUri = manifestUri;
  this.dataSourceFactory = dataSourceFactory;
  this.minLoadableRetryCount = minLoadableRetryCount;
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
}
 
Example #3
Source File: DashMediaSource.java    From K-Sonic with MIT License 5 votes vote down vote up
private DashMediaSource(DashManifest manifest, Uri manifestUri,
    DataSource.Factory manifestDataSourceFactory, DashManifestParser manifestParser,
    DashChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount,
    long livePresentationDelayMs, Handler eventHandler,
    AdaptiveMediaSourceEventListener eventListener) {
  this.manifest = manifest;
  this.manifestUri = manifestUri;
  this.manifestDataSourceFactory = manifestDataSourceFactory;
  this.manifestParser = manifestParser;
  this.chunkSourceFactory = chunkSourceFactory;
  this.minLoadableRetryCount = minLoadableRetryCount;
  this.livePresentationDelayMs = livePresentationDelayMs;
  sideloadedManifest = manifest != null;
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  manifestUriLock = new Object();
  periodsById = new SparseArray<>();
  if (sideloadedManifest) {
    Assertions.checkState(!manifest.dynamic);
    manifestCallback = null;
    refreshManifestRunnable = null;
    simulateManifestRefreshRunnable = null;
  } else {
    manifestCallback = new ManifestCallback();
    refreshManifestRunnable = new Runnable() {
      @Override
      public void run() {
        startLoadingManifest();
      }
    };
    simulateManifestRefreshRunnable = new Runnable() {
      @Override
      public void run() {
        processManifest(false);
      }
    };
  }
}
 
Example #4
Source File: HlsMediaSource.java    From K-Sonic with MIT License 4 votes vote down vote up
public HlsMediaSource(Uri manifestUri, DataSource.Factory dataSourceFactory, Handler eventHandler,
    AdaptiveMediaSourceEventListener eventListener) {
  this(manifestUri, dataSourceFactory, DEFAULT_MIN_LOADABLE_RETRY_COUNT, eventHandler,
      eventListener);
}
 
Example #5
Source File: HlsMediaSource.java    From K-Sonic with MIT License 4 votes vote down vote up
public HlsMediaSource(Uri manifestUri, DataSource.Factory dataSourceFactory,
    int minLoadableRetryCount, Handler eventHandler,
    AdaptiveMediaSourceEventListener eventListener) {
  this(manifestUri, new DefaultHlsDataSourceFactory(dataSourceFactory), minLoadableRetryCount,
      eventHandler, eventListener);
}
 
Example #6
Source File: DashMediaSource.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * Constructs an instance to play a given {@link DashManifest}, which must be static.
 *
 * @param manifest The manifest. {@link DashManifest#dynamic} must be false.
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public DashMediaSource(DashManifest manifest, DashChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount, Handler eventHandler, AdaptiveMediaSourceEventListener
    eventListener) {
  this(manifest, null, null, null, chunkSourceFactory, minLoadableRetryCount,
      DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS, eventHandler, eventListener);
}
 
Example #7
Source File: DashMediaSource.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be dynamic or
 * static.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public DashMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory,
    DashChunkSource.Factory chunkSourceFactory, Handler eventHandler,
    AdaptiveMediaSourceEventListener eventListener) {
  this(manifestUri, manifestDataSourceFactory, chunkSourceFactory,
      DEFAULT_MIN_LOADABLE_RETRY_COUNT, DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS,
      eventHandler, eventListener);
}
 
Example #8
Source File: DashMediaSource.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be dynamic or
 * static.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param livePresentationDelayMs For live playbacks, the duration in milliseconds by which the
 *     default start position should precede the end of the live window. Use
 *     {@link #DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS} to use the value specified by
 *     the manifest, if present.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public DashMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory,
    DashChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount,
    long livePresentationDelayMs, Handler eventHandler,
    AdaptiveMediaSourceEventListener eventListener) {
  this(manifestUri, manifestDataSourceFactory, new DashManifestParser(), chunkSourceFactory,
      minLoadableRetryCount, livePresentationDelayMs, eventHandler, eventListener);
}
 
Example #9
Source File: DashMediaSource.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be dynamic or
 * static.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param manifestParser A parser for loaded manifest data.
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param livePresentationDelayMs For live playbacks, the duration in milliseconds by which the
 *     default start position should precede the end of the live window. Use
 *     {@link #DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS} to use the value specified by
 *     the manifest, if present.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public DashMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory,
    DashManifestParser manifestParser, DashChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount, long livePresentationDelayMs, Handler eventHandler,
    AdaptiveMediaSourceEventListener eventListener) {
  this(null, manifestUri, manifestDataSourceFactory, manifestParser, chunkSourceFactory,
      minLoadableRetryCount, livePresentationDelayMs, eventHandler, eventListener);
}
 
Example #10
Source File: SsMediaSource.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * Constructs an instance to play a given {@link SsManifest}, which must not be live.
 *
 * @param manifest The manifest. {@link SsManifest#isLive} must be false.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public SsMediaSource(SsManifest manifest, SsChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount, Handler eventHandler,
    AdaptiveMediaSourceEventListener eventListener) {
  this(manifest, null, null, null, chunkSourceFactory, minLoadableRetryCount,
      DEFAULT_LIVE_PRESENTATION_DELAY_MS, eventHandler, eventListener);
}
 
Example #11
Source File: SsMediaSource.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be live or
 * on-demand.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory,
    SsChunkSource.Factory chunkSourceFactory, Handler eventHandler,
    AdaptiveMediaSourceEventListener eventListener) {
  this(manifestUri, manifestDataSourceFactory, chunkSourceFactory,
      DEFAULT_MIN_LOADABLE_RETRY_COUNT, DEFAULT_LIVE_PRESENTATION_DELAY_MS, eventHandler,
      eventListener);
}
 
Example #12
Source File: SsMediaSource.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be live or
 * on-demand.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param livePresentationDelayMs For live playbacks, the duration in milliseconds by which the
 *     default start position should precede the end of the live window.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory,
    SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount,
    long livePresentationDelayMs, Handler eventHandler,
    AdaptiveMediaSourceEventListener eventListener) {
  this(manifestUri, manifestDataSourceFactory, new SsManifestParser(), chunkSourceFactory,
      minLoadableRetryCount, livePresentationDelayMs, eventHandler, eventListener);
}
 
Example #13
Source File: SsMediaSource.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * Constructs an instance to play the manifest at a given {@link Uri}, which may be live or
 * on-demand.
 *
 * @param manifestUri The manifest {@link Uri}.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest.
 * @param manifestParser A parser for loaded manifest data.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param minLoadableRetryCount The minimum number of times to retry if a loading error occurs.
 * @param livePresentationDelayMs For live playbacks, the duration in milliseconds by which the
 *     default start position should precede the end of the live window.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory,
    SsManifestParser manifestParser, SsChunkSource.Factory chunkSourceFactory,
    int minLoadableRetryCount, long livePresentationDelayMs, Handler eventHandler,
    AdaptiveMediaSourceEventListener eventListener) {
  this(null, manifestUri, manifestDataSourceFactory, manifestParser, chunkSourceFactory,
      minLoadableRetryCount, livePresentationDelayMs, eventHandler, eventListener);
}
 
Example #14
Source File: DashMediaSource.java    From K-Sonic with MIT License 2 votes vote down vote up
/**
 * Constructs an instance to play a given {@link DashManifest}, which must be static.
 *
 * @param manifest The manifest. {@link DashManifest#dynamic} must be false.
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public DashMediaSource(DashManifest manifest, DashChunkSource.Factory chunkSourceFactory,
    Handler eventHandler, AdaptiveMediaSourceEventListener eventListener) {
  this(manifest, chunkSourceFactory, DEFAULT_MIN_LOADABLE_RETRY_COUNT, eventHandler,
      eventListener);
}
 
Example #15
Source File: SsMediaSource.java    From K-Sonic with MIT License 2 votes vote down vote up
/**
 * Constructs an instance to play a given {@link SsManifest}, which must not be live.
 *
 * @param manifest The manifest. {@link SsManifest#isLive} must be false.
 * @param chunkSourceFactory A factory for {@link SsChunkSource} instances.
 * @param eventHandler A handler for events. May be null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 */
public SsMediaSource(SsManifest manifest, SsChunkSource.Factory chunkSourceFactory,
    Handler eventHandler, AdaptiveMediaSourceEventListener eventListener) {
  this(manifest, chunkSourceFactory, DEFAULT_MIN_LOADABLE_RETRY_COUNT,
      eventHandler, eventListener);
}