com.google.android.exoplayer2.trackselection.TrackSelector Java Examples

The following examples show how to use com.google.android.exoplayer2.trackselection.TrackSelector. 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: ExoPlayerFactory.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * @deprecated Use {@link SimpleExoPlayer.Builder} instead. The {@link DrmSessionManager} cannot
 *     be passed to {@link SimpleExoPlayer.Builder} and should instead be injected into the {@link
 *     MediaSource} factories.
 */
@Deprecated
@SuppressWarnings("deprecation")
public static SimpleExoPlayer newSimpleInstance(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter) {
  return newSimpleInstance(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      new AnalyticsCollector(Clock.DEFAULT),
      Util.getLooper());
}
 
Example #2
Source File: ExoPlayerFactory.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * @deprecated Use {@link SimpleExoPlayer.Builder} instead. The {@link DrmSessionManager} cannot
 *     be passed to {@link SimpleExoPlayer.Builder} and should instead be injected into the {@link
 *     MediaSource} factories.
 */
@Deprecated
@SuppressWarnings("deprecation")
public static SimpleExoPlayer newSimpleInstance(
    Context context,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    @DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode,
    long allowedVideoJoiningTimeMs) {
  RenderersFactory renderersFactory =
      new DefaultRenderersFactory(context)
          .setExtensionRendererMode(extensionRendererMode)
          .setAllowedVideoJoiningTimeMs(allowedVideoJoiningTimeMs);
  return newSimpleInstance(
      context, renderersFactory, trackSelector, loadControl, drmSessionManager);
}
 
Example #3
Source File: ExoPlayerFactory.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that
 *     will collect and forward all player events.
 * @param looper The {@link Looper} which must be used for all calls to the player and which is
 *     used to call listeners on.
 */
public static SimpleExoPlayer newSimpleInstance(
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter,
    AnalyticsCollector.Factory analyticsCollectorFactory,
    Looper looper) {
  return new SimpleExoPlayer(
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      analyticsCollectorFactory,
      looper);
}
 
Example #4
Source File: ExoPlayerFactory.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param context A {@link Context}.
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance.
 */
public static SimpleExoPlayer newSimpleInstance(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter) {
  return newSimpleInstance(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      new AnalyticsCollector.Factory(),
      Util.getLooper());
}
 
Example #5
Source File: ExoPlayerFactory.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance.
 */
public static SimpleExoPlayer newSimpleInstance(
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter) {
  return newSimpleInstance(
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      new AnalyticsCollector.Factory(),
      Util.getLooper());
}
 
Example #6
Source File: ExoPlayerFactory.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param context A {@link Context}.
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that
 *     will collect and forward all player events.
 */
public static SimpleExoPlayer newSimpleInstance(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    AnalyticsCollector.Factory analyticsCollectorFactory) {
  return newSimpleInstance(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      analyticsCollectorFactory,
      Util.getLooper());
}
 
Example #7
Source File: MediaPeriodHolder.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new holder with information required to play it as part of a timeline.
 *
 * @param rendererCapabilities The renderer capabilities.
 * @param rendererPositionOffsetUs The renderer time of the start of the period, in microseconds.
 * @param trackSelector The track selector.
 * @param allocator The allocator.
 * @param mediaSource The media source that produced the media period.
 * @param info Information used to identify this media period in its timeline period.
 */
public MediaPeriodHolder(
    RendererCapabilities[] rendererCapabilities,
    long rendererPositionOffsetUs,
    TrackSelector trackSelector,
    Allocator allocator,
    MediaSource mediaSource,
    MediaPeriodInfo info) {
  this.rendererCapabilities = rendererCapabilities;
  this.rendererPositionOffsetUs = rendererPositionOffsetUs;
  this.trackSelector = trackSelector;
  this.mediaSource = mediaSource;
  this.uid = info.id.periodUid;
  this.info = info;
  sampleStreams = new SampleStream[rendererCapabilities.length];
  mayRetainStreamFlags = new boolean[rendererCapabilities.length];
  mediaPeriod =
      createMediaPeriod(
          info.id, mediaSource, allocator, info.startPositionUs, info.endPositionUs);
}
 
Example #8
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param context A {@link Context}.
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance.
 * @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that
 *     will collect and forward all player events.
 * @param looper The {@link Looper} which must be used for all calls to the player and which is
 *     used to call listeners on.
 */
protected SimpleExoPlayer(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter,
    AnalyticsCollector.Factory analyticsCollectorFactory,
    Looper looper) {
  this(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      analyticsCollectorFactory,
      Clock.DEFAULT,
      looper);
}
 
