Java Code Examples for com.google.android.exoplayer2.analytics.AnalyticsCollector#Factory

The following examples show how to use com.google.android.exoplayer2.analytics.AnalyticsCollector#Factory . 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 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 2
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.
 * @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,
    BandwidthMeter bandwidthMeter,
    AnalyticsCollector.Factory analyticsCollectorFactory,
    Looper looper) {
  return new SimpleExoPlayer(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      analyticsCollectorFactory,
      looper);
}
 
Example 3
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.
 * @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,
    AnalyticsCollector.Factory analyticsCollectorFactory,
    Looper looper) {
  return newSimpleInstance(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      getDefaultBandwidthMeter(context),
      analyticsCollectorFactory,
      looper);
}
 
Example 4
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 5
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 6
Source File: SimpleExoPlayer.java    From Telegram-FOSS 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 7
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @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(
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter,
    AnalyticsCollector.Factory analyticsCollectorFactory,
    Looper looper) {
  this(
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      analyticsCollectorFactory,
      Clock.DEFAULT,
      looper);
}
 
Example 8
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @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(
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    BandwidthMeter bandwidthMeter,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    Looper looper) {
  this(
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      new AnalyticsCollector.Factory(),
      looper);
}
 
Example 9
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 10
Source File: SimpleExoPlayer.java    From Telegram-FOSS 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 11
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.
 * @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,
    AnalyticsCollector.Factory analyticsCollectorFactory,
    Looper looper) {
  return newSimpleInstance(
      context,
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      getDefaultBandwidthMeter(context),
      analyticsCollectorFactory,
      looper);
}
 
Example 12
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @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(
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    BandwidthMeter bandwidthMeter,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    Looper looper) {
  this(
      renderersFactory,
      trackSelector,
      loadControl,
      drmSessionManager,
      bandwidthMeter,
      new AnalyticsCollector.Factory(),
      looper);
}
 
Example 13
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 14
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 15
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 16
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 17
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 4 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 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.
 */
protected SimpleExoPlayer(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter,
    AnalyticsCollector.Factory analyticsCollectorFactory,
    Clock clock,
    Looper looper) {
  this.bandwidthMeter = bandwidthMeter;
  componentListener = new ComponentListener();
  videoListeners = new CopyOnWriteArraySet<>();
  audioListeners = new CopyOnWriteArraySet<>();
  textOutputs = new CopyOnWriteArraySet<>();
  metadataOutputs = new CopyOnWriteArraySet<>();
  videoDebugListeners = new CopyOnWriteArraySet<>();
  audioDebugListeners = new CopyOnWriteArraySet<>();
  eventHandler = new Handler(looper);
  renderers =
      renderersFactory.createRenderers(
          eventHandler,
          componentListener,
          componentListener,
          componentListener,
          componentListener,
          drmSessionManager);

  // Set initial values.
  audioVolume = 1;
  audioSessionId = C.AUDIO_SESSION_ID_UNSET;
  audioAttributes = AudioAttributes.DEFAULT;
  videoScalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
  currentCues = Collections.emptyList();

  // Build the player and associated objects.
  player =
      new ExoPlayerImpl(renderers, trackSelector, loadControl, bandwidthMeter, clock, looper);
  analyticsCollector = analyticsCollectorFactory.createAnalyticsCollector(player, clock);
  addListener(analyticsCollector);
  addListener(componentListener);
  videoDebugListeners.add(analyticsCollector);
  videoListeners.add(analyticsCollector);
  audioDebugListeners.add(analyticsCollector);
  audioListeners.add(analyticsCollector);
  addMetadataOutput(analyticsCollector);
  bandwidthMeter.addEventListener(eventHandler, analyticsCollector);
  if (drmSessionManager instanceof DefaultDrmSessionManager) {
    ((DefaultDrmSessionManager) drmSessionManager).addListener(eventHandler, analyticsCollector);
  }
  audioFocusManager = new AudioFocusManager(context, componentListener);
}
 
Example 18
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @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 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.
 */
protected SimpleExoPlayer(
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter,
    AnalyticsCollector.Factory analyticsCollectorFactory,
    Clock clock,
    Looper looper) {
  this.bandwidthMeter = bandwidthMeter;
  componentListener = new ComponentListener();
  videoListeners = new CopyOnWriteArraySet<>();
  audioListeners = new CopyOnWriteArraySet<>();
  textOutputs = new CopyOnWriteArraySet<>();
  metadataOutputs = new CopyOnWriteArraySet<>();
  videoDebugListeners = new CopyOnWriteArraySet<>();
  audioDebugListeners = new CopyOnWriteArraySet<>();
  eventHandler = new Handler(looper);
  renderers =
      renderersFactory.createRenderers(
          eventHandler,
          componentListener,
          componentListener,
          componentListener,
          componentListener,
          drmSessionManager);

  // Set initial values.
  audioVolume = 1;
  audioSessionId = C.AUDIO_SESSION_ID_UNSET;
  audioAttributes = AudioAttributes.DEFAULT;
  videoScalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
  currentCues = Collections.emptyList();

  // Build the player and associated objects.
  player =
      createExoPlayerImpl(renderers, trackSelector, loadControl, bandwidthMeter, clock, looper);
  analyticsCollector = analyticsCollectorFactory.createAnalyticsCollector(player, clock);
  addListener(analyticsCollector);
  videoDebugListeners.add(analyticsCollector);
  videoListeners.add(analyticsCollector);
  audioDebugListeners.add(analyticsCollector);
  audioListeners.add(analyticsCollector);
  addMetadataOutput(analyticsCollector);
  bandwidthMeter.addEventListener(eventHandler, analyticsCollector);
  if (drmSessionManager instanceof DefaultDrmSessionManager) {
    ((DefaultDrmSessionManager) drmSessionManager).addListener(eventHandler, analyticsCollector);
  }
}
 
