Java Code Examples for com.google.android.exoplayer2.trackselection.TrackSelector#init()

The following examples show how to use com.google.android.exoplayer2.trackselection.TrackSelector#init() . 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: ExoPlayerImplInternal.java    From K-Sonic with MIT License 5 votes vote down vote up
public ExoPlayerImplInternal(Renderer[] renderers, TrackSelector trackSelector,
    LoadControl loadControl, boolean playWhenReady, Handler eventHandler,
    PlaybackInfo playbackInfo, ExoPlayer player) {
  this.renderers = renderers;
  this.trackSelector = trackSelector;
  this.loadControl = loadControl;
  this.playWhenReady = playWhenReady;
  this.eventHandler = eventHandler;
  this.state = ExoPlayer.STATE_IDLE;
  this.playbackInfo = playbackInfo;
  this.player = player;

  rendererCapabilities = new RendererCapabilities[renderers.length];
  for (int i = 0; i < renderers.length; i++) {
    renderers[i].setIndex(i);
    rendererCapabilities[i] = renderers[i].getCapabilities();
  }
  standaloneMediaClock = new StandaloneMediaClock();
  enabledRenderers = new Renderer[0];
  window = new Timeline.Window();
  period = new Timeline.Period();
  trackSelector.init(this);

  // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can
  // not normally change to this priority" is incorrect.
  internalPlaybackThread = new PriorityHandlerThread("ExoPlayerImplInternal:Handler",
      Process.THREAD_PRIORITY_AUDIO);
  internalPlaybackThread.start();
  handler = new Handler(internalPlaybackThread.getLooper(), this);
}
 
Example 2
Source File: ExoPlayerImplInternal.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
public ExoPlayerImplInternal(
    Renderer[] renderers,
    TrackSelector trackSelector,
    TrackSelectorResult emptyTrackSelectorResult,
    LoadControl loadControl,
    BandwidthMeter bandwidthMeter,
    boolean playWhenReady,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled,
    Handler eventHandler,
    Clock clock) {
  this.renderers = renderers;
  this.trackSelector = trackSelector;
  this.emptyTrackSelectorResult = emptyTrackSelectorResult;
  this.loadControl = loadControl;
  this.bandwidthMeter = bandwidthMeter;
  this.playWhenReady = playWhenReady;
  this.repeatMode = repeatMode;
  this.shuffleModeEnabled = shuffleModeEnabled;
  this.eventHandler = eventHandler;
  this.clock = clock;
  this.queue = new MediaPeriodQueue();

  backBufferDurationUs = loadControl.getBackBufferDurationUs();
  retainBackBufferFromKeyframe = loadControl.retainBackBufferFromKeyframe();

  seekParameters = SeekParameters.DEFAULT;
  playbackInfo =
      PlaybackInfo.createDummy(/* startPositionUs= */ C.TIME_UNSET, emptyTrackSelectorResult);
  playbackInfoUpdate = new PlaybackInfoUpdate();
  rendererCapabilities = new RendererCapabilities[renderers.length];
  for (int i = 0; i < renderers.length; i++) {
    renderers[i].setIndex(i);
    rendererCapabilities[i] = renderers[i].getCapabilities();
  }
  mediaClock = new DefaultMediaClock(this, clock);
  pendingMessages = new ArrayList<>();
  enabledRenderers = new Renderer[0];
  window = new Timeline.Window();
  period = new Timeline.Period();
  trackSelector.init(/* listener= */ this, bandwidthMeter);

  // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can
  // not normally change to this priority" is incorrect.
  internalPlaybackThread =
      new HandlerThread("ExoPlayerImplInternal:Handler", Process.THREAD_PRIORITY_AUDIO);
  internalPlaybackThread.start();
  handler = clock.createHandler(internalPlaybackThread.getLooper(), this);
  deliverPendingMessageAtStartPositionRequired = true;
}
 
