List of usage examples for android.media AudioManager AUDIOFOCUS_REQUEST_DELAYED
int AUDIOFOCUS_REQUEST_DELAYED
To view the source code for android.media AudioManager AUDIOFOCUS_REQUEST_DELAYED.
Click Source Link
From source file:androidx.media.widget.VideoView2.java
@SuppressWarnings("deprecation") private void requestAudioFocus(int focusType) { int result;/*from w w w .j a va2 s . c om*/ if (android.os.Build.VERSION.SDK_INT >= 26) { AudioFocusRequest focusRequest; focusRequest = new AudioFocusRequest.Builder(focusType).setAudioAttributes(mAudioAttributes) .setOnAudioFocusChangeListener(mAudioFocusListener).build(); result = mAudioManager.requestAudioFocus(focusRequest); } else { result = mAudioManager.requestAudioFocus(mAudioFocusListener, AudioManager.STREAM_MUSIC, focusType); } if (result == AudioManager.AUDIOFOCUS_REQUEST_FAILED) { mAudioFocused = false; } else if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { mAudioFocused = true; } else if (result == AudioManager.AUDIOFOCUS_REQUEST_DELAYED) { mAudioFocused = false; } }