class AudioFocusManager {

  @PlayerCommand
  public int setAudioAttributes(
      @Nullable AudioAttributes audioAttributes, boolean playWhenReady, int playerState) {
    if (!Util.areEqual(this.audioAttributes, audioAttributes)) {
      this.audioAttributes = audioAttributes;
      focusGain = convertAudioAttributesToFocusGain(audioAttributes);

      Assertions.checkArgument(
          focusGain == C.AUDIOFOCUS_GAIN || focusGain == C.AUDIOFOCUS_NONE,
          "Automatic handling of audio focus is only available for USAGE_MEDIA and USAGE_GAME.");
      if (playWhenReady
          && (playerState == Player.STATE_BUFFERING || playerState == Player.STATE_READY)) {
        return requestAudioFocus();
      }
    }

    return playerState == Player.STATE_IDLE
        ? handleIdle(playWhenReady)
        : handlePrepare(playWhenReady);
  }

  public  AudioFocusManager(Context context, PlayerControl playerControl);

}