Commit 7bd290c9 authored by Chen Jiping's avatar Chen Jiping

fix:增加测试代码;调整音频播放

parent efb43eff
......@@ -308,6 +308,8 @@ export class PlayComponent implements OnInit, OnDestroy {
const audio = this.audioObj[key];
if (audio) {
this.pauseAudio(this.curAudio);
if (now) {
audio.pause();
audio.currentTime = 0;
......@@ -319,6 +321,21 @@ export class PlayComponent implements OnInit, OnDestroy {
};
}
audio.play();
this.curAudio = audio;
return audio;
}
}
pauseAudio(audio){
if (audio) {
if (this.listening && audio == this.listening.audio) {
this.listening.pauseAudio();
}
else {
audio.pause();
}
}
}
......@@ -689,7 +706,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.startY = startY;
this.initY = startY;
let viewHight = 560 * this.mapScale;
let viewHight = Math.floor( 560 * this.mapScale);
const bg = new ShapeRect();
bg.setSize(680 * this.mapScale, viewHight);
......@@ -701,7 +718,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let y = 0;
let dH = 24 * this.mapScale;
let dH = Math.floor(24 * this.mapScale) ;
let totalHeight = 0;
......@@ -745,9 +762,9 @@ export class PlayComponent implements OnInit, OnDestroy {
}
let scrollbar = new Scrollbar();
scrollbar.init(this.mapScale, this.mapScale, viewHight, totalHeight - dH, 14);
scrollbar.init(this.mapScale, this.mapScale, viewHight, Math.floor(totalHeight - dH), 14);
scrollbar.showScrollbar();
scrollbar.hide();
//scrollbar.hide();
scrollbar.bg.x = this.canvasWidth / 2 + 161 * this.mapScale;
scrollbar.bg.y = this.canvasHeight / 2 - 231 * this.mapScale;
this.renderArr.push(scrollbar.bg);
......@@ -761,17 +778,15 @@ export class PlayComponent implements OnInit, OnDestroy {
return;
}
if (this.curAudio) {
if (this.curAudio == this.listening.audio) {
this.listening.pauseAudio();
}
else {
this.curAudio.pause();
}
}
if (this.listening && this.checkClickTarget(this.listening.bg)) {
let tempAudio = this.curAudio;
if(tempAudio){
tempAudio.pause();
}
this.curAudio = this.listening.play(() => {
this.listening.reset();
});
......@@ -780,7 +795,11 @@ export class PlayComponent implements OnInit, OnDestroy {
}
if (this.checkClickTarget(this.title.titleBg)) {
this.curAudio = this.title.playAudio();
this.pauseAudio(this.curAudio);
let audio = this.title.playAudio();
if(audio){
this.curAudio = audio;
}
return;
}
......@@ -809,7 +828,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if (this.checkClickTarget(sentenceSpr) && sentenceSpr.visible && sentenceSpr.alpha == 1) {
clicked = true;
this.curAudio = this.playAudio(sentenceSpr.data.audioUrl, true);
this.playAudio(sentenceSpr.data.audioUrl, true);
break;
}
}
......@@ -896,7 +915,7 @@ export class PlayComponent implements OnInit, OnDestroy {
indexItem.sentence = sentence;
}
this.curAudio = this.playAudio(sentence.audioUrl, true);
this.playAudio(sentence.audioUrl, true);
let spr;
......@@ -933,7 +952,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let dH = 24 * this.mapScale;
console.log(offsetY, Math.floor(this.initY), Math.floor(this.initY + this.sentenceBg.height))
//如果句子不在可视窗口,则进行定位滚动
if(offsetY < Math.floor(this.initY) || offsetY >= Math.floor(this.initY + this.sentenceBg.height)){
......
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