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.

inside custom component

Web and WebWorks Development

Reply
Regular Contributor
Posts: 64
Registered: ‎06-16-2011
My Device: bold 9000, playbook
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.

Developer
Posts: 51
Registered: ‎10-22-2011
My Device: 9800
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
Highlighted
Regular Contributor
Posts: 64
Registered: ‎06-16-2011
My Device: bold 9000, playbook
My Carrier: vodafone

Re: Playbook <audio> not playing.

[ Edited ]

Thanks it worked Smiley Happy