com.google.android.exoplayer2.audio.AudioListener Java Examples

The following examples show how to use com.google.android.exoplayer2.audio.AudioListener. 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 Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onAudioSessionId(int sessionId) {
  if (audioSessionId == sessionId) {
    return;
  }
  audioSessionId = sessionId;
  for (AudioListener audioListener : audioListeners) {
    // Prevent duplicate notification if a listener is both a AudioRendererEventListener and
    // a AudioListener, as they have the same method signature.
    if (!audioDebugListeners.contains(audioListener)) {
      audioListener.onAudioSessionId(sessionId);
    }
  }
  for (AudioRendererEventListener audioDebugListener : audioDebugListeners) {
    audioDebugListener.onAudioSessionId(sessionId);
  }
}
 
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 setVolume(float audioVolume) {
  audioVolume = Util.constrainValue(audioVolume, /* min= */ 0, /* max= */ 1);
  if (this.audioVolume == audioVolume) {
    return;
  }
  this.audioVolume = audioVolume;
  for (Renderer renderer : renderers) {
    if (renderer.getTrackType() == C.TRACK_TYPE_AUDIO) {
      player.createMessage(renderer).setType(C.MSG_SET_VOLUME).setPayload(audioVolume).send();
    }
  }
  for (AudioListener audioListener : audioListeners) {
    audioListener.onVolumeChanged(audioVolume);
  }
}
 
Example #3
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 #4
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onAudioSessionId(int sessionId) {
  if (audioSessionId == sessionId) {
    return;
  }
  audioSessionId = sessionId;
  for (AudioListener audioListener : audioListeners) {
    // Prevent duplicate notification if a listener is both a AudioRendererEventListener and
    // a AudioListener, as they have the same method signature.
    if (!audioDebugListeners.contains(audioListener)) {
      audioListener.onAudioSessionId(sessionId);
    }
  }
  for (AudioRendererEventListener audioDebugListener : audioDebugListeners) {
    audioDebugListener.onAudioSessionId(sessionId);
  }
}
 
Example #5
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 #6
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onAudioSessionId(int sessionId) {
  if (audioSessionId == sessionId) {
    return;
  }
  audioSessionId = sessionId;
  for (AudioListener audioListener : audioListeners) {
    // Prevent duplicate notification if a listener is both a AudioRendererEventListener and
    // a AudioListener, as they have the same method signature.
    if (!audioDebugListeners.contains(audioListener)) {
      audioListener.onAudioSessionId(sessionId);
    }
  }
  for (AudioRendererEventListener audioDebugListener : audioDebugListeners) {
    audioDebugListener.onAudioSessionId(sessionId);
  }
}
 
Example #7
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setVolume(float audioVolume) {
  audioVolume = Util.constrainValue(audioVolume, /* min= */ 0, /* max= */ 1);
  if (this.audioVolume == audioVolume) {
    return;
  }
  this.audioVolume = audioVolume;
  for (Renderer renderer : renderers) {
    if (renderer.getTrackType() == C.TRACK_TYPE_AUDIO) {
      player.createMessage(renderer).setType(C.MSG_SET_VOLUME).setPayload(audioVolume).send();
    }
  }
  for (AudioListener audioListener : audioListeners) {
    audioListener.onVolumeChanged(audioVolume);
  }
}
 
Example #8
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 #9
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onAudioSessionId(int sessionId) {
  if (audioSessionId == sessionId) {
    return;
  }
  audioSessionId = sessionId;
  for (AudioListener audioListener : audioListeners) {
    // Prevent duplicate notification if a listener is both a AudioRendererEventListener and
    // a AudioListener, as they have the same method signature.
    if (!audioDebugListeners.contains(audioListener)) {
      audioListener.onAudioSessionId(sessionId);
    }
  }
  for (AudioRendererEventListener audioDebugListener : audioDebugListeners) {
    audioDebugListener.onAudioSessionId(sessionId);
  }
}
 
