Commit caae671e authored by limingzhe's avatar limingzhe

Merge branch 'master' of http://vcs.ireadabc.com/template/JM_4-2

parents 4676b2be 73fa2b2a
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -656,24 +656,41 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -656,24 +656,41 @@ export class PlayComponent implements OnInit, OnDestroy {
this.soundStyleMarginL = -this.curSoundIconIndex * 100 + '%' this.soundStyleMarginL = -this.curSoundIconIndex * 100 + '%'
} }
currentAudio = null;
currentAudioCallback = null;
playSentenceAudio() { playSentenceAudio() {
const mp3Url = this.curSentenceData.audio_url const mp3Url = this.curSentenceData.audio_url
if (!mp3Url) { if (!mp3Url) {
return; return;
} }
if (this.currentAudio) {
this.currentAudio.pause();
if (this.currentAudioCallback) {
this.currentAudioCallback();
this.currentAudioCallback = null;
}
}
const mp3 = new Audio(mp3Url); const mp3 = new Audio(mp3Url);
mp3.play(); //播放 mp3这个音频对象 mp3.play(); //播放 mp3这个音频对象
mp3.addEventListener("ended", () => { this.currentAudio = mp3;
this.currentAudioCallback = () => {
this.stopSoundAnim(); this.stopSoundAnim();
if (!this.isCountDownStart) { if (!this.isCountDownStart) {
this.countDownStart(); this.countDownStart();
} }
}); };
mp3.addEventListener("ended", () => {
if (this.currentAudioCallback) {
this.currentAudioCallback();
this.currentAudioCallback = null;
}
});
this.showSoundAnim(); this.showSoundAnim();
} }
playHtmlAudio(mp3Url, cb=null) { playHtmlAudio(mp3Url, cb=null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment