Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Regular Contributor
sandeshmsg
Posts: 64
Registered: ‎06-16-2011
My Carrier: vodafone
Accepted Solution

Playbook <audio> not playing.

Hello Experts,

 

I am trying to play a click sound  when the button is clicked in my application , I am unable to get the solution. 

Currently I am using the following code :

 

var audio = document.createElement('audio');
audio.src='button-29.wav';
audio.controls = true;
document.body.appendChild(audio);

 

Please help me to play the sound when the button is clicked.

 

Regards,

Sandesh.

Please use plain text.
Developer
Puzzling
Posts: 51
Registered: ‎10-22-2011
My Carrier: Telus

Re: Playbook <audio> not playing.

Something like
button.addEventListener("click", function() {audio.play();}, 0);
should do it? Of course, you'll have to have created the button before this code. If that doesn't work: - Make sure the "audio" object you created is in scope at the point you execute the above code (or give it an id and get it) - Make sure the wav file is not some format unsupported on the device - Make sure you have the full and correct path to the sound file
Please use plain text.
Regular Contributor
sandeshmsg
Posts: 64
Registered: ‎06-16-2011
My Carrier: vodafone

Re: Playbook <audio> not playing.

[ Edited ]

Thanks it worked :smileyhappy:

Please use plain text.