我試圖用DART和Chrome使用html5音頻,並且我正在儘可能使用AudioElement的簡單方法。我希望能夠暫停聲音並在稍後恢復。我有:AudioElement恢復播放口吃一秒鐘,並停止
startSound() {
audioElement.src = "foo";
audioElement.load();
audioElement.play();
}
pause() {
this.time = audioElement.currentTime;
audioElement.pause();
}
unpause() {
audioElement.currentTime = this.time;
audioElement.play();
}
這些連接到事件處理程序,所以當有人點擊'暫停'按鈕,播放停止。然而,當他們點擊「恢復」按鈕時,只有大約半秒鐘的時間纔會再次停止播放。
如何讓音頻恢復正常?