我有一个简单的角度应用程序中使用下面的JavaScript网页音频对象是角视图模型后没有更新的变化
app.component.ts
export class AppComponent {
title = 'media player';
audio;
currentTime: number;
constructor() {
this.audio = new Audio();
this.audio.src = './Music/demo2.MP3';
this.audio.play();
this.currentTime = this.audio.currentTime;
}
}
和 app.component.ts
播放音频<h4>{{ currentTime }}</h4>
一切工作正常,但认为不作为模型更新改变
您不能绑定到'audio.currentTime'吗? – user184994
这是因为此行'this.currentTime = this.audio.currentTime;'只在组件加载时运行一次。您需要确保每秒更新一行。或者@ user184994方法也可以工作。 –
@PraveenM是我低于和'this.currentTime = this.audio.currentTime;'只运行一次。请你知道一种方法来使这些工作。 –