javascript - how to pause a audio on click a video? -
i've made jquery script pause background music on click video don't work. can me?here's javascript:
<script src="../style/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready( function(){ $("#trailer").click( function(){ $("#bgm").get(0).pause(); } ) } ); </script>
here's html:
<video height="340" width="864.5" id="trailer" onclick="gofullscreen('trailer');"> <source src="video.mp4" type="video/mp4"> </video> <embed src="sound.mp3" hidden="true" autostart="true" loop="true" id="bgm"></embed>
anyway, embed mp3 can't loop too, can correct me?thks.
probably embed element not have htmlmediaelement interface includes pause() method. can use htmlaudioelement <audio> instead.
than: access audio element directly click event handler.
$("#bgm").pause();
Comments
Post a Comment