html5网页想要加一个音乐播放器可以怎么做?

html5网页想要加一个音乐播放器可以怎么做?,第1张

可以使用html5的audio标签来添加音乐播放器

<audio controls>

type:指定文件类型  

<source src="horse.ogg" type="audio/ogg">

   <source src="horse.mp3" type="audio/mpeg">

</audio>

对应的参数属性如下图:

不能修改(不同浏览器表现的默认播放器是不一样得),唯一的方法就是你自己制作按钮样式后通过Js把相应的功能嵌套到你的按钮中:

具体参考http://www.runoob.com/try/try.php?filename=tryhtml5_video_js_prop

播放器可以弄自定义样式的

html:

<div style="text-align:center">

   <div>

       <button onclick="playPause()">播放/暂停</button> 

       <button onclick="makeBig()">大</button>

       <button onclick="makeNormal()">中</button>

       <button onclick="makeSmall()">小</button>

   </div>

   <video id="video1" width="420" style="margin-top:15px">

       <source src="http://www.w3school.com.cn/i/movie.mp4" type="video/mp4" />

       <source src="http://www.w3school.com.cn/i/movie.ogg" type="video/ogg" />

       Your browser does not support HTML5 video.

</video>

</div> 

js:

var myVideo=document.getElementById("video1")

function playPause(){ 

   if (myVideo.paused) 

       myVideo.play() 

   else 

       myVideo.pause() 

function makeBig(){ 

   myVideo.width=560 

function makeSmall(){ 

   myVideo.width=320 

function makeNormal(){ 

   myVideo.width=420 

}

布局样式在css里改可以了

参考http://w3school.com.cn/html5/html_5_video_dom.asp


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/7941908.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-11
下一篇2023-04-11

发表评论

登录后才能评论

评论列表(0条)

    保存