html5之<video>开发实现音乐播放控…

来源:互联网 发布:python 期货 编辑:程序博客网 时间:2024/04/28 06:38
<!DOCTYPEhtml>
<html>
<head>
   <meta charset="utf-8">
   <title>控制音乐播放的html5程序</title>
   <style>
       #mymusic{
          border: 1px solid red;
          width: 600px;
          height: 400px;
       }
   </style>
   <script>
       functionaudioPlay(){
           document.getElementByIdx_x("myaudio").play();
       }

       functiongoToFirst(){
         document.getElementByIdx_x("myaudio").currentTime=0;
         document.getElementByIdx_x("myaudio").play();
       }

       functionaudioPause(){
         document.getElementByIdx_x("myaudio").pause();
       }
   </script>
</head>
<body>
   <div id="mymusic">
      <!--
         paly()  播放
         pause()  暂停
         load()  加载
         canPlayType() 是否可以播放,不可以为空,可以maybe
         currentTime  当前播放时间
         duration   视频/音频的时长
         paused   是否暂停
         ended  是否播放到最后
         playbackRate 播放速度,2表示两倍,可以指定小数,指定数值太大时候,不能够播放声音
      -->
       <audioid="myaudio">
          <sourcesrc="video/first.ogg">
          播放音频
      </audio>
       <buttononclick="audioPlay()">播放</button>
       <buttononclick="goToFirst()">从头播放</button>
       <buttononclick="audioPause()">暂停</button>
   </div>
</body>
</html>
0 0
原创粉丝点击