Java Code Examples for com.google.android.exoplayer2.C#AudioUsage

The following examples show how to use com.google.android.exoplayer2.C#AudioUsage . 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: Util.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the {@link C.AudioUsage} corresponding to the specified {@link C.StreamType}.
 */
@C.AudioUsage
public static int getAudioUsageForStreamType(@C.StreamType int streamType) {
  switch (streamType) {
    case C.STREAM_TYPE_ALARM:
      return C.USAGE_ALARM;
    case C.STREAM_TYPE_DTMF:
      return C.USAGE_VOICE_COMMUNICATION_SIGNALLING;
    case C.STREAM_TYPE_NOTIFICATION:
      return C.USAGE_NOTIFICATION;
    case C.STREAM_TYPE_RING:
      return C.USAGE_NOTIFICATION_RINGTONE;
    case C.STREAM_TYPE_SYSTEM:
      return C.USAGE_ASSISTANCE_SONIFICATION;
    case C.STREAM_TYPE_VOICE_CALL:
      return C.USAGE_VOICE_COMMUNICATION;
    case C.STREAM_TYPE_USE_DEFAULT:
    case C.STREAM_TYPE_MUSIC:
    default:
      return C.USAGE_MEDIA;
  }
}
 
Example 2
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C.AudioUsage} corresponding to the specified {@link C.StreamType}.
 */
@C.AudioUsage
public static int getAudioUsageForStreamType(@C.StreamType int streamType) {
  switch (streamType) {
    case C.STREAM_TYPE_ALARM:
      return C.USAGE_ALARM;
    case C.STREAM_TYPE_DTMF:
      return C.USAGE_VOICE_COMMUNICATION_SIGNALLING;
    case C.STREAM_TYPE_NOTIFICATION:
      return C.USAGE_NOTIFICATION;
    case C.STREAM_TYPE_RING:
      return C.USAGE_NOTIFICATION_RINGTONE;
    case C.STREAM_TYPE_SYSTEM:
      return C.USAGE_ASSISTANCE_SONIFICATION;
    case C.STREAM_TYPE_VOICE_CALL:
      return C.USAGE_VOICE_COMMUNICATION;
    case C.STREAM_TYPE_USE_DEFAULT:
    case C.STREAM_TYPE_MUSIC:
    default:
      return C.USAGE_MEDIA;
  }
}
 
Example 3
Source File: Util.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C.AudioUsage} corresponding to the specified {@link C.StreamType}.
 */
@C.AudioUsage
public static int getAudioUsageForStreamType(@C.StreamType int streamType) {
  switch (streamType) {
    case C.STREAM_TYPE_ALARM:
      return C.USAGE_ALARM;
    case C.STREAM_TYPE_DTMF:
      return C.USAGE_VOICE_COMMUNICATION_SIGNALLING;
    case C.STREAM_TYPE_NOTIFICATION:
      return C.USAGE_NOTIFICATION;
    case C.STREAM_TYPE_RING:
      return C.USAGE_NOTIFICATION_RINGTONE;
    case C.STREAM_TYPE_SYSTEM:
      return C.USAGE_ASSISTANCE_SONIFICATION;
    case C.STREAM_TYPE_VOICE_CALL:
      return C.USAGE_VOICE_COMMUNICATION;
    case C.STREAM_TYPE_USE_DEFAULT:
    case C.STREAM_TYPE_MUSIC:
    default:
      return C.USAGE_MEDIA;
  }
}
 
Example 4
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C.AudioUsage} corresponding to the specified {@link C.StreamType}.
 */
