I am trying to play audio stream for a radio channel using cordova, The code runs well on all mobile phones but on Huawei Pro 30 it is not able to load the and throwing this error when using direct
<audio controls src='mystreamurl' id="myaudio" />
Failed to load resource: the server responded with a status of 401 (Authentication Required)
I have tried to use cordova-plugin-media and made sure that all permissions are there :
it throws error code 0
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
and have added to the application tag
android:usesCleartextTraffic="true"
and my html meta tag
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'self' http://* https://* 'unsafe-inline'; script-src * 'self' http://* https://* 'unsafe-inline' 'unsafe-eval';img-src * 'self' https: blob: data: http:; media-src * 'self' 'unsafe-inline' http://* https://* ;font-src *" />
Kindly note as mentioned before on all other phones it is working but on huawei having androird 10 not working and I have double checked the application settings and permissions on the phone all seems to be right.
**EDIT : I found that the issue is not in the code but the issue in authorization on the link in Android 10 , this Link is http://acc.qatarnavigator.com/news/music.html which contains the audio src (http://shaincast.caster.fm:44928/listen.mp3?authn3a123cb80bd23dbc6bee1f8156e8c8a0) is working fine.
If I added it as a iframe the Android 10 also block the media link (Failed to load resource: the server responded with a status of 401 (Authentication Required)
So the question now is there any work arround to authorize the link? is because it is not encoding it correctly ?
Note if I play any other online media .mp3 link it is working
I have tested to create
<a href="http://shaincast.caster.fm:44928/listen.mp3?authn3a123cb80bd23dbc6bee1f8156e8c8a0">CLICK ME</a>
Then it Throws an error
err_cleartext_not_permitted
So I have added due to Network configuration new rules
<?xml version="1.0" encoding="utf-8"?>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">shaincast.caster.fm:44928</domain>
</domain-config>
But again it throws the error :
Failed to load resource: the server responded with a status of 401 (Authentication Required)
Any Ideas?
**