Example 3
Source File: ExoPlayerImplInternal.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public ExoPlayerImplInternal(
    Renderer[] renderers,
    TrackSelector trackSelector,
    TrackSelectorResult emptyTrackSelectorResult,
    LoadControl loadControl,
    BandwidthMeter bandwidthMeter,
    boolean playWhenReady,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled,
    Handler eventHandler,
    ExoPlayer player,
    Clock clock) {
  this.renderers = renderers;
  this.trackSelector = trackSelector;
  this.emptyTrackSelectorResult = emptyTrackSelectorResult;
  this.loadControl = loadControl;
  this.bandwidthMeter = bandwidthMeter;
  this.playWhenReady = playWhenReady;
  this.repeatMode = repeatMode;
  this.shuffleModeEnabled = shuffleModeEnabled;
  this.eventHandler = eventHandler;
  this.player = player;
  this.clock = clock;
  this.queue = new MediaPeriodQueue();

  backBufferDurationUs = loadControl.getBackBufferDurationUs();
  retainBackBufferFromKeyframe = loadControl.retainBackBufferFromKeyframe();

  seekParameters = SeekParameters.DEFAULT;
  playbackInfo =
      PlaybackInfo.createDummy(/* startPositionUs= */ C.TIME_UNSET, emptyTrackSelectorResult);
  playbackInfoUpdate = new PlaybackInfoUpdate();
  rendererCapabilities = new RendererCapabilities[renderers.length];
  for (int i = 0; i < renderers.length; i++) {
    renderers[i].setIndex(i);
    rendererCapabilities[i] = renderers[i].getCapabilities();
  }
  mediaClock = new DefaultMediaClock(this, clock);
  pendingMessages = new ArrayList<>();
  enabledRenderers = new Renderer[0];
  window = new Timeline.Window();
  period = new Timeline.Period();
  trackSelector.init(/* listener= */ this, bandwidthMeter);

  // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can
  // not normally change to this priority" is incorrect.
  internalPlaybackThread = new HandlerThread("ExoPlayerImplInternal:Handler",
      Process.THREAD_PRIORITY_AUDIO);
  internalPlaybackThread.start();
  handler = clock.createHandler(internalPlaybackThread.getLooper(), this);
}
 
Example 4
Source File: ExoPlayerImplInternal.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public ExoPlayerImplInternal(
    Renderer[] renderers,
    TrackSelector trackSelector,
    TrackSelectorResult emptyTrackSelectorResult,
    LoadControl loadControl,
    BandwidthMeter bandwidthMeter,
    boolean playWhenReady,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled,
    Handler eventHandler,
    ExoPlayer player,
    Clock clock) {
  this.renderers = renderers;
  this.trackSelector = trackSelector;
  this.emptyTrackSelectorResult = emptyTrackSelectorResult;
  this.loadControl = loadControl;
  this.bandwidthMeter = bandwidthMeter;
  this.playWhenReady = playWhenReady;
  this.repeatMode = repeatMode;
  this.shuffleModeEnabled = shuffleModeEnabled;
  this.eventHandler = eventHandler;
  this.player = player;
  this.clock = clock;
  this.queue = new MediaPeriodQueue();

  backBufferDurationUs = loadControl.getBackBufferDurationUs();
  retainBackBufferFromKeyframe = loadControl.retainBackBufferFromKeyframe();

  seekParameters = SeekParameters.DEFAULT;
  playbackInfo =
      PlaybackInfo.createDummy(/* startPositionUs= */ C.TIME_UNSET, emptyTrackSelectorResult);
  playbackInfoUpdate = new PlaybackInfoUpdate();
  rendererCapabilities = new RendererCapabilities[renderers.length];
  for (int i = 0; i < renderers.length; i++) {
    renderers[i].setIndex(i);
    rendererCapabilities[i] = renderers[i].getCapabilities();
  }
  mediaClock = new DefaultMediaClock(this, clock);
  pendingMessages = new ArrayList<>();
  enabledRenderers = new Renderer[0];
  window = new Timeline.Window();
  period = new Timeline.Period();
  trackSelector.init(/* listener= */ this, bandwidthMeter);

  // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can
  // not normally change to this priority" is incorrect.
  internalPlaybackThread = new HandlerThread("ExoPlayerImplInternal:Handler",
      Process.THREAD_PRIORITY_AUDIO);
  internalPlaybackThread.start();
  handler = clock.createHandler(internalPlaybackThread.getLooper(), this);
}
 
