Java Code Examples for com.google.android.exoplayer2.audio.AudioListener#onAudioAttributesChanged()

The following examples show how to use com.google.android.exoplayer2.audio.AudioListener#onAudioAttributesChanged() . 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 TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setAudioAttributes(AudioAttributes audioAttributes) {
  if (Util.areEqual(this.audioAttributes, audioAttributes)) {
    return;
  }
  this.audioAttributes = audioAttributes;
  for (Renderer renderer : renderers) {
    if (renderer.getTrackType() == C.TRACK_TYPE_AUDIO) {
      player
          .createMessage(renderer)
          .setType(C.MSG_SET_AUDIO_ATTRIBUTES)
          .setPayload(audioAttributes)
          .send();
    }
  }
  for (AudioListener audioListener : audioListeners) {
    audioListener.onAudioAttributesChanged(audioAttributes);
  }
}
 
Example 2
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setAudioAttributes(AudioAttributes audioAttributes) {
  if (Util.areEqual(this.audioAttributes, audioAttributes)) {
    return;
  }
  this.audioAttributes = audioAttributes;
  for (Renderer renderer : renderers) {
    if (renderer.getTrackType() == C.TRACK_TYPE_AUDIO) {
      player
          .createMessage(renderer)
          .setType(C.MSG_SET_AUDIO_ATTRIBUTES)
          .setPayload(audioAttributes)
          .send();
    }
  }
  for (AudioListener audioListener : audioListeners) {
    audioListener.onAudioAttributesChanged(audioAttributes);
  }
}
 
Example 3
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus) {
  verifyApplicationThread();
  if (!Util.areEqual(this.audioAttributes, audioAttributes)) {
    this.audioAttributes = audioAttributes;
    for (Renderer renderer : renderers) {
      if (renderer.getTrackType() == C.TRACK_TYPE_AUDIO) {
        player
            .createMessage(renderer)
            .setType(C.MSG_SET_AUDIO_ATTRIBUTES)
            .setPayload(audioAttributes)
            .send();
      }
    }
    for (AudioListener audioListener : audioListeners) {
      audioListener.onAudioAttributesChanged(audioAttributes);
    }
  }

  @AudioFocusManager.PlayerCommand
  int playerCommand =
      audioFocusManager.setAudioAttributes(
          handleAudioFocus ? audioAttributes : null, getPlayWhenReady(), getPlaybackState());
  updatePlayWhenReady(getPlayWhenReady(), playerCommand);
}
 
Example 4
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus) {
  verifyApplicationThread();
  if (!Util.areEqual(this.audioAttributes, audioAttributes)) {
    this.audioAttributes = audioAttributes;
    for (Renderer renderer : renderers) {
      if (renderer.getTrackType() == C.TRACK_TYPE_AUDIO) {
        player
            .createMessage(renderer)
            .setType(C.MSG_SET_AUDIO_ATTRIBUTES)
            .setPayload(audioAttributes)
            .send();
      }
    }
    for (AudioListener audioListener : audioListeners) {
      audioListener.onAudioAttributesChanged(audioAttributes);
    }
  }

  @AudioFocusManager.PlayerCommand
  int playerCommand =
      audioFocusManager.setAudioAttributes(
          handleAudioFocus ? audioAttributes : null, getPlayWhenReady(), getPlaybackState());
  updatePlayWhenReady(getPlayWhenReady(), playerCommand);
}
 
Example 5
Source File: SimpleExoPlayer.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public void setAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus) {
  verifyApplicationThread();
  if (playerReleased) {
    return;
  }
  if (!Util.areEqual(this.audioAttributes, audioAttributes)) {
    this.audioAttributes = audioAttributes;
    for (Renderer renderer : renderers) {
      if (renderer.getTrackType() == C.TRACK_TYPE_AUDIO) {
        player
            .createMessage(renderer)
            .setType(C.MSG_SET_AUDIO_ATTRIBUTES)
            .setPayload(audioAttributes)
            .send();
      }
    }
    for (AudioListener audioListener : audioListeners) {
      audioListener.onAudioAttributesChanged(audioAttributes);
    }
  }

  @AudioFocusManager.PlayerCommand
  int playerCommand =
      audioFocusManager.setAudioAttributes(
          handleAudioFocus ? audioAttributes : null, getPlayWhenReady(), getPlaybackState());
  updatePlayWhenReady(getPlayWhenReady(), playerCommand);
}