[英]Handling multiple objects
我正在構建音樂混音器,但是我不知道如何創建多個對象。
由於無法像在循環中那樣創建動態對象名稱,因此我不知道如何處理
var wavesurfer = WaveSurfer.create({
container: '.regua div[regua-item="index-0"]',
scrollParent : true
});
wavesurfer.load('link.mp3');
wavesurfer.play();
問題是我不能多次調用它,因為它會重寫wavesurfer.load
的鏈接
像這樣:
wavesurfer.load('link_2.mp3') // once i load another music this one will be destroyed
wavesurfer.load('link_3.mp3')
這里有什么解決方案?
您可以嘗試將setInterval()與if語句一起使用,該語句檢測是否通過使用.ended()完成waveurfer 。 像這樣:
let musicInterval = setInterval(function(){
if(wavesurfer.ended()){
//Your code
// this is to clear the interval, if that is what you want.
clearInterval(musicInterval)
}
},100)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.