Commit cc34407c authored by Chen Jiping's avatar Chen Jiping

完善

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