@C.AudioUsage
public static int getAudioUsageForStreamType(@C.StreamType int streamType) {
  switch (streamType) {
    case C.STREAM_TYPE_ALARM:
      return C.USAGE_ALARM;
    case C.STREAM_TYPE_DTMF:
      return C.USAGE_VOICE_COMMUNICATION_SIGNALLING;
    case C.STREAM_TYPE_NOTIFICATION:
      return C.USAGE_NOTIFICATION;
    case C.STREAM_TYPE_RING:
      return C.USAGE_NOTIFICATION_RINGTONE;
    case C.STREAM_TYPE_SYSTEM:
      return C.USAGE_ASSISTANCE_SONIFICATION;
    case C.STREAM_TYPE_VOICE_CALL:
      return C.USAGE_VOICE_COMMUNICATION;
    case C.STREAM_TYPE_USE_DEFAULT:
    case C.STREAM_TYPE_MUSIC:
    default:
      return C.USAGE_MEDIA;
  }
}
 
Example 5
Source File: Util.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C.AudioUsage} corresponding to the specified {@link C.StreamType}.
 */
@C.AudioUsage
public static int getAudioUsageForStreamType(@C.StreamType int streamType) {
  switch (streamType) {
    case C.STREAM_TYPE_ALARM:
      return C.USAGE_ALARM;
    case C.STREAM_TYPE_DTMF:
      return C.USAGE_VOICE_COMMUNICATION_SIGNALLING;
    case C.STREAM_TYPE_NOTIFICATION:
      return C.USAGE_NOTIFICATION;
    case C.STREAM_TYPE_RING:
      return C.USAGE_NOTIFICATION_RINGTONE;
    case C.STREAM_TYPE_SYSTEM:
      return C.USAGE_ASSISTANCE_SONIFICATION;
    case C.STREAM_TYPE_VOICE_CALL:
      return C.USAGE_VOICE_COMMUNICATION;
    case C.STREAM_TYPE_USE_DEFAULT:
    case C.STREAM_TYPE_MUSIC:
    default:
      return C.USAGE_MEDIA;
  }
}
 
Example 6
Source File: Util.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the {@link C.StreamType} corresponding to the specified {@link C.AudioUsage}.
 */
@C.StreamType
public static int getStreamTypeForAudioUsage(@C.AudioUsage int usage) {
  switch (usage) {
    case C.USAGE_MEDIA:
    case C.USAGE_GAME:
    case C.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
      return C.STREAM_TYPE_MUSIC;
    case C.USAGE_ASSISTANCE_SONIFICATION:
      return C.STREAM_TYPE_SYSTEM;
    case C.USAGE_VOICE_COMMUNICATION:
      return C.STREAM_TYPE_VOICE_CALL;
    case C.USAGE_VOICE_COMMUNICATION_SIGNALLING:
      return C.STREAM_TYPE_DTMF;
    case C.USAGE_ALARM:
      return C.STREAM_TYPE_ALARM;
    case C.USAGE_NOTIFICATION_RINGTONE:
      return C.STREAM_TYPE_RING;
    case C.USAGE_NOTIFICATION:
    case C.USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
    case C.USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
    case C.USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
    case C.USAGE_NOTIFICATION_EVENT:
      return C.STREAM_TYPE_NOTIFICATION;
    case C.USAGE_ASSISTANCE_ACCESSIBILITY:
    case C.USAGE_ASSISTANT:
    case C.USAGE_UNKNOWN:
    default:
      return C.STREAM_TYPE_DEFAULT;
  }
}
 
Example 7
Source File: AudioAttributes.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private AudioAttributes(
    @C.AudioContentType int contentType,
    @C.AudioFlags int flags,
    @C.AudioUsage int usage,
    @C.AudioAllowedCapturePolicy int allowedCapturePolicy) {
  this.contentType = contentType;
  this.flags = flags;
  this.usage = usage;
  this.allowedCapturePolicy = allowedCapturePolicy;
}
 
Example 8
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the {@link C.StreamType} corresponding to the specified {@link C.AudioUsage}.
 */
