I try to play an mp3 file. This works if I change the path to the file on my local webserver, but if I run this on an Android device the sound is not played and no error is shown.
I am pretty shure that the mp3 file is not found, but I still don't know how to fix it.
This is the Html
<body>
<audio id="successSound" src="/android_asset/www/sound/successSound.mp3" type="audio/mpeg" ></audio>
<audio id="errorSound" src="/android_asset/www/sound/errorSound.mp3" type="audio/mpeg" ></audio>
<!-- some more UI -->
</body>
This is the Javascript
document.getElementById('errorSound').play();
The is the file structure
phonyapp
`-- www
`-- index.html
|-- sound
| |-- errorSound.mp3
| `-- successSound.mp3
|-- res
`-- spec
Edit 1
I tried
<audio id="successSound" src="sound/successSound.mp3" type="audio/mpeg" ></audio>
This worked in chrome on my local webserver but not on Android.
I tried
<audio id="successSound" src="http://html5multimedia.com/media/sayHello.mp3" type="audio/mpeg" ></audio>
This worked, but I need to get local files playing
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…