有没有办法在没有缓存的情况下循环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>
答案 0 :(得分: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>
答案 1 :(得分:0)
将id:更改为另一个将避免需要清除缓存。
即使URL的路径不同,如果ID相同,也会重播该歌曲。
如果改变:
id: 'mySound1',
因此新歌将播放的每首独特曲目都是唯一的。
id: 'mySound1'+id,
答案 2 :(得分: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
}
},
...