Posible SoundManager 2播放本地声音?

时间:2015-08-20 15:32:44

标签: javascript php jquery html soundmanager2

我在Localhost上创建了一个音乐库,是否可以使用SoundManager 2播放带路径的本地声音文件,例如:D:/Music/file.mp3。

1 个答案:

答案 0 :(得分:0)

<

!DOCTYPE html>
<html>
<head>
  <title></title>
</head>
<body>
<a href="" id="play">play</a>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="js/soundmanager2-nodebug-jsmin.js"></script>
<script type="text/javascript">
$('#play').click(function(e){
  e.preventDefault()
  soundManager.setup({
    url: '/js/',
    onready: function() {
      var mySound = soundManager.createSound({
        id: 'aSound',
        url: 'path/to/file.mp3'
      });
      mySound.play();
    },
    ontimeout: function() {
      // Hrmm, SM2 could not start. Missing SWF? Flash blocked? Show an error, etc.?
    }
  });
})
</script>
</body>
</html>