播放音乐动画暂停继续播放实例

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>播放音乐动画暂停继续</title>
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<style type="text/css">
#longin{
width: 10%;
height: 10%;
position: absolute;
left: 0;
top: 0;
display: none;
z-index:10000000000000000000000000000 ;
}
#longin img{
display: block;
width: 100%;
}
</style>
<body>  
    <div id="longin">
<img src="loading.gif" />
</div>
    <p id="zhixing" style="position: absolute;z-index: 100000;top: 400px;"> 点击执行 </p>
   
   
    <audio id="bgMusic">
    <source = src="hangge.mp3" type="audio/mp3">
    <source = src="hangge.ogg" type="audio/ogg">
</audio>
<script src="js/jquery-2.2.1.min.js" type="text/javascript" charset="utf-8"></script>
     
    <script type="text/javascript">
   
    var audio = document.getElementById("bgMusic");
    var num=0;
    function aa(){
    setInterval(fun1,100)
    }
    function fun1(){
    if(num%2==0){
    audio.pause();
    $("#longin").css("display","none")
    }else{
    $("#longin").css("display","-webkit-box")
    audio.play();
    }
    }
    $("#zhixing").click(function(){
    num++;
    aa()
    })
    </script>
</body>
</html>
阅读更多
文章标签: audio js
个人分类: 技术
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