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
New Developer
kubosh
Posts: 9
Registered: ‎11-26-2012
My Device: Dev Alpha

Playsound fuction - problem - second button play assigned sound and sound from first button :(

Hi All .

I create app in html5 . I  have 2 diffrient buttons . When i click first - it play  assigned  sound , when i click second - it play sound from first button and assignet together :smileysad:

I use Playsound Function :

 

"<script language="javascript" type="text/javascript">
function playSound(soundfile) {
document.getElementById("dummy").innerHTML=document.getElementById("dummy").innerHTML +
"<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}
</script>"

 

And code for buttons :

 

<span id="dummy" onclick="playSound('Sound/swinia.wav');"><img src="Images/swinia.png" name="swinia" width="115" height="100" border="0" style="position: absolute; right: 90%; top: 80%" id="swinia"  /></a></span>


<span id="dummy" onclick="playSound('Sound/kon.wav');"><img src="Images/kon.png" name="kon" width="153" height="127" border="0" style="position: absolute; right: 87%; top: 60%" id="kon"  /></a></span>

 

I would like to have above 10 diffrent buttons and corresponding sounds.

 

Please help me :smileysad:

 

Br. Kubosh

Please use plain text.
New Developer
kubosh
Posts: 9
Registered: ‎11-26-2012
My Device: Dev Alpha

Re: Playsound fuction - problem - second button play assigned sound and sound from first button :(

I update Script and code - everything is works

 

    <script language="javascript" type="text/javascript">  
      
        function playSound(soundfile)   
        {  
              
            document.getElementById("dummy").innerHTML= "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";  
        }  
          
    </script>

 

AND CODE:

 

<span id="swinia" onclick="playSound('Sound/swinia.wav');"><img src="Images/swinia.png" name="swinia" width="115" height="100" border="0" style="position: absolute; right: 87%; top: 80%" id="swinia"  /></a></span>

 

<span id="kon" onclick="playSound('Sound/kon.wav');"><img src="Images/kon.png" name="kon" width="153" height="127" border="0" style="position: absolute; right: 87%; top: 58%" id="kon"  /></a></span>

Please use plain text.