2

How can I play an mp3 or wav sound using the jquery click event?

i want to add click sound not any track or song

Web Worm
  • 2,080
  • 12
  • 40
  • 65

2 Answers2

3

You might find the jQuery Sound Plugin of use:

This is a simple sound player, it uses flash to play the sounds, but DOES NOT provide a flash interface for any controls, everything is controlled via jQuery

$("#sound").sound({swf: url});
$("#sound").load(url);
$("#sound").play();
$("#sound").pause();
$("#sound").stop();
$("#sound").volume(0-100);
Sampson
  • 265,109
  • 74
  • 539
  • 565
  • it is under development once i complete it i will tell you – Web Worm Dec 23 '09 at 19:07
  • @Mohan I believe it's your container - something like `
    `.
    – Sampson Jan 25 '11 at 14:29
  • I am using mp3 file, but not works for me i used like this $("#sound").sound({swf: 'www.example.com/example.mp3'}); – Mohan Ram Jan 25 '11 at 14:34
  • @Mohan This (comments on this answer) wouldn't be the best place to provide support. Perhaps you could ask a new question here regarding your problem. Invite the readers to look at the source code with you and determine what (if anything) might have broken in later versions of jQuery. Best of luck! – Sampson Jan 25 '11 at 15:36
0

You can't use DHTML to play sound. You can use a flash player like this one.

Mongus Pong
  • 11,337
  • 9
  • 44
  • 72