通知
本站点除 Legacy 产品与方案外,已迁移至 声网新文档中心 ,当前页面不再维护
Documentation
All
Console 官网 Community Technical support

Why can't I play the audio file using startAudioMixing or playEffect on Android 9?

Type: Integration issues    Platform: Android   Last Updated: 2022/09/14 02:21:22

Issue description

Cannot play an mp3, mp4, or any other music format using startAudioMixing or playEffect on Android 9.

Reason

This is caused by an Android permission limit. If targetSdkVersion ≥ 28, you need to add relevant app privileges to play the a music file.

Solution

For Android projects with targetSdkVersion ≥ 28, add the following line in the application zone of the AndroidManifest.xml file to play the music file:

<application
   android:usesCleartextTraffic="true"
   android:requestLegacyExternalStorage="true"
   …
</application>

For more Android permission settings and considerations, see Project setup.