html - Custom button to mute audio play -
i have code below , using html based game making. delays playing of call in background while player uses iframe continue play game without interrupting call.
<audio onloadeddata="var audioplayer = this; settimeout(function() { audioplayer.play(); }, 1500)"> <source src="call1.mp3" type="audio/mp3" />
my question is, how can make custom mute button can placed within iframe, when player clicks it, mutes call , hides button?
found answer.
used following code:
the html
<a href="#" id="mutebutton"><img src="mutecall.png"></a> <div id="sounddiv"> <audio id="background_audio" onloadeddata="var audioplayer = this; settimeout(function() { audioplayer.play(); }, 1500)"> <source src="call1.mp3" type="audio/mp3" /> </audio> </div>
the javascript:
<script language="javascript"> $("#mutebutton").click(function() { $(this).hide(); var div = document.getelementbyid("sounddiv"); div.parentnode.removechild(div); }); </script>
it worked question asked.
when image clicked, muted audio , hid button.
Comments
Post a Comment