如何从Html5音频中获取curentTime。我没有放置音频html标签。我只想在typescript.i中执行此操作。I get TypeError:无法读取未定义的属性'currentTime‘。我认为当前的环境有问题吗?我如何使用apply & bind或任何其他技术来修复它?
//player.ts
audio = new Audio();
btnPlay(){
this.audio.src = "media/Audio_1.mp3";
this.audio.load();
this.audio.play();
this.audio.addEventListener('timeupdate',this.timeupdate)
}
timeupdate(e){
console.log(this.audio.currentTime);
}
发布于 2019-04-24 03:06:13
使timeupdate
成为箭头函数:
timeupdate = (e) => {
console.log(this.audio.currentTime);
}
有关详细信息,请参阅https://www.typescriptlang.org/docs/handbook/functions.html#this-and-arrow-functions。
https://stackoverflow.com/questions/55804106
复制相似问题