Example 5
Source File: ExoPlayerImplInternal.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public ExoPlayerImplInternal(
    Renderer[] renderers,
    TrackSelector trackSelector,
    TrackSelectorResult emptyTrackSelectorResult,
    LoadControl loadControl,
    BandwidthMeter bandwidthMeter,
    boolean playWhenReady,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled,
    Handler eventHandler,
    Clock clock) {
  this.renderers = renderers;
  this.trackSelector = trackSelector;
  this.emptyTrackSelectorResult = emptyTrackSelectorResult;
  this.loadControl = loadControl;
  this.bandwidthMeter = bandwidthMeter;
  this.playWhenReady = playWhenReady;
  this.repeatMode = repeatMode;
  this.shuffleModeEnabled = shuffleModeEnabled;
  this.eventHandler = eventHandler;
  this.clock = clock;
  this.queue = new MediaPeriodQueue();

  backBufferDurationUs = loadControl.getBackBufferDurationUs();
  retainBackBufferFromKeyframe = loadControl.retainBackBufferFromKeyframe();

  seekParameters = SeekParameters.DEFAULT;
  playbackInfo =
      PlaybackInfo.createDummy(/* startPositionUs= */ C.TIME_UNSET, emptyTrackSelectorResult);
  playbackInfoUpdate = new PlaybackInfoUpdate();
  rendererCapabilities = new RendererCapabilities[renderers.length];
  for (int i = 0; i < renderers.length; i++) {
    renderers[i].setIndex(i);
    rendererCapabilities[i] = renderers[i].getCapabilities();
  }
  mediaClock = new DefaultMediaClock(this, clock);
  pendingMessages = new ArrayList<>();
  enabledRenderers = new Renderer[0];
  window = new Timeline.Window();
  period = new Timeline.Period();
  trackSelector.init(/* listener= */ this, bandwidthMeter);

  // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can
  // not normally change to this priority" is incorrect.
  internalPlaybackThread = new HandlerThread("ExoPlayerImplInternal:Handler",
      Process.THREAD_PRIORITY_AUDIO);
  internalPlaybackThread.start();
  handler = clock.createHandler(internalPlaybackThread.getLooper(), this);
}
 
Example 6
Source File: ExoPlayerImplInternal.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public ExoPlayerImplInternal(
    Renderer[] renderers,
    TrackSelector trackSelector,
    TrackSelectorResult emptyTrackSelectorResult,
    LoadControl loadControl,
    BandwidthMeter bandwidthMeter,
    boolean playWhenReady,
    @Player.RepeatMode int repeatMode,
    boolean shuffleModeEnabled,
    Handler eventHandler,
    Clock clock) {
  this.renderers = renderers;
  this.trackSelector = trackSelector;
  this.emptyTrackSelectorResult = emptyTrackSelectorResult;
  this.loadControl = loadControl;
  this.bandwidthMeter = bandwidthMeter;
  this.playWhenReady = playWhenReady;
  this.repeatMode = repeatMode;
  this.shuffleModeEnabled = shuffleModeEnabled;
  this.eventHandler = eventHandler;
  this.clock = clock;
  this.queue = new MediaPeriodQueue();

  backBufferDurationUs = loadControl.getBackBufferDurationUs();
  retainBackBufferFromKeyframe = loadControl.retainBackBufferFromKeyframe();

  seekParameters = SeekParameters.DEFAULT;
  playbackInfo =
      PlaybackInfo.createDummy(/* startPositionUs= */ C.TIME_UNSET, emptyTrackSelectorResult);
  playbackInfoUpdate = new PlaybackInfoUpdate();
  rendererCapabilities = new RendererCapabilities[renderers.length];
  for (int i = 0; i < renderers.length; i++) {
    renderers[i].setIndex(i);
    rendererCapabilities[i] = renderers[i].getCapabilities();
  }
  mediaClock = new DefaultMediaClock(this, clock);
  pendingMessages = new ArrayList<>();
  enabledRenderers = new Renderer[0];
  window = new Timeline.Window();
  period = new Timeline.Period();
  trackSelector.init(/* listener= */ this, bandwidthMeter);

  // Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can
  // not normally change to this priority" is incorrect.
  internalPlaybackThread = new HandlerThread("ExoPlayerImplInternal:Handler",
      Process.THREAD_PRIORITY_AUDIO);
  internalPlaybackThread.start();
  handler = clock.createHandler(internalPlaybackThread.getLooper(), this);
}