Creating an Image Button that Creates a Sound HTML -
hi trying make image button ( of speaker ) play audio file me.
<p><br></p> <table> <tbody><tr> <th> quick clicks </th> <td style="text-align: center;"> <a href="#3" onclick=""><img src="https://zingtree-uploads.s3.amazonaws.com/images/59777e50293d71.47898028-416750-speaker.png" style="width: 145px; height: 145px;"></a> </td> <td style="text-align: center;"> <a href="#3" onclick="do_button_click(14, 7, 'quick clicks',0);"><img src="https://zingtree-uploads.s3.amazonaws.com/images/59777e50293d71.47898028-486417-quick+clicks.png" style="width: 145px; height: 145px;" ></a> </td> </tr> </tbody></table>
those 2 pictures i'd use , i'd make first button play audio file:
<a class="btn btn-lg btn-zingtree btn-block btn-primary" onclick="this.firstchild.play()"><audio src="https://thorswrench-my.sharepoint.com/personal/christiaan_karsavior_com/documents/database%20media/sounds/dead%20battery%20clicking.mp3"></audio>play</a>`enter code here`
sorry, know there must solution somewhere have failed find one.
at basic if you'd trigger play()
on <audio>
you'll need find element , setup function calls play(). can set in <script>
tag @ bottom of <body>
, call onclick
if you'd like.
let au = document.getelementsbytagname('audio')[0] function playau() { au.play() }
the <audio>
element needs on page somewhere. if there multiple audio's you'll want give them ids , selected them individually. if there problem file (source) trying play see in console.
Comments
Post a Comment