您的位置:首页 > Web前端 > HTML5

h5 音乐播放

2016-01-26 17:10 483 查看
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no" />
<meta name="apple-touch-fullscreen" content="YES" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>

<audio id="my"  controls="true"  autoplay="autoplay" loop="loop">
<source src="http://map.baidu.com/zt/y2015/waimaibear/mobile/others/WalkingWithAPet-1.mp3">
你的浏览器不支持HTML5
</audio>

<input type="button" onclick="document.getElementById('my').play()" value='播放'/>
<input type="button" onclick="document.getElementById('my').pause()" value='暂停'/>

<div id="star"> 开始</div>
<div>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
var audio=$('#my')[0];
var btn=$('#star');

$('#star').on("click",function(){
if(audio.paused){
audio.play();
}else{
audio.pause();
}

})

</script>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: