音频播放播放进度设置无效

const src = audio.src;
audio.src = this.music[0];
audio.volume = 1.0;
console.info(this.currentTime);

let currentTime = audio.currentTime;
audio.currentTime = 5.0;
audio.play();
audio.ontimeupdate = function() {
  this.currentTime = audio.currentTime;
  // this.src = this.music[this.index]
  console.log(`audio current time: ` + this.currentTime);
};

你这个是因为动态改变了 audio.src 相当于音频又重置了,目前没有想到好的办法解决,暂时可以考虑通过 setTimeout 延迟再去修改 currentTime 实现

参考 快应用论坛回复

results matching ""

    No results matching ""