@C.StreamType
public static int getStreamTypeForAudioUsage(@C.AudioUsage int usage) {
  switch (usage) {
    case C.USAGE_MEDIA:
    case C.USAGE_GAME:
    case C.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
      return C.STREAM_TYPE_MUSIC;
    case C.USAGE_ASSISTANCE_SONIFICATION:
      return C.STREAM_TYPE_SYSTEM;
    case C.USAGE_VOICE_COMMUNICATION:
      return C.STREAM_TYPE_VOICE_CALL;
    case C.USAGE_VOICE_COMMUNICATION_SIGNALLING:
      return C.STREAM_TYPE_DTMF;
    case C.USAGE_ALARM:
      return C.STREAM_TYPE_ALARM;
    case C.USAGE_NOTIFICATION_RINGTONE:
      return C.STREAM_TYPE_RING;
    case C.USAGE_NOTIFICATION:
    case C.USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
    case C.USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
    case C.USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
    case C.USAGE_NOTIFICATION_EVENT:
      return C.STREAM_TYPE_NOTIFICATION;
    case C.USAGE_ASSISTANCE_ACCESSIBILITY:
    case C.USAGE_UNKNOWN:
    default:
      return C.STREAM_TYPE_DEFAULT;
  }
}
 
Example 9
Source File: Util.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the {@link C.StreamType} corresponding to the specified {@link C.AudioUsage}.
 */
@C.StreamType
public static int getStreamTypeForAudioUsage(@C.AudioUsage int usage) {
  switch (usage) {
    case C.USAGE_MEDIA:
    case C.USAGE_GAME:
    case C.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
      return C.STREAM_TYPE_MUSIC;
    case C.USAGE_ASSISTANCE_SONIFICATION:
      return C.STREAM_TYPE_SYSTEM;
    case C.USAGE_VOICE_COMMUNICATION:
      return C.STREAM_TYPE_VOICE_CALL;
    case C.USAGE_VOICE_COMMUNICATION_SIGNALLING:
      return C.STREAM_TYPE_DTMF;
    case C.USAGE_ALARM:
      return C.STREAM_TYPE_ALARM;
    case C.USAGE_NOTIFICATION_RINGTONE:
      return C.STREAM_TYPE_RING;
    case C.USAGE_NOTIFICATION:
    case C.USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
    case C.USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
    case C.USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
    case C.USAGE_NOTIFICATION_EVENT:
      return C.STREAM_TYPE_NOTIFICATION;
    case C.USAGE_ASSISTANCE_ACCESSIBILITY:
    case C.USAGE_ASSISTANT:
    case C.USAGE_UNKNOWN:
    default:
      return C.STREAM_TYPE_DEFAULT;
  }
}
 
Example 10
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the {@link C.StreamType} corresponding to the specified {@link C.AudioUsage}.
 */
@C.StreamType
public static int getStreamTypeForAudioUsage(@C.AudioUsage int usage) {
  switch (usage) {
    case C.USAGE_MEDIA:
    case C.USAGE_GAME:
    case C.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
      return C.STREAM_TYPE_MUSIC;
    case C.USAGE_ASSISTANCE_SONIFICATION:
      return C.STREAM_TYPE_SYSTEM;
    case C.USAGE_VOICE_COMMUNICATION:
      return C.STREAM_TYPE_VOICE_CALL;
    case C.USAGE_VOICE_COMMUNICATION_SIGNALLING:
      return C.STREAM_TYPE_DTMF;
    case C.USAGE_ALARM:
      return C.STREAM_TYPE_ALARM;
    case C.USAGE_NOTIFICATION_RINGTONE:
      return C.STREAM_TYPE_RING;
    case C.USAGE_NOTIFICATION:
    case C.USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
    case C.USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
    case C.USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
    case C.USAGE_NOTIFICATION_EVENT:
      return C.STREAM_TYPE_NOTIFICATION;
    case C.USAGE_ASSISTANCE_ACCESSIBILITY:
    case C.USAGE_UNKNOWN:
    default:
      return C.STREAM_TYPE_DEFAULT;
  }
}
 
