2017-03-02 105 views
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:无法关闭背景下,是 正在关闭或已关闭。

事情似乎工作正常,但我每次都得到这个错误,我不知道什么似乎是问题。任何帮助,将不胜感激!

回答

1

尝试将Wavesurfer升级到当前最新版本1.3.7,它应该解决问题。