question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems with AudioFocus on Android 8.0 (API 26)

See original GitHub issue

Hi, On Android 8.0 (API 26) audio stops as soon as video playout starts. The message in console:

W/AudioManager: Use of stream types is deprecated for operations other than volume control
W/AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case
I/MediaFocusControl:  AudioFocus  requestAudioFocus() from uid/pid 10047/6345 clientId=android.media.AudioManager@96ca3e7com.devbrackets.android.exomedia.ui.widget.VideoView$AudioFocusHelper@8dc5b94 req=1 flags=0x0

It seems that AudioManager API has been changed in Android 8: https://developer.android.com/preview/features/audiofocus.html

Tested only on Android Emulator

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ivanzhangcommented, Dec 19, 2018

No, it’s happen on many physical devices… but it fails only some videos, not all videos, well, i have some logcat info to share:

12-19 13:13:08.077 21366-21366/com.dianmoge I/ExoPlayerImpl: Init 1971167 [ExoPlayerLib/2.9.1] [16th, 16th, Meizu, 27] 12-19 13:13:08.079 21366-21366/com.dianmoge W/AudioManager: Use of stream types is deprecated for operations other than volume control See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case 12-19 13:13:08.092 21366-21403/com.dianmoge I/ReactNativeJS: ‘video url:’, ‘https://1251052432.vod2.myqcloud.com/3ef5dd60vodtransgzp1251052432/06200bd85285890783193923458/v.f30.mp4’ 12-19 13:13:08.094 21366-21403/com.dianmoge I/ReactNativeJS: ‘onAudioFocusChanged …’, { hasAudioFocus: false } ‘video url:’, ‘https://1251052432.vod2.myqcloud.com/3ef5dd60vodtransgzp1251052432/59a687555285890783191143697/v.f30.mp4’ 12-19 13:13:08.115 21366-23342/com.dianmoge I/BufferQueue: unnamed-21366-85 BufferQueue core=(21366:com.dianmoge) 12-19 13:13:08.116 21366-23119/com.dianmoge I/MediaCodec: [OMX.qcom.video.decoder.avc] setting surface generation to 21878868 12-19 13:13:08.121 21366-21366/com.dianmoge I/ExoPlayerImpl: Release 2d08719 [ExoPlayerLib/2.9.1] [16th, 16th, Meizu, 27] [goog.exo.core, goog.exo.okhttp] 12-19 13:13:08.180 21366-21366/com.dianmoge I/BufferQueue: unnamed-21366-86 BufferQueue core=(21366:com.dianmoge) 12-19 13:13:08.183 21366-21366/com.dianmoge I/Choreographer: Skipped 3 frames! The application may be doing too much work on its main thread. 12-19 13:13:09.298 21366-21394/com.dianmoge I/qtaguid: Untagging socket 138 failed errno=-22 12-19 13:13:09.683 21366-23346/com.dianmoge I/qtaguid: Untagging socket 138 failed errno=-22 12-19 13:13:11.314 21366-21394/com.dianmoge I/qtaguid: Untagging socket 138 failed errno=-22 12-19 13:13:11.724 21366-23348/com.dianmoge I/qtaguid: Untagging socket 146 failed errno=-22 12-19 13:13:13.337 21366-21394/com.dianmoge I/qtaguid: Untagging socket 138 failed errno=-22

0reactions
brianwernickcommented, Jan 23, 2019

Sorry @ivanzhang I don’t remember getting notified of any additional comments on this thread. Looking in to it some more, the audio focus method calls definitely need to be updated; not sure why I was thinking it was only an emulator issue. I’m going to re-open the issue to track updating the AudioFocus

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage audio focus - Android Developers
The system looks at them when an app gains and loses audio focus. Attributes supersede the notion of stream type. In Android 8.0...
Read more >
How to request AudioFocus for android devices above api ...
Consider using AudioManagerCompat . One method is deprecated but it's the only method until api 26. If you don't want to deal with...
Read more >
How to Manage Audio Focus in Android? - GeeksforGeeks
Steps to Implement the Audio Focus or handle Audio interruptions. Step 1: Create an empty activity project. Create an empty activity Android ......
Read more >
Respecting Audio Focus - Android Developers Blog
If your application doesn't respect the rules of audio focus then it's disrespecting ... AUDIOFOCUS_GAIN); 8. if (result == AudioManager.
Read more >
Failed to load map Error contacting Google servers issue with ...
Failed to load map according to Google Maps Android API (16603). ... <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found