Commit cc34407c authored by Chen Jiping's avatar Chen Jiping

完善

parent 80eba6ad
...@@ -28,10 +28,10 @@ export class Exercises { ...@@ -28,10 +28,10 @@ export class Exercises {
wordSplitPic:ShapeRect = null; wordSplitPic:ShapeRect = null;
/**单词发音 */ /**单词发音 */
wordAudioUrl:''; wordAudioKey;
/**字母(组合)发音 */ /**字母(组合)发音 */
letterAudioUrl:''; letterAudioKey;
/**单词拆分的字母(组合) */ /**单词拆分的字母(组合) */
letterArr = []; letterArr = [];
......
...@@ -72,6 +72,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -72,6 +72,8 @@ export class PlayComponent implements OnInit, OnDestroy {
/**音频播放状态 */ /**音频播放状态 */
playStatus = false; playStatus = false;
isListenAudio = false;
/**当前播放的curAudio */ /**当前播放的curAudio */
curAudio; curAudio;
...@@ -548,19 +550,19 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -548,19 +550,19 @@ export class PlayComponent implements OnInit, OnDestroy {
this.addUrlToAudioObj('click', this.rawAudios.get('click'), 0.3); this.addUrlToAudioObj('click', this.rawAudios.get('click'), 0.3);
//标题发音 //标题发音
this.addUrlToAudioObj(this.data.title.audioUrl); this.addUrlToAudioObj('titleAudio', this.data.title.audioUrl);
//听力材料 //听力材料
this.addUrlToAudioObj(this.data.listenAudioUrl); this.addUrlToAudioObj('listenAudio', this.data.listenAudioUrl);
//单词音效 //单词音效
for (let i = 0; i < this.data.exercisesArr.length; ++i) { for (let i = 0; i < this.data.exercisesArr.length; ++i) {
let exercises = this.data.exercisesArr[i]; let exercises = this.data.exercisesArr[i];
this.addUrlToAudioObj(exercises.audioUrl); this.addUrlToAudioObj('exercises' + i, exercises.audioUrl);
this.addUrlToAudioObj(exercises.letterCombinations.audioUrl); this.addUrlToAudioObj('exercises_letter' + i, exercises.letterCombinations.audioUrl);
} }
} }
...@@ -757,6 +759,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -757,6 +759,10 @@ export class PlayComponent implements OnInit, OnDestroy {
exercisesObj.bg = exercisesBg; exercisesObj.bg = exercisesBg;
exercisesObj.wordAudioKey = "exercises" + i;
exercisesObj.letterAudioKey = 'exercises_letter' + i;
//单词图片 //单词图片
this.initWordPic(this.data.exercisesArr[i], exercisesObj); this.initWordPic(this.data.exercisesArr[i], exercisesObj);
...@@ -769,9 +775,6 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -769,9 +775,6 @@ export class PlayComponent implements OnInit, OnDestroy {
initWordPic(exercises, exercisesObj: Exercises) { initWordPic(exercises, exercisesObj: Exercises) {
exercisesObj.wordAudioUrl = exercises.audioUrl;
exercisesObj.letterAudioUrl = exercises.letterCombinations.audioUrl;
//最短 //最短
let sWidth = 120; let sWidth = 120;
...@@ -863,7 +866,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -863,7 +866,7 @@ export class PlayComponent implements OnInit, OnDestroy {
const answerBg = new MySprite(); const answerBg = new MySprite();
answerBg.init(this.images.get('answer')); answerBg.init(this.images.get('answer'));
answerBg.setScaleXY(this.mapScale);
answerBg.x = -wordBg.width / 2 + answerBg.width / 2 + 13 ; answerBg.x = -wordBg.width / 2 + answerBg.width / 2 + 13 ;
answerBg.y = - 5 * this.mapScale; answerBg.y = - 5 * this.mapScale;
answerBg.alpha = 0; answerBg.alpha = 0;
...@@ -878,10 +881,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -878,10 +881,10 @@ export class PlayComponent implements OnInit, OnDestroy {
answerIndex.fontColor = "#000000"; answerIndex.fontColor = "#000000";
answerIndex.refreshSize(); answerIndex.refreshSize();
answerIndex.alpha = 0; answerIndex.alpha = 0;
answerIndex.setMaxSize(80 * this.mapScale);
answerIndex.y = 0; answerIndex.y = 0;
answerIndex.x = - answerIndex.getBoundingBox().width/2 + 13; answerIndex.x = - answerIndex.getBoundingBox().width/2 + 5 * this.mapScale;
answerBg.addChild(answerIndex); answerBg.addChild(answerIndex);
//answerBg.setScaleXY(this.mapScale);
exercisesObj.answerIndexLabel = answerIndex; exercisesObj.answerIndexLabel = answerIndex;
} }
...@@ -962,6 +965,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -962,6 +965,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if(this.curAudio){ if(this.curAudio){
this.curAudio.pause(); this.curAudio.pause();
} }
this.isListenAudio = true;
this.setListenPlayStatus(); this.setListenPlayStatus();
} }
...@@ -977,14 +981,16 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -977,14 +981,16 @@ export class PlayComponent implements OnInit, OnDestroy {
if(this.playStatus){ if(this.playStatus){
this.playStatus = false; this.playStatus = false;
this.pauseAudio(this.data.listenAudioUrl); this.pauseAudio('listenAudio');
this.btnPlay.alpha = 1; this.btnPlay.alpha = 1;
this.btnStop.alpha = 0; this.btnStop.alpha = 0;
} }
else{ else{
this.playAudio(this.data.listenAudioUrl, false, ()=>{
this.playAudio('listenAudio', false, ()=>{
this.playStatus = false; this.playStatus = false;
...@@ -1011,10 +1017,13 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1011,10 +1017,13 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
//如果不是播放听力材料,则暂停当前播放音频 //如果不是播放听力材料,则暂停当前播放音频
if(!this.playStatus){ if(this.curAudio){
if(this.curAudio){
if(!this.isListenAudio){
this.curAudio.pause(); this.curAudio.pause();
this.curAudio.currentTime = 0;
} }
} }
if (this.checkClickTarget(this.btnPlay) && !this.playStatus) { if (this.checkClickTarget(this.btnPlay) && !this.playStatus) {
...@@ -1030,12 +1039,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1030,12 +1039,8 @@ export class PlayComponent implements OnInit, OnDestroy {
//点击标题 //点击标题
if (this.checkClickTarget(this.titleBg)) { if (this.checkClickTarget(this.titleBg)) {
if(this.playStatus){
this.setListenPlayStatus();
}
//播放发音 //播放发音
this.playAudio(this.data.title.audioUrl); this.playOtherAudio('titleAudio');
return; return;
} }
...@@ -1048,22 +1053,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1048,22 +1053,14 @@ export class PlayComponent implements OnInit, OnDestroy {
//点击图片 //点击图片
if(this.checkClickTarget(exercises.wordPic)){ if(this.checkClickTarget(exercises.wordPic)){
if(this.playStatus){ this.playOtherAudio(exercises.wordAudioKey);
this.setListenPlayStatus();
}
this.playAudio(exercises.wordAudioUrl);
return; return;
} }
//点击圆圈 //点击圆圈
if(this.checkClickTarget(exercises.letterCombinations)){ if(this.checkClickTarget(exercises.letterCombinations)){
if(this.playStatus){ this.playOtherAudio(exercises.letterAudioKey);
this.setListenPlayStatus();
}
this.playAudio(exercises.letterAudioUrl);
return; return;
} }
...@@ -1073,11 +1070,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1073,11 +1070,7 @@ export class PlayComponent implements OnInit, OnDestroy {
//如果未加载,则加载 //如果未加载,则加载
if(exercises.showed){ if(exercises.showed){
if(this.playStatus){ this.playOtherAudio(exercises.wordAudioKey);
this.setListenPlayStatus();
}
this.playAudio(exercises.wordAudioUrl);
return; return;
} }
else{ else{
...@@ -1113,6 +1106,16 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1113,6 +1106,16 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
playOtherAudio(key, callback = null){
if(this.playStatus){
this.setListenPlayStatus();
}
this.isListenAudio = false;
this.playAudio(key, callback);
}
update() { update() {
......
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