zoukankan      html  css  js  c++  java
  • js控制html5 audio的暂停、播放、停止

    <!DOCTYPE HTML>
    
    <html>
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    
    </head>
    <body>  音乐
    <audio src="b.mp3" controls="controls" preload id="music1" hidden>
    </audio>
    <span id="bf" onclick="bf();">播放/暂停</span>
    <span id="bf" onclick="rbf();">重新播放</span>
    <script>
    function rbf(){
     var audio = document.getElementById('music1'); 
     audio.currentTime = 0;
    }
    function bf(){
     var audio = document.getElementById('music1'); 
     if(audio!==null){             
        //检测播放是否已暂停.audio.paused 在播放器播放时返回false.
         alert(audio.paused);
      if(audio.paused)                     {                 
          audio.play();//audio.play();// 这个就是播放  
      }else{
       audio.pause();// 这个就是暂停
      }
     } 
    }
       
    </script>
    </body>
    </html>
  • 相关阅读:
    算法导论————KMP
    KMP算法
    几个很好的OJ网站
    查找(二分、hash、桶)
    动态规划
    贪心(未完待续)
    搜索的题
    codeVS 1031 质数环
    《将博客搬至CSDN》
    HDU1717小数化分数2
  • 原文地址:https://www.cnblogs.com/kingplus/p/5587441.html
Copyright © 2011-2022 走看看