I`m making an educational game that has 16 very short sound files. User clicks a start button, one sound file is randomly chosen from an array and the sound file is played. After that, other stuff happens...
Considerations.
I'm thinking that HTML5 might be suitable because I could assign a different id to each sound file, making it easier to randomly choose one using javascript from an array of all 16 files...
I'm assuming there's a way to use a javascript call back to make the audio file to play after it is randomly chosen. Ideally, I don't want the user to have to cli开发者_Go百科ck a separate "play" button
On the other hand, it's a game for students studying English as a second language, and a lot of people in Asia don't use the latest browsers, so HTML5 support isn't guaranteed.
So, Is HTML5 suitable to store the files in the browswer and accomplish these objectives?
This is one of those times when you should go with flash. Asia is the greatest IE6 user and you're definitely not getting HTML5 <audio>
goodness out of that.
While you could go directly for HTML5 <audio>
in this case, the support for it isn't very wide yet.
And, as Radu says, Asian countries are still big on older browsers.
I would recommend using SoundManager 2 to accomplish what you're doing. It provides an easy to use API for controlling audio from JavaScript, and it supports different ways of playing back the audio so you can better guarantee it works properly.
Nothing you're talking about requires HTML5. It's all standard stuff where you store the file location of the 16 sound files in an array, select a random index of the array and play that sound when the play button is clicked.
精彩评论