Safari 5 on Windows doesn't support the HTML5 audio element, and so won't play any audio you've embedded that way. In fact, Apple no longer develops Safari on Windows - so it's doubtful they'll develop a Safari 6 or later for Windows in the near future that is more HTML5-compliant.
It should work on the iPad, with the exception that you cannot autoplay audio or video on iOS - Apple doesn't permit it in iOS. If you are playing from a button click, it should work.
I have .play() function calling in a click event, it works on PC, but still no sound on iPod. The iPod sound device works normally, I tried other webpage and it can play audio.
Not sure what's the problem?
Maybe it's the mp3 file that's the problem? Try loading an HTML file on the iPod Touch containing the HTML5 audio element, like this:
<audio src="xxx.mp3" controls>
It works with <audio src="xxx.mp3" controls> on iPod
I guess I'm close to the problem. The sound works when I run the html on my own PC (local). But after I put the html on my server and access it through network. There is no sound.
I place all the mp3 files inside a folder "sound" and put it into my project folder (same directory as html file), and the code looks like this:
a.src = "sound/xxx.mp3";
I put the folder "sound" on my server as well (same directory as html file)
Really not sure what the problem may be. Here are some links that may help:
I've solved the problem with the following code:
var audioElement = document.createElement('audio');
audioElement.setAttribute('type', 'audio/mpeg'); //or 'audio/ogg'
var audio = new Audio();
EDIT: I'm wrong, this only solved the problem on PC. There is still no sound on iPod