Here is my simple audio play function:
let audioPlayResolve;
async function audioPlay(source) {
return new Promise(resolve => {
audioPlayResolve = resolve;
if(source === undefined) { resolve(); return; }
const audio = new Audio(source);
audio.crossOrigin = 'anonymous';
audio.volume = 0.9;
Playing.audios.push(audio);
audio.play();
audio.onerror = function() {
console.log("Error loading: " + this.src);
resolve();
}
audio.addEventListener("ended", function() {
audio.currentTime = 0;
resolve();
});
});
}
This is working fine on chrome windows.
The issue is when I play audio in Android Chrome the voice gets somehow distorted like it's a telephone call voice.
The interesting thing is when I decided to change the volume of my phone I noticed the audio volume is not controlled by media volume but call volume.
So if I turn down the media volume of my phone to 0 the audio I played via the above function still has volume and I can hear it!
What should I do to solve these two issues?