I have this code:
$('#typer').keypress(function(e){
var code = (e.keyCode ? e.keyCode : e.which);
if (code == '13') {
$.sound.play("cr.wav",{timeout:1000});
} else if (code == '8') {
$.sound.play("del.wav",{timeout:1000});
} else if (code == '27') {
$.sound.play("asswipe.wav",{timeout:1000});
} else {
$.sound.play("key.wav",{timeout:1000});
}
});
Now, for some reason – I can only type one character in this box. The sound plays once and then nothing more.
This works fine in IE… Just FireFox…
Plugin link: http://code.google.com/p/jqueryjs/source/browse/trunk/plugins/sound/jquery.sound.js?r=5750
Has ANYONE ever used this plugin….?
First, e.which is a number, not a string, so you should lose the single quotes: use
code == 13, notcode == '13'. You might be better served by a switch statement (though that’s just a matter of preference).Second, I don’t think the problem is with the plugin. Without using the plugin, this has the same problem:
It seems that FF and Chrome do not deal well with having
<embed>tags added to them dynamically. You may want to look for a different plugin, one that doesn’t use the tag. I’m not a fan of flash, but there are probably some plugins out there that use it, and that work well.