Some limitations

28 views
Skip to first unread message

Micael Ribeiros

unread,
Jan 6, 2011, 7:51:54 PM1/6/11
to js-audio
Ive recently started working with the audio tag and ive came across
some limitations.
Please note that I'm currently only testing it on Mozilla but Im just
posting this cause it might help some people.

I'm creating a web game and I need to use a looped background music
with some effect sounds.
One of the most bothering problem that I came across with was that for
some reason if I change the src propriety of an audio tag and play the
sound again it will still play the original src file. To temporarily
solve Ill be using separate audio tags for each file (Ill have to use
a lot of audio tags but what the heck!). The next problem was that
Mozilla doesn't support the "loop" propriety so I had to use a
workaround to play the sound again when it ends:

sound.addEventListener('ended', function() {
this.currentTime = 0;
this.play();
}, false);

This makes the sound stop for a second or so ending the beauty of the
loop so I decided that Ill just use an embed tag for the background
sound, that way I can loop correctly it on Mozilla (The reason Im not
using embed is because I havent found a way to play multiple sounds at
the same time using embed, if you know how to please inform me).
Reply all
Reply to author
Forward
0 new messages