Example #9
Source File: ExoPlayerFactory.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * @deprecated Use {@link SimpleExoPlayer.Builder} instead. The {@link DrmSessionManager} cannot
 *     be passed to {@link SimpleExoPlayer.Builder} and should instead be injected into the {@link
 *     MediaSource} factories.
 */
@Deprecated
@SuppressWarnings("deprecation")
public static SimpleExoPlayer newSimpleInstance(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    AnalyticsCollector analyticsCollector) {
  return newSimpleInstance(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      analyticsCollector,
      Util.getLooper());
}
 
Example #10
Source File: ExoPlayerFactory.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * @deprecated Use {@link SimpleExoPlayer.Builder} instead. The {@link DrmSessionManager} cannot
 *     be passed to {@link SimpleExoPlayer.Builder} and should instead be injected into the {@link
 *     MediaSource} factories.
 */
@Deprecated
@SuppressWarnings("deprecation")
public static SimpleExoPlayer newSimpleInstance(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    Looper looper) {
  return newSimpleInstance(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      new AnalyticsCollector(Clock.DEFAULT),
      looper);
}
 
Example #11
Source File: ExoPlayerFactory.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param context A {@link Context}.
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance.
 */
public static SimpleExoPlayer newSimpleInstance(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter) {
  return newSimpleInstance(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      new AnalyticsCollector.Factory(),
      Util.getLooper());
}
 
Example #12
Source File: ExoPlayerFactory.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * @deprecated Use {@link SimpleExoPlayer.Builder} instead. The {@link DrmSessionManager} cannot
 *     be passed to {@link SimpleExoPlayer.Builder} and should instead be injected into the {@link
 *     MediaSource} factories.
 */
@SuppressWarnings("deprecation")
@Deprecated
public static SimpleExoPlayer newSimpleInstance(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter,
    AnalyticsCollector analyticsCollector,
    Looper looper) {
  return new SimpleExoPlayer(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      analyticsCollector,
      Clock.DEFAULT,
      looper);
}
 
Example #13
Source File: ExoPlayerFactory.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param context A {@link Context}.
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that
 *     will collect and forward all player events.
 */
public static SimpleExoPlayer newSimpleInstance(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    AnalyticsCollector.Factory analyticsCollectorFactory) {
  return newSimpleInstance(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      analyticsCollectorFactory,
      Util.getLooper());
}
 
Example #14
Source File: ExoPlayerFactory.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that
 *     will collect and forward all player events.
 * @param looper The {@link Looper} which must be used for all calls to the player and which is
 *     used to call listeners on.
 */
public static SimpleExoPlayer newSimpleInstance(
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter,
    AnalyticsCollector.Factory analyticsCollectorFactory,
    Looper looper) {
  return new SimpleExoPlayer(
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      analyticsCollectorFactory,
      looper);
}
 
Example #15
Source File: ExoPlayerFactory.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that
 *     will collect and forward all player events.
 * @param looper The {@link Looper} which must be used for all calls to the player and which is
 *     used to call listeners on.
 */
public static SimpleExoPlayer newSimpleInstance(
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    AnalyticsCollector.Factory analyticsCollectorFactory,
    Looper looper) {
  return newSimpleInstance(
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      getDefaultBandwidthMeter(),
      analyticsCollectorFactory,
      looper);
}
 
