Commit 83e23f5b authored by limingzhe's avatar limingzhe

update startBtn touch enable

parent 6c59cff2
...@@ -218,15 +218,27 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -218,15 +218,27 @@ export class PlayComponent implements OnInit, OnDestroy {
load() { load() {
// window["air"].hideAirClassLoading(this.saveKey, this.data);
// console.log('in load 1');
this.loadResources().then(() => { this.loadResources().then(() => {
// console.log('in load 2');
this.init(); this.init();
// console.log('in load 3');
this.update(); this.update();
// console.log('in load 4');
this.addServerListener(); this.addServerListener();
// console.log('in load 5');
window["air"].hideAirClassLoading(this.saveKey, this.data); window["air"].hideAirClassLoading(this.saveKey, this.data);
// console.log('in load 6');
}); });
} }
...@@ -273,6 +285,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -273,6 +285,7 @@ export class PlayComponent implements OnInit, OnDestroy {
const c = (<any> window).courseware; const c = (<any> window).courseware;
c.onEvent('userchange', (data, next) => { c.onEvent('userchange', (data, next) => {
//data的结构如下 //data的结构如下
/*{ /*{
...@@ -336,6 +349,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -336,6 +349,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.teacherPage.visible = true; this.teacherPage.visible = true;
} }
this.canTouch = true;
next(); next();
}); });
...@@ -394,7 +409,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -394,7 +409,6 @@ export class PlayComponent implements OnInit, OnDestroy {
this.addTeacherPageData(data); this.addTeacherPageData(data);
} }
next(); next();
}); });
...@@ -600,19 +614,25 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -600,19 +614,25 @@ export class PlayComponent implements OnInit, OnDestroy {
playAudio(key, now = false, callback = null) { playAudio(key, now = false, callback = null) {
const audio = this.audioObj[key]; const audio = this.audioObj[key];
if (audio) {
if (now) {
audio.pause();
audio.currentTime = 0;
}
if (callback) { try {
audio.onended = () => { if (audio) {
callback(); if (now) {
}; audio.pause();
audio.currentTime = 0;
}
if (callback) {
audio.onended = () => {
callback();
};
}
audio.play();
} }
audio.play(); } catch (e) {
console.log('e: ', e);
} }
} }
...@@ -656,14 +676,21 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -656,14 +676,21 @@ export class PlayComponent implements OnInit, OnDestroy {
preloadAudio(url) { preloadAudio(url) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const audio = new Audio(); const audio = new Audio();
audio.oncanplay = (a) => { // audio.addEventListener('loadedmetadata', () => {
resolve(); // resolve();
}; // });
// audio.oncanplay = (a) => {
// resolve();
// };
audio.onerror = () => { audio.onerror = () => {
reject(); reject();
}; };
audio.src = url; audio.src = url;
audio.load(); audio.load();
resolve();
}); });
} }
...@@ -884,8 +911,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -884,8 +911,6 @@ export class PlayComponent implements OnInit, OnDestroy {
this.syncPage(); this.syncPage();
} }
syncPage() { syncPage() {
...@@ -2554,6 +2579,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2554,6 +2579,8 @@ export class PlayComponent implements OnInit, OnDestroy {
this.sendServerEvent('startGame', {roleData, roleIndex, wordArr, gameResultArr, date, start: true}); this.sendServerEvent('startGame', {roleData, roleIndex, wordArr, gameResultArr, date, start: true});
this.canTouch = false;
} }
sendServerNewRound() { sendServerNewRound() {
......
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