Html 在SoundManager中循环音频而不缓存
有没有办法在没有缓存的情况下循环SoundManager,使其每次都被迫重新加载源音频文件?我可以让它循环,但我不能让它不缓存Html 在SoundManager中循环音频而不缓存,html,html5-audio,soundmanager2,Html,Html5 Audio,Soundmanager2,有没有办法在没有缓存的情况下循环SoundManager,使其每次都被迫重新加载源音频文件?我可以让它循环,但我不能让它不缓存 <script type="text/javascript"> soundManager.url = '../../swf/soundmanager2.swf'; soundManager.debugMode = true; soundManager.consoleOnly = true; soundManager.onload = function()
<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>
soundManager.url='../../swf/soundmanager2.swf';
soundManager.debugMode=true;
soundManager.consoleOnly=true;
soundManager.onload=函数(){
soundManager.createSound({
id:'mySound1',
url:'path/to/audio.mp3',
溪流:对
});
loopSound('mySound1');
}
函数loopSound(soundID){
setTimeout(函数(){
play(soundID,{onfinish:function(){loopSound(soundID);}});
},1);
}
目前,这是我提出的解决方案:
<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>
soundManager.setup({
url:“../swf/”,
//可选:在可用的情况下使用100%HTML5模式
//A:错,
onready:function(){
var sound=soundManager.createSound({
id:'mySound1',
url:'path/to/audio.mp3',
onfinish:function(){
soundManager._writeDebug(this.id+'已完成当前曲目,现在正在加载下一首曲目');
//破坏这声音
这个。unload();
soundManager.createSound({
id:'mySound1',
url:'path/to/audio.mp3',
});
soundManager.play('mySound1');
},
自动播放:对
});
}
});
将id:更改为其他id将避免清除缓存
即使URL的路径不同,如果ID相同,歌曲也会重播
如果更改,请执行以下操作:
id: 'mySound1',
因此,新歌将播放的每个独特曲目都是独一无二的
id: 'mySound1'+id,
欢迎来到堆栈溢出。请在您的答案中添加一些描述,以解释为什么这适用于该问题
...
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
}
},
...