Reputation: 1080
What is the preferred method to add sound to a page using jquery?
I am considering using jPlayer but have my doubts about it. Depending on the messages being displayed on the screen, I need to customize the sound.
Thanks in advance.
Upvotes: 4
Views: 11381
Reputation: 8406
Personally, i prefer jPlayer and use it heavily. But you could consider Soundmanager, too. http://www.schillmania.com/projects/soundmanager2/
Upvotes: 0
Reputation: 1871
Personally I find random audio on a website really annoying but here you go:
<audio>
<source src="audio/audio.mp3"></source>
<source src="audio/audio.ogg"></source>
HTML5 Needed
</audio>
<script>
var audio = $("audio")[0];
audio.play();
</script>
or something like:
$("<audio></audio>").attr({
'src':'audio/something.mp3',
'volume':0.4,
'autoplay':'autoplay'
}).appendTo("body");
Both these examples use HTML5 but with small modifications you can use flash to play the audio.
Upvotes: 4