I have an HTTP URL of audio.
The URL is working fine with the ExoPlayer v2.7.0 when android TargetSDKVersion is 26.
When the TargetSDKVersion is set to 28, it is not working.
Getting the following error:
W/MediaPlayer: Couldn't open http://***
java.io.FileNotFoundException: No content provider: http://***
But, when I set an HTTPS URL, it works fine.
For this, we have set the network configuration in the AndroidManifest
<application
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
And network_security_config is:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>
Also, used setAudioAttributes
instead of setAudioStreamType
for the media player.
mediaPlayer.setAudioAttributes(
new AudioAttributes
.Builder()
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build());
Any thoughts on this?