使用JS播放声音——SoundManager 2

<!DOCTYPE html>
<html>
<head>
    <meta charset=utf-8 />
    <title>SoundDemo</title>
    <script type="text/javascript" src="script/soundmanager2-nodebug-jsmin.js"></script>
    <script type="text/javascript" src="script/jquery-1.10.0.min.js"></script>
    <script type="text/javascript">
      soundManager.setup({
        url: 'swf/', //swf文件夹的位置
        onready: function() {
          soundManager.createSound({
            id: 'msg',
            autoLoad: true,
            autoPlay: false,
            url: 'sound/msg.mp3' //mp3文件的位置
          });
        }
      });
      $(document).ready(function () {
        $('#play').click(function () {
          soundManager.play('msg'); //点击按钮可播放
        });
      });
    </script>
</head>
<body>
    <input type='button' id='play' value='Play' />
</body>
</html>
posted @ 2017-10-30 14:21  人情世故  阅读(2042)  评论(0编辑  收藏  举报
"不管做什么,只要坚持下去就会看到不一样!在路上,不卑不亢!"