Example #10
Source File: SimpleExoPlayer.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public void onAudioSessionId(int sessionId) {
  if (audioSessionId == sessionId) {
    return;
  }
  audioSessionId = sessionId;
  for (AudioListener audioListener : audioListeners) {
    // Prevent duplicate notification if a listener is both a AudioRendererEventListener and
    // a AudioListener, as they have the same method signature.
    if (!audioDebugListeners.contains(audioListener)) {
      audioListener.onAudioSessionId(sessionId);
    }
  }
  for (AudioRendererEventListener audioDebugListener : audioDebugListeners) {
    audioDebugListener.onAudioSessionId(sessionId);
  }
}
 
Example #11
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 #12
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setVolume(float audioVolume) {
  verifyApplicationThread();
  audioVolume = Util.constrainValue(audioVolume, /* min= */ 0, /* max= */ 1);
  if (this.audioVolume == audioVolume) {
    return;
  }
  this.audioVolume = audioVolume;
  sendVolumeToRenderers();
  for (AudioListener audioListener : audioListeners) {
    audioListener.onVolumeChanged(audioVolume);
  }
}
 
Example #13
Source File: SimpleExoPlayer.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public void setVolume(float audioVolume) {
  verifyApplicationThread();
  audioVolume = Util.constrainValue(audioVolume, /* min= */ 0, /* max= */ 1);
  if (this.audioVolume == audioVolume) {
    return;
  }
  this.audioVolume = audioVolume;
  sendVolumeToRenderers();
  for (AudioListener audioListener : audioListeners) {
    audioListener.onVolumeChanged(audioVolume);
  }
}
 
Example #14
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);
}
 
Example #15
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void setVolume(float audioVolume) {
  verifyApplicationThread();
  audioVolume = Util.constrainValue(audioVolume, /* min= */ 0, /* max= */ 1);
  if (this.audioVolume == audioVolume) {
    return;
  }
  this.audioVolume = audioVolume;
  sendVolumeToRenderers();
  for (AudioListener audioListener : audioListeners) {
    audioListener.onVolumeChanged(audioVolume);
  }
}
 
Example #16
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addAudioListener(AudioListener listener) {
  audioListeners.add(listener);
}
 
Example #17
Source File: SimpleExoPlayer.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void removeAudioListener(AudioListener listener) {
  audioListeners.remove(listener);
}
 
Example #18
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void removeAudioListener(AudioListener listener) {
  audioListeners.remove(listener);
}
 
Example #19
Source File: SimpleExoPlayer.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addAudioListener(AudioListener listener) {
  audioListeners.add(listener);
}
 
Example #20
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void removeAudioListener(AudioListener listener) {
  audioListeners.remove(listener);
}
 
Example #21
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addAudioListener(AudioListener listener) {
  audioListeners.add(listener);
}
 
Example #22
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void removeAudioListener(AudioListener listener) {
  audioListeners.remove(listener);
}
 
Example #23
Source File: SimpleExoPlayer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addAudioListener(AudioListener listener) {
  audioListeners.add(listener);
}
 
Example #24
Source File: SimpleExoPlayer.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
public void removeAudioListener(AudioListener listener) {
  audioListeners.remove(listener);
}
 
Example #25
Source File: SimpleExoPlayer.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
public void addAudioListener(AudioListener listener) {
  audioListeners.add(listener);
}
 
Example #26
Source File: Player.java    From MediaSDK with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a listener to receive audio events.
 *
 * @param listener The listener to register.
 */
void addAudioListener(AudioListener listener);
 
Example #27
Source File: Player.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Adds a listener to receive audio events.
 *
 * @param listener The listener to register.
 */
void addAudioListener(AudioListener listener);
 
Example #28
Source File: Player.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Removes a listener of audio events.
 *
 * @param listener The listener to unregister.
 */
void removeAudioListener(AudioListener listener);
 
Example #29
Source File: Player.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Removes a listener of audio events.
 *
 * @param listener The listener to unregister.
 */
void removeAudioListener(AudioListener listener);
 
Example #30
Source File: Player.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Adds a listener to receive audio events.
 *
 * @param listener The listener to register.
 */
void addAudioListener(AudioListener listener);