Example 19
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @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 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.
 */
protected SimpleExoPlayer(
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter,
    AnalyticsCollector.Factory analyticsCollectorFactory,
    Clock clock,
    Looper looper) {
  this.bandwidthMeter = bandwidthMeter;
  componentListener = new ComponentListener();
  videoListeners = new CopyOnWriteArraySet<>();
  audioListeners = new CopyOnWriteArraySet<>();
  textOutputs = new CopyOnWriteArraySet<>();
  metadataOutputs = new CopyOnWriteArraySet<>();
  videoDebugListeners = new CopyOnWriteArraySet<>();
  audioDebugListeners = new CopyOnWriteArraySet<>();
  eventHandler = new Handler(looper);
  renderers =
      renderersFactory.createRenderers(
          eventHandler,
          componentListener,
          componentListener,
          componentListener,
          componentListener,
          drmSessionManager);

  // Set initial values.
  audioVolume = 1;
  audioSessionId = C.AUDIO_SESSION_ID_UNSET;
  audioAttributes = AudioAttributes.DEFAULT;
  videoScalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
  currentCues = Collections.emptyList();

  // Build the player and associated objects.
  player =
      createExoPlayerImpl(renderers, trackSelector, loadControl, bandwidthMeter, clock, looper);
  analyticsCollector = analyticsCollectorFactory.createAnalyticsCollector(player, clock);
  addListener(analyticsCollector);
  videoDebugListeners.add(analyticsCollector);
  videoListeners.add(analyticsCollector);
  audioDebugListeners.add(analyticsCollector);
  audioListeners.add(analyticsCollector);
  addMetadataOutput(analyticsCollector);
  bandwidthMeter.addEventListener(eventHandler, analyticsCollector);
  if (drmSessionManager instanceof DefaultDrmSessionManager) {
    ((DefaultDrmSessionManager) drmSessionManager).addListener(eventHandler, analyticsCollector);
  }
}
 
Example 20
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 4 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 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.
 */
protected SimpleExoPlayer(
    Context context,
    RenderersFactory renderersFactory,
    TrackSelector trackSelector,
    LoadControl loadControl,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    BandwidthMeter bandwidthMeter,
    AnalyticsCollector.Factory analyticsCollectorFactory,
    Clock clock,
    Looper looper) {
  this.bandwidthMeter = bandwidthMeter;
  componentListener = new ComponentListener();
  videoListeners = new CopyOnWriteArraySet<>();
  audioListeners = new CopyOnWriteArraySet<>();
  textOutputs = new CopyOnWriteArraySet<>();
  metadataOutputs = new CopyOnWriteArraySet<>();
  videoDebugListeners = new CopyOnWriteArraySet<>();
  audioDebugListeners = new CopyOnWriteArraySet<>();
  eventHandler = new Handler(looper);
  renderers =
      renderersFactory.createRenderers(
          eventHandler,
          componentListener,
          componentListener,
          componentListener,
          componentListener,
          drmSessionManager);

  // Set initial values.
  audioVolume = 1;
  audioSessionId = C.AUDIO_SESSION_ID_UNSET;
  audioAttributes = AudioAttributes.DEFAULT;
  videoScalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
  currentCues = Collections.emptyList();

  // Build the player and associated objects.
  player =
      new ExoPlayerImpl(renderers, trackSelector, loadControl, bandwidthMeter, clock, looper);
  analyticsCollector = analyticsCollectorFactory.createAnalyticsCollector(player, clock);
  addListener(analyticsCollector);
  addListener(componentListener);
  videoDebugListeners.add(analyticsCollector);
  videoListeners.add(analyticsCollector);
  audioDebugListeners.add(analyticsCollector);
  audioListeners.add(analyticsCollector);
  addMetadataOutput(analyticsCollector);
  bandwidthMeter.addEventListener(eventHandler, analyticsCollector);
  if (drmSessionManager instanceof DefaultDrmSessionManager) {
    ((DefaultDrmSessionManager) drmSessionManager).addListener(eventHandler, analyticsCollector);
  }
  audioFocusManager = new AudioFocusManager(context, componentListener);
}