Example #16
Source File: SimpleExoPlayer.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * @param context A {@link Context}.
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance.
 * @param analyticsCollector A factory for creating the {@link AnalyticsCollector} that will
 *     collect and forward all player events.
 * @param clock The {@link Clock} that will be used by the instance. Should always be {@link
 *     Clock#DEFAULT}, unless the player is being used from a test.
 * @param looper The {@link Looper} which must be used for all calls to the player and which is
 *     used to call listeners on.
 */
@SuppressWarnings("deprecation")
protected SimpleExoPlayer(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    BandwidthMeter bandwidthMeter,
    AnalyticsCollector analyticsCollector,
    Clock clock,
    Looper looper) {
  this(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      DrmSessionManager.getDummyDrmSessionManager(),
      bandwidthMeter,
      analyticsCollector,
      clock,
      looper);
}
 
Example #17
Source File: ExoPlayerFactory.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param context A {@link Context}.
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param looper The {@link Looper} which must be used for all calls to the player and which is
 *     used to call listeners on.
 */
public static SimpleExoPlayer newSimpleInstance(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    Looper looper) {
  return newSimpleInstance(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      new AnalyticsCollector.Factory(),
      looper);
}
 
Example #18
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param context A {@link Context}.
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param bandwidthMeter The {@link BandwidthMeter} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param looper The {@link Looper} which must be used for all calls to the player and which is
 *     used to call listeners on.
 */
protected SimpleExoPlayer(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    BandwidthMeter bandwidthMeter,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    Looper looper) {
  this(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      new AnalyticsCollector.Factory(),
      looper);
}
 
Example #19
Source File: ExoPlayerFactory.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param context A {@link Context}.
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 */
public static SimpleExoPlayer newSimpleInstance(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl) {
  return newSimpleInstance(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      /* drmSessionManager= */ null,
      Util.getLooper());
}
 
Example #20
Source File: MediaPeriodQueue.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Enqueues a new media period based on the specified information as the new loading media period,
 * and returns it.
 *
 * @param rendererCapabilities The renderer capabilities.
 * @param trackSelector The track selector.
 * @param allocator The allocator.
 * @param mediaSource The media source that produced the media period.
 * @param uid The unique identifier for the containing timeline period.
 * @param info Information used to identify this media period in its timeline period.
 */
public MediaPeriod enqueueNextMediaPeriod(
    RendererCapabilities[] rendererCapabilities,
    TrackSelector trackSelector,
    Allocator allocator,
    MediaSource mediaSource,
    Object uid,
    MediaPeriodInfo info) {
  long rendererPositionOffsetUs =
      loading == null
          ? info.startPositionUs
          : (loading.getRendererOffset() + loading.info.durationUs);
  MediaPeriodHolder newPeriodHolder =
      new MediaPeriodHolder(
          rendererCapabilities,
          rendererPositionOffsetUs,
          trackSelector,
          allocator,
          mediaSource,
          uid,
          info);
  if (loading != null) {
    Assertions.checkState(hasPlayingPeriod());
    loading.next = newPeriodHolder;
  }
  oldFrontPeriodUid = null;
  loading = newPeriodHolder;
  length++;
  return newPeriodHolder.mediaPeriod;
}
 
Example #21
Source File: ExoFFmpegPlayer.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
public ExoFFmpegPlayer(Context context, TrackSelector trackSelector) {

        super(context,
                new SimpleRendersFactory(context),
                trackSelector,
                new DefaultLoadControl(),
                null,
                new DefaultBandwidthMeter.Builder().build(),
                new AnalyticsCollector.Factory(),
                Clock.DEFAULT,
                Util.getLooper());
    }
 
Example #22
Source File: ProviderTvPlayer.java    From xipl with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes and prepares the player but doesn't make it play the content.
 *
 * @param context the context needed to initialize the player.
 */
private void init(Context context) {
    BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
    TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

    player = ExoPlayerFactory.newSimpleInstance(context, trackSelector);
    player.prepare(getMediaSource(context));
}
 
Example #23
Source File: ExoPlayerFactory.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that
 *     will collect and forward all player events.
 */
public static SimpleExoPlayer newSimpleInstance(
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    AnalyticsCollector.Factory analyticsCollectorFactory) {
  return newSimpleInstance(
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      analyticsCollectorFactory,
      Util.getLooper());
}
 
Example #24
Source File: ExoPlayerFactory.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param looper The {@link Looper} which must be used for all calls to the player and which is
 *     used to call listeners on.
 */
public static SimpleExoPlayer newSimpleInstance(
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    Looper looper) {
  return newSimpleInstance(
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      new AnalyticsCollector.Factory(),
      looper);
}
 
Example #25
Source File: ExoPlayerFactory.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 * @param drmSessionManager An optional {@link DrmSessionManager}. May be null if the instance
 *     will not be used for DRM protected playbacks.
 * @param analyticsCollectorFactory A factory for creating the {@link AnalyticsCollector} that
 *     will collect and forward all player events.
 */
public static SimpleExoPlayer newSimpleInstance(
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    AnalyticsCollector.Factory analyticsCollectorFactory) {
  return newSimpleInstance(
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      analyticsCollectorFactory,
      Util.getLooper());
}
 
Example #26
Source File: ExoPlayerFactory.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 */
public static SimpleExoPlayer newSimpleInstance(RenderersFactory renderersFactory,
    TrackSelector trackSelector, LoadControl loadControl) {
  return newSimpleInstance(
      renderersFactory,
      trackSelector,
      loadControl,
      /* drmSessionManager= */ null,
      Util.getLooper());
}
 
Example #27
Source File: MediaPeriodQueue.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Enqueues a new media period holder based on the specified information as the new loading media
 * period, and returns it.
 *
 * @param rendererCapabilities The renderer capabilities.
 * @param trackSelector The track selector.
 * @param allocator The allocator.
 * @param mediaSource The media source that produced the media period.
 * @param info Information used to identify this media period in its timeline period.
 * @param emptyTrackSelectorResult A {@link TrackSelectorResult} with empty selections for each
 *     renderer.
 */
public MediaPeriodHolder enqueueNextMediaPeriodHolder(
    RendererCapabilities[] rendererCapabilities,
    TrackSelector trackSelector,
    Allocator allocator,
    MediaSource mediaSource,
    MediaPeriodInfo info,
    TrackSelectorResult emptyTrackSelectorResult) {
  long rendererPositionOffsetUs =
      loading == null
          ? (info.id.isAd() && info.contentPositionUs != C.TIME_UNSET
              ? info.contentPositionUs
              : 0)
          : (loading.getRendererOffset() + loading.info.durationUs - info.startPositionUs);
  MediaPeriodHolder newPeriodHolder =
      new MediaPeriodHolder(
          rendererCapabilities,
          rendererPositionOffsetUs,
          trackSelector,
          allocator,
          mediaSource,
          info,
          emptyTrackSelectorResult);
  if (loading != null) {
    loading.setNext(newPeriodHolder);
  } else {
    playing = newPeriodHolder;
    reading = newPeriodHolder;
  }
  oldFrontPeriodUid = null;
  loading = newPeriodHolder;
  length++;
  return newPeriodHolder;
}
 
Example #28
Source File: ExoPlayerCreator.java    From no-player with Apache License 2.0 5 votes vote down vote up
@NonNull
public SimpleExoPlayer create(DrmSessionCreator drmSessionCreator,
                              DefaultDrmSessionEventListener drmSessionEventListener,
                              MediaCodecSelector mediaCodecSelector,
                              TrackSelector trackSelector) {
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = drmSessionCreator.create(drmSessionEventListener);
    SubtitleDecoderFactory subtitleDecoderFactory = new NoPlayerSubtitleDecoderFactory();
    RenderersFactory renderersFactory = new SimpleRenderersFactory(
            context,
            EXTENSION_RENDERER_MODE_OFF,
            DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS,
            mediaCodecSelector,
            subtitleDecoderFactory
    );

    DefaultLoadControl loadControl = new DefaultLoadControl();
    return ExoPlayerFactory.newSimpleInstance(context, renderersFactory, trackSelector, loadControl, drmSessionManager);
}
 
Example #29
Source File: ExoPlayerFactory.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link SimpleExoPlayer} instance.
 *
 * @param renderersFactory A factory for creating {@link Renderer}s to be used by the instance.
 * @param trackSelector The {@link TrackSelector} that will be used by the instance.
 * @param loadControl The {@link LoadControl} that will be used by the instance.
 */
