1
我使用wavesurfer在我的網頁上顯示歌曲波形。我使用下面的代碼 -waveurfer.js destroy()導致Uncaught(在promise中)DOMException:無法關閉正在關閉或已關閉的上下文
function setupSongwaves(songJson) {
var songwaveid = '#song-waveform' + songJson.songid;
var wavesurfer = WaveSurfer.create({
container: songwaveid,
height : 80,
barWidth : 4,
cursorWidth : 2,
waveColor: 'blue',
cursorColor: 'white',
progressColor: 'red'
});
wavesurfer.on('ready', function() {
console.log('ready');
// wavesurfer.play();
setTimeout(function() {
destroyCurrentSongwaves()
},2000);
});
$(document).on("destroy-songwaves", function() {
wavesurfer.destroy();
});
// Hard coding song for now
wavesurfer.load('../assets/song1.mp3');
}
function destroyCurrentSongwaves() {
$.event.trigger({
type: "destroy-songwaves"
});
}
只要wavesurfer.destroy()
叫我在控制檯中看到以下錯誤消息 -
未捕獲的(以諾)拋出:DOMException:無法關閉背景下,是 正在關閉或已關閉。
事情似乎工作正常,但我每次都得到這個錯誤,我不知道什麼似乎是問題。任何幫助,將不勝感激!