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

The following examples show how to use com.google.android.exoplayer2.C#StreamType . 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.AudioContentType} corresponding to the specified {@link C.StreamType}.
 */
@C.AudioContentType
public static int getAudioContentTypeForStreamType(@C.StreamType int streamType) {
  switch (streamType) {
    case C.STREAM_TYPE_ALARM:
    case C.STREAM_TYPE_DTMF:
    case C.STREAM_TYPE_NOTIFICATION:
    case C.STREAM_TYPE_RING:
    case C.STREAM_TYPE_SYSTEM:
      return C.CONTENT_TYPE_SONIFICATION;
    case C.STREAM_TYPE_VOICE_CALL:
      return C.CONTENT_TYPE_SPEECH;
    case C.STREAM_TYPE_USE_DEFAULT:
    case C.STREAM_TYPE_MUSIC:
    default:
      return C.CONTENT_TYPE_MUSIC;
  }
}
 
Example 2
Source File: Util.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C.AudioContentType} corresponding to the specified {@link C.StreamType}.
 */
@C.AudioContentType
public static int getAudioContentTypeForStreamType(@C.StreamType int streamType) {
  switch (streamType) {
    case C.STREAM_TYPE_ALARM:
    case C.STREAM_TYPE_DTMF:
    case C.STREAM_TYPE_NOTIFICATION:
    case C.STREAM_TYPE_RING:
    case C.STREAM_TYPE_SYSTEM:
      return C.CONTENT_TYPE_SONIFICATION;
    case C.STREAM_TYPE_VOICE_CALL:
      return C.CONTENT_TYPE_SPEECH;
    case C.STREAM_TYPE_USE_DEFAULT:
    case C.STREAM_TYPE_MUSIC:
    default:
      return C.CONTENT_TYPE_MUSIC;
  }
}
 
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 Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C.AudioContentType} corresponding to the specified {@link C.StreamType}.
 */
@C.AudioContentType
public static int getAudioContentTypeForStreamType(@C.StreamType int streamType) {
  switch (streamType) {
    case C.STREAM_TYPE_ALARM:
    case C.STREAM_TYPE_DTMF:
    case C.STREAM_TYPE_NOTIFICATION:
    case C.STREAM_TYPE_RING:
    case C.STREAM_TYPE_SYSTEM:
      return C.CONTENT_TYPE_SONIFICATION;
    case C.STREAM_TYPE_VOICE_CALL:
      return C.CONTENT_TYPE_SPEECH;
    case C.STREAM_TYPE_USE_DEFAULT:
    case C.STREAM_TYPE_MUSIC:
    default:
      return C.CONTENT_TYPE_MUSIC;
  }
}
 
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: MediaCodecAudioRenderer.java    From K-Sonic with MIT License 6 votes vote down vote up
@Override
public void handleMessage(int messageType, Object message) throws ExoPlaybackException {
  switch (messageType) {
    case C.MSG_SET_VOLUME:
      audioTrack.setVolume((Float) message);
      break;
    case C.MSG_SET_PLAYBACK_PARAMS:
      audioTrack.setPlaybackParams((PlaybackParams) message);
      break;
    case C.MSG_SET_STREAM_TYPE:
      @C.StreamType int streamType = (Integer) message;
      audioTrack.setStreamType(streamType);
      break;
    default:
      super.handleMessage(messageType, message);
      break;
  }
}
 
Example 7
Source File: SimpleDecoderAudioRenderer.java    From K-Sonic with MIT License 6 votes vote down vote up
@Override
public void handleMessage(int messageType, Object message) throws ExoPlaybackException {
  switch (messageType) {
    case C.MSG_SET_VOLUME:
      audioTrack.setVolume((Float) message);
      break;
    case C.MSG_SET_PLAYBACK_PARAMS:
      audioTrack.setPlaybackParams((PlaybackParams) message);
      break;
    case C.MSG_SET_STREAM_TYPE:
      @C.StreamType int streamType = (Integer) message;
      audioTrack.setStreamType(streamType);
      break;
    default:
      super.handleMessage(messageType, message);
      break;
  }
}
 
Example 8
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C.AudioContentType} corresponding to the specified {@link C.StreamType}.
 */
@C.AudioContentType
public static int getAudioContentTypeForStreamType(@C.StreamType int streamType) {
  switch (streamType) {
    case C.STREAM_TYPE_ALARM:
    case C.STREAM_TYPE_DTMF:
    case C.STREAM_TYPE_NOTIFICATION:
    case C.STREAM_TYPE_RING:
    case C.STREAM_TYPE_SYSTEM:
      return C.CONTENT_TYPE_SONIFICATION;
    case C.STREAM_TYPE_VOICE_CALL:
      return C.CONTENT_TYPE_SPEECH;
    case C.STREAM_TYPE_USE_DEFAULT:
    case C.STREAM_TYPE_MUSIC:
    default:
      return C.CONTENT_TYPE_MUSIC;
  }
}
 
Example 9
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 10
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C.AudioContentType} corresponding to the specified {@link C.StreamType}.
 */
@C.AudioContentType
public static int getAudioContentTypeForStreamType(@C.StreamType int streamType) {
  switch (streamType) {
    case C.STREAM_TYPE_ALARM:
    case C.STREAM_TYPE_DTMF:
    case C.STREAM_TYPE_NOTIFICATION:
    case C.STREAM_TYPE_RING:
    case C.STREAM_TYPE_SYSTEM:
      return C.CONTENT_TYPE_SONIFICATION;
    case C.STREAM_TYPE_VOICE_CALL:
      return C.CONTENT_TYPE_SPEECH;
    case C.STREAM_TYPE_USE_DEFAULT:
    case C.STREAM_TYPE_MUSIC:
    default:
      return C.CONTENT_TYPE_MUSIC;
  }
}
 
Example 11
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 12
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 13
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 14
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 15
Source File: AudioTrack.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * Sets the stream type for audio track. If the stream type has changed and if the audio track
 * is not configured for use with tunneling, then the audio track is reset and the audio session
 * id is cleared.
 * <p>
 * If the audio track is configured for use with tunneling then the stream type is ignored, the
 * audio track is not reset and the audio session id is not cleared. The passed stream type will
 * be used if the audio track is later re-configured into non-tunneled mode.
 *
 * @param streamType The {@link C.StreamType} to use for audio output.
 */
public void setStreamType(@C.StreamType int streamType) {
  if (this.streamType == streamType) {
    return;
  }
  this.streamType = streamType;
  if (tunneling) {
    // The stream type is ignored in tunneling mode, so no need to reset.
    return;
  }
  reset();
  audioSessionId = C.AUDIO_SESSION_ID_UNSET;
}
 
Example 16
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 17
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 18
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 19
Source File: ExoPlayerAdapter.java    From leanback-showcase with Apache License 2.0 4 votes vote down vote up
public void setAudioStreamType(@C.StreamType int audioStreamType) {
    mAudioStreamType = audioStreamType;
}
 
Example 20
Source File: ExoPlayerAdapter.java    From tv-samples with Apache License 2.0 4 votes vote down vote up
public void setAudioStreamType(@C.StreamType int audioStreamType) {
    mAudioStreamType = audioStreamType;
}