I recently published a Phonegap / Cordova app, with sounds. It plays nice with most phones. However, some complaints were made, that no sound is played on several phones. I found one of the models is Samsung S3. I managed to create a simplified app, that demonstrates this issue:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Hello World</title>
<script type="text/javascript" src="cordova.js"></script>
</head>
<body>
<h1 id="ogg">OGG</h1>
<h1 id="wav">WAV</h1>
<h1 id="mp3">MP3</h1>
<script>
var ogg = document.getElementById("ogg"),
oggSound = new Audio('bark04.ogg'),
wav = document.getElementById("wav"),
wavSound = new Audio('bark04.wav'),
mp3 = document.getElementById("mp3"),
mp3Sound = new Audio('bark04.mp3');
ogg.onclick = function(){
console.log("Start ogg");
oggSound.play();
console.log("Done ogg");
}
wav.onclick = function(){
console.log("Start wav");
wavSound.play();
console.log("Done wav");
}
mp3.onclick = function(){
console.log("Start mp3");
oggSound.play();
console.log("Done mp3");
}
</script>
</body>
</html>
Several notes here:
- This code works well when I use the android browser to look at the page. Only when I compile it using Phonegap 6.4.6 / Cordova 6.5.0, there any issue.
- This code works well on several phones, including Samsung S5
- Using android "about:inspect", I saw that all console.log outputs appear, and there are no errors.
- Both mp3 / ogg files were created using Audacity from the same wav. Both are kinda short. I couldn't think of any file format that did work. Thanks in advance for your help.