0

有没有办法在没有缓存的情况下循环 SoundManager,以便每次都强制重新加载源音频文件?我可以让它循环,但我不能让它不缓存。

<script type="text/javascript">
soundManager.url = '../../swf/soundmanager2.swf';
soundManager.debugMode = true;
soundManager.consoleOnly = true;

soundManager.onload = function() {
soundManager.createSound({
id:'mySound1',
url:'path/to/audio.mp3',
stream: true
});
loopSound('mySound1');
}

function loopSound(soundID) {
window.setTimeout(function() {
soundManager.play(soundID,{onfinish:function(){loopSound(soundID);}});
},1);
}</script>
4

3 回答 3

0

目前,这是我想出的解决方案:

<script>
soundManager.setup({
  url: '../swf/',
  // optional: use 100% HTML5 mode where available
  // preferFlash: false,
  onready: function() {
   var sound = soundManager.createSound({
 id: 'mySound1',
 url: 'path/to/audio.mp3',
 onfinish: function() {
  soundManager._writeDebug(this.id+' has finished the current track, now loading next track.');
  // destroy this sound
  this.unload();
  soundManager.createSound({
 id: 'mySound1',
 url: 'path/to/audio.mp3',
});
  soundManager.play('mySound1');
 },
 autoPlay: true
 });

  }
});
</script>
于 2013-04-11T21:49:08.283 回答
0

将 id: 更改为不同的将避免需要清除缓存。

似乎即使 URL 的路径不同,如果 ID 相同,也会重播歌曲。

如果更改:

id: 'mySound1',

这样它对于新歌曲将播放的每个独特曲目都是独一无二的。

id: 'mySound1'+id,
于 2015-06-02T02:31:06.237 回答
0
...
onload: function(){
                  if(this.readyState==2){ //ERROR HTML5 player
                      console.log('ERRORS readyState');
                      stop_play(id); // function stop play id
                      start_play(url); // function start play
                  }
},
...
于 2016-12-13T20:15:11.047 回答