Example 11
Source File: ExoMediaPlayer.java    From ExoMedia with Apache License 2.0 5 votes vote down vote up
public void setAudioStreamType(int streamType) {
    @C.AudioUsage
    int usage = Util.getAudioUsageForStreamType(streamType);
    @C.AudioContentType
    int contentType = Util.getAudioContentTypeForStreamType(streamType);

    AudioAttributes audioAttributes = new AudioAttributes.Builder()
            .setUsage(usage)
            .setContentType(contentType)
            .build();

    sendMessage(C.TRACK_TYPE_AUDIO, C.MSG_SET_AUDIO_ATTRIBUTES, audioAttributes);
}
 
Example 12
Source File: Util.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the {@link C.StreamType} corresponding to the specified {@link C.AudioUsage}.
 */
@C.StreamType
public static int getStreamTypeForAudioUsage(@C.AudioUsage int usage) {
  switch (usage) {
    case C.USAGE_MEDIA:
    case C.USAGE_GAME:
    case C.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
      return C.STREAM_TYPE_MUSIC;
    case C.USAGE_ASSISTANCE_SONIFICATION:
      return C.STREAM_TYPE_SYSTEM;
    case C.USAGE_VOICE_COMMUNICATION:
      return C.STREAM_TYPE_VOICE_CALL;
    case C.USAGE_VOICE_COMMUNICATION_SIGNALLING:
      return C.STREAM_TYPE_DTMF;
    case C.USAGE_ALARM:
      return C.STREAM_TYPE_ALARM;
    case C.USAGE_NOTIFICATION_RINGTONE:
      return C.STREAM_TYPE_RING;
    case C.USAGE_NOTIFICATION:
    case C.USAGE_NOTIFICATION_COMMUNICATION_REQUEST:
    case C.USAGE_NOTIFICATION_COMMUNICATION_INSTANT:
    case C.USAGE_NOTIFICATION_COMMUNICATION_DELAYED:
    case C.USAGE_NOTIFICATION_EVENT:
      return C.STREAM_TYPE_NOTIFICATION;
    case C.USAGE_ASSISTANCE_ACCESSIBILITY:
    case C.USAGE_ASSISTANT:
    case C.USAGE_UNKNOWN:
    default:
      return C.STREAM_TYPE_DEFAULT;
  }
}
 
Example 13
Source File: AudioAttributes.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see android.media.AudioAttributes.Builder#setUsage(int)
 */
public Builder setUsage(@C.AudioUsage int usage) {
  this.usage = usage;
  return this;
}
 
Example 14
Source File: AudioAttributes.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private AudioAttributes(@C.AudioContentType int contentType, @C.AudioFlags int flags,
    @C.AudioUsage int usage) {
  this.contentType = contentType;
  this.flags = flags;
  this.usage = usage;
}
 
Example 15
Source File: AudioAttributes.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see android.media.AudioAttributes.Builder#setUsage(int)
 */
public Builder setUsage(@C.AudioUsage int usage) {
  this.usage = usage;
  return this;
}
 
Example 16
Source File: AudioAttributes.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private AudioAttributes(@C.AudioContentType int contentType, @C.AudioFlags int flags,
    @C.AudioUsage int usage) {
  this.contentType = contentType;
  this.flags = flags;
  this.usage = usage;
}
 
Example 17
Source File: AudioAttributes.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see android.media.AudioAttributes.Builder#setUsage(int)
 */
public Builder setUsage(@C.AudioUsage int usage) {
  this.usage = usage;
  return this;
}
 
Example 18
Source File: AudioAttributes.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private AudioAttributes(@C.AudioContentType int contentType, @C.AudioFlags int flags,
    @C.AudioUsage int usage) {
  this.contentType = contentType;
  this.flags = flags;
  this.usage = usage;
}
 
Example 19
Source File: AudioAttributes.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @see android.media.AudioAttributes.Builder#setUsage(int)
 */
public Builder setUsage(@C.AudioUsage int usage) {
  this.usage = usage;
  return this;
}
 
Example 20
Source File: AudioAttributes.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private AudioAttributes(@C.AudioContentType int contentType, @C.AudioFlags int flags,
    @C.AudioUsage int usage) {
  this.contentType = contentType;
  this.flags = flags;
  this.usage = usage;
}