Java Code Examples for com.google.android.exoplayer2.C#USAGE_NOTIFICATION_COMMUNICATION_INSTANT
The following examples show how to use
com.google.android.exoplayer2.C#USAGE_NOTIFICATION_COMMUNICATION_INSTANT .
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 | 5 votes |
/** * 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 2
Source File: Util.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * 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 3
Source File: Util.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * 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 4
Source File: Util.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * 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 5
Source File: Util.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * 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 6
Source File: AudioFocusManager.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
/** * Converts {@link AudioAttributes} to one of the audio focus request. * * <p>This follows the class Javadoc of {@link AudioFocusRequest}. * * @param audioAttributes The audio attributes associated with this focus request. * @return The type of audio focus gain that should be requested. */ private static int convertAudioAttributesToFocusGain(@Nullable AudioAttributes audioAttributes) { if (audioAttributes == null) { // Don't handle audio focus. It may be either video only contents or developers // want to have more finer grained control. (e.g. adding audio focus listener) return C.AUDIOFOCUS_NONE; } switch (audioAttributes.usage) { // USAGE_VOICE_COMMUNICATION_SIGNALLING is for DTMF that may happen multiple times // during the phone call when AUDIOFOCUS_GAIN_TRANSIENT is requested for that. // Don't request audio focus here. case C.USAGE_VOICE_COMMUNICATION_SIGNALLING: return C.AUDIOFOCUS_NONE; // Javadoc says 'AUDIOFOCUS_GAIN: Examples of uses of this focus gain are for music // playback, for a game or a video player' case C.USAGE_GAME: case C.USAGE_MEDIA: return C.AUDIOFOCUS_GAIN; // Special usages: USAGE_UNKNOWN shouldn't be used. Request audio focus to prevent // multiple media playback happen at the same time. case C.USAGE_UNKNOWN: Log.w( TAG, "Specify a proper usage in the audio attributes for audio focus" + " handling. Using AUDIOFOCUS_GAIN by default."); return C.AUDIOFOCUS_GAIN; // Javadoc says 'AUDIOFOCUS_GAIN_TRANSIENT: An example is for playing an alarm, or // during a VoIP call' case C.USAGE_ALARM: case C.USAGE_VOICE_COMMUNICATION: return C.AUDIOFOCUS_GAIN_TRANSIENT; // Javadoc says 'AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK: Examples are when playing // driving directions or notifications' case C.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE: case C.USAGE_ASSISTANCE_SONIFICATION: case C.USAGE_NOTIFICATION: case C.USAGE_NOTIFICATION_COMMUNICATION_DELAYED: case C.USAGE_NOTIFICATION_COMMUNICATION_INSTANT: case C.USAGE_NOTIFICATION_COMMUNICATION_REQUEST: case C.USAGE_NOTIFICATION_EVENT: case C.USAGE_NOTIFICATION_RINGTONE: return C.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK; // Javadoc says 'AUDIOFOCUS_GAIN_EXCLUSIVE: This is typically used if you are doing // audio recording or speech recognition'. // Assistant is considered as both recording and notifying developer case C.USAGE_ASSISTANT: if (Util.SDK_INT >= 19) { return C.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE; } else { return C.AUDIOFOCUS_GAIN_TRANSIENT; } // Special usages: case C.USAGE_ASSISTANCE_ACCESSIBILITY: if (audioAttributes.contentType == C.CONTENT_TYPE_SPEECH) { // Voice shouldn't be interrupted by other playback. return C.AUDIOFOCUS_GAIN_TRANSIENT; } return C.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK; default: Log.w(TAG, "Unidentified audio usage: " + audioAttributes.usage); return C.AUDIOFOCUS_NONE; } }
Example 7
Source File: AudioFocusManager.java From Telegram with GNU General Public License v2.0 | 4 votes |
/** * Converts {@link AudioAttributes} to one of the audio focus request. * * <p>This follows the class Javadoc of {@link AudioFocusRequest}. * * @param audioAttributes The audio attributes associated with this focus request. * @return The type of audio focus gain that should be requested. */ private static int convertAudioAttributesToFocusGain(@Nullable AudioAttributes audioAttributes) { if (audioAttributes == null) { // Don't handle audio focus. It may be either video only contents or developers // want to have more finer grained control. (e.g. adding audio focus listener) return C.AUDIOFOCUS_NONE; } switch (audioAttributes.usage) { // USAGE_VOICE_COMMUNICATION_SIGNALLING is for DTMF that may happen multiple times // during the phone call when AUDIOFOCUS_GAIN_TRANSIENT is requested for that. // Don't request audio focus here. case C.USAGE_VOICE_COMMUNICATION_SIGNALLING: return C.AUDIOFOCUS_NONE; // Javadoc says 'AUDIOFOCUS_GAIN: Examples of uses of this focus gain are for music // playback, for a game or a video player' case C.USAGE_GAME: case C.USAGE_MEDIA: return C.AUDIOFOCUS_GAIN; // Special usages: USAGE_UNKNOWN shouldn't be used. Request audio focus to prevent // multiple media playback happen at the same time. case C.USAGE_UNKNOWN: Log.w( TAG, "Specify a proper usage in the audio attributes for audio focus" + " handling. Using AUDIOFOCUS_GAIN by default."); return C.AUDIOFOCUS_GAIN; // Javadoc says 'AUDIOFOCUS_GAIN_TRANSIENT: An example is for playing an alarm, or // during a VoIP call' case C.USAGE_ALARM: case C.USAGE_VOICE_COMMUNICATION: return C.AUDIOFOCUS_GAIN_TRANSIENT; // Javadoc says 'AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK: Examples are when playing // driving directions or notifications' case C.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE: case C.USAGE_ASSISTANCE_SONIFICATION: case C.USAGE_NOTIFICATION: case C.USAGE_NOTIFICATION_COMMUNICATION_DELAYED: case C.USAGE_NOTIFICATION_COMMUNICATION_INSTANT: case C.USAGE_NOTIFICATION_COMMUNICATION_REQUEST: case C.USAGE_NOTIFICATION_EVENT: case C.USAGE_NOTIFICATION_RINGTONE: return C.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK; // Javadoc says 'AUDIOFOCUS_GAIN_EXCLUSIVE: This is typically used if you are doing // audio recording or speech recognition'. // Assistant is considered as both recording and notifying developer case C.USAGE_ASSISTANT: if (Util.SDK_INT >= 19) { return C.AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE; } else { return C.AUDIOFOCUS_GAIN_TRANSIENT; } // Special usages: case C.USAGE_ASSISTANCE_ACCESSIBILITY: if (audioAttributes.contentType == C.CONTENT_TYPE_SPEECH) { // Voice shouldn't be interrupted by other playback. return C.AUDIOFOCUS_GAIN_TRANSIENT; } return C.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK; default: Log.w(TAG, "Unidentified audio usage: " + audioAttributes.usage); return C.AUDIOFOCUS_NONE; } }