h5 音乐播放

<!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>
原文地址:https://www.cnblogs.com/yjhua/p/5161016.html