Commit 11aaf94d authored by Jeff nan's avatar Jeff nan

debug

parent 80a8a613
...@@ -35,20 +35,17 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges { ...@@ -35,20 +35,17 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges {
saveKey = 'listen-choose'; saveKey = 'listen-choose';
isPlaying = false; isPlaying = false;
audio = new Audio(); audio = null;
rightAudio = new Audio(); rightAudio = null;
wrongAudio = new Audio(); wrongAudio = null;
_lc_text = ''; _lc_text = '';
_data = []; _data = [];
constructor(private appRef: ApplicationRef, constructor(private appRef: ApplicationRef,
public changeDetectorRef: ChangeDetectorRef) { public changeDetectorRef: ChangeDetectorRef) {
this.rightAudio.src = 'assets/right.mp3';
this.rightAudio.load();
this.wrongAudio.src = 'assets/wrong.mp3';
this.wrongAudio.load();
} }
canPlayAudio = false;
ngOnInit() { ngOnInit() {
this.data = { this.data = {
contentObj: { contentObj: {
...@@ -62,6 +59,19 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges { ...@@ -62,6 +59,19 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges {
} }
}; };
window['courseware'].onEvent('course-in-screen', () => {
setTimeout(() => {
this.audio = new Audio();
this.audio.src = this.data.contentObj.audio_id;
this.rightAudio = new Audio();
this.rightAudio.src = 'assets/right.mp3';
this.wrongAudio = new Audio();
this.wrongAudio.src = 'assets/wrong.mp3';
this.canPlayAudio = true;
}, 1500);
});
// 获取数据 // 获取数据
const getData = ( window as any).courseware.getData; const getData = ( window as any).courseware.getData;
getData((data) => { getData((data) => {
...@@ -96,11 +106,9 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges { ...@@ -96,11 +106,9 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges {
} }
playCount = 0;
playAudio() { playAudio() {
if (this.playCount == 0 && this.data.contentObj && this.data.contentObj.audio_id) { if (!this.canPlayAudio) {
this.playCount = 1; return;
this.audio = new Audio(this.data.contentObj.audio_id);
} }
if (this.data.contentObj && this.data.contentObj.audio_id) { if (this.data.contentObj && this.data.contentObj.audio_id) {
if (this.isPlaying) { if (this.isPlaying) {
...@@ -124,12 +132,15 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges { ...@@ -124,12 +132,15 @@ export class PlayComponent implements OnInit, OnDestroy, OnChanges {
} }
handleTap(ev, item) { handleTap(ev, item) {
if (!this.canPlayAudio) {
return;
}
if (item.is_right) { if (item.is_right) {
item.state = 'right'; item.state = 'right';
new Audio(this.rightAudio.src + '?v=' + new Date().getTime()).play(); this.rightAudio.play();
} else { } else {
item.state = 'wrong'; item.state = 'wrong';
new Audio(this.wrongAudio.src + '?v=' + new Date().getTime()).play(); this.wrongAudio.play();
setTimeout(() => { setTimeout(() => {
item.state = ''; item.state = '';
}, 1500); }, 1500);
......
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