public static SimpleExoPlayer newSimpleInstance(RenderersFactory renderersFactory,
    TrackSelector trackSelector, LoadControl loadControl) {
  return newSimpleInstance(
      renderersFactory,
      trackSelector,
      loadControl,
      /* drmSessionManager= */ null,
      Util.getLooper());
}
 
Example #30
Source File: MediaPeriodQueue.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Enqueues a new media period based on the specified information as the new loading media period,
 * and returns it.
 *
 * @param rendererCapabilities The renderer capabilities.
 * @param trackSelector The track selector.
 * @param allocator The allocator.
 * @param mediaSource The media source that produced the media period.
 * @param uid The unique identifier for the containing timeline period.
 * @param info Information used to identify this media period in its timeline period.
 */
public MediaPeriod enqueueNextMediaPeriod(
    RendererCapabilities[] rendererCapabilities,
    TrackSelector trackSelector,
    Allocator allocator,
    MediaSource mediaSource,
    Object uid,
    MediaPeriodInfo info) {
  long rendererPositionOffsetUs =
      loading == null
          ? info.startPositionUs
          : (loading.getRendererOffset() + loading.info.durationUs);
  MediaPeriodHolder newPeriodHolder =
      new MediaPeriodHolder(
          rendererCapabilities,
          rendererPositionOffsetUs,
          trackSelector,
          allocator,
          mediaSource,
          uid,
          info);
  if (loading != null) {
    Assertions.checkState(hasPlayingPeriod());
    loading.next = newPeriodHolder;
  }
  oldFrontPeriodUid = null;
  loading = newPeriodHolder;
  length++;
  return newPeriodHolder.mediaPeriod;
}