Java Code Examples for com.google.android.exoplayer2.source.MediaSource#addEventListener()

The following examples show how to use com.google.android.exoplayer2.source.MediaSource#addEventListener() . 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: SimpleExoPlayer.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState) {
  verifyApplicationThread();
  if (this.mediaSource != null) {
    this.mediaSource.removeEventListener(analyticsCollector);
    analyticsCollector.resetForNewMediaSource();
  }
  this.mediaSource = mediaSource;
  mediaSource.addEventListener(eventHandler, analyticsCollector);
  @AudioFocusManager.PlayerCommand
  int playerCommand = audioFocusManager.handlePrepare(getPlayWhenReady());
  updatePlayWhenReady(getPlayWhenReady(), playerCommand);
  player.prepare(mediaSource, resetPosition, resetState);
}
 
Example 2
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState) {
  if (this.mediaSource != mediaSource) {
    if (this.mediaSource != null) {
      this.mediaSource.removeEventListener(analyticsCollector);
      analyticsCollector.resetForNewMediaSource();
    }
    mediaSource.addEventListener(eventHandler, analyticsCollector);
    this.mediaSource = mediaSource;
  }
  player.prepare(mediaSource, resetPosition, resetState);
}
 
Example 3
Source File: ExoPlayerUtils.java    From ARVI with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the {@link MediaSourceEventListener} to the specified {@link MediaSource} only if both
 * the specified {@link Handler} and {@link MediaSourceEventListener} are not null.
 *
 * @param mediaSource the media source
 * @param handler the handler
 * @param listener the listener to be added
 */
public static void addEventListenerIfNonNull(@NonNull MediaSource mediaSource,
                                             @Nullable Handler handler,
                                             @Nullable MediaSourceEventListener listener) {
    Preconditions.nonNull(mediaSource);

    if((handler != null) && (listener != null)) {
        mediaSource.addEventListener(handler, listener);
    }
}
 
Example 4
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState) {
  if (this.mediaSource != mediaSource) {
    if (this.mediaSource != null) {
      this.mediaSource.removeEventListener(analyticsCollector);
      analyticsCollector.resetForNewMediaSource();
    }
    mediaSource.addEventListener(eventHandler, analyticsCollector);
    this.mediaSource = mediaSource;
  }
  player.prepare(mediaSource, resetPosition, resetState);
}
 
Example 5
Source File: ExoMediaPlayer.java    From ExoMedia with Apache License 2.0 5 votes vote down vote up
public void setMediaSource(@Nullable MediaSource source) {
    if (this.mediaSource != null) {
        this.mediaSource.removeEventListener(analyticsCollector);
        analyticsCollector.resetForNewMediaSource();
    }
    if (source != null) {
        source.addEventListener(mainHandler, analyticsCollector);
    }
    this.mediaSource = source;

    prepared = false;
    prepare();
}
 
Example 6
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState) {
  verifyApplicationThread();
  if (this.mediaSource != null) {
    this.mediaSource.removeEventListener(analyticsCollector);
    analyticsCollector.resetForNewMediaSource();
  }
  this.mediaSource = mediaSource;
  mediaSource.addEventListener(eventHandler, analyticsCollector);
  @AudioFocusManager.PlayerCommand
  int playerCommand = audioFocusManager.handlePrepare(getPlayWhenReady());
  updatePlayWhenReady(getPlayWhenReady(), playerCommand);
  player.prepare(mediaSource, resetPosition, resetState);
}
 
Example 7
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState) {
  verifyApplicationThread();
  if (this.mediaSource != null) {
    this.mediaSource.removeEventListener(analyticsCollector);
    analyticsCollector.resetForNewMediaSource();
  }
  this.mediaSource = mediaSource;
  mediaSource.addEventListener(eventHandler, analyticsCollector);
  @AudioFocusManager.PlayerCommand
  int playerCommand = audioFocusManager.handlePrepare(getPlayWhenReady());
  updatePlayWhenReady(getPlayWhenReady(), playerCommand);
  player.prepare(mediaSource, resetPosition, resetState);
}