Commit 4beec0cf authored by 李维's avatar 李维

.

parent c5832a8f
......@@ -1958,7 +1958,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 154.07,
"width": 110.43,
"height": 40.32
},
"_anchorPoint": {
......@@ -2010,8 +2010,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "进度:13/23",
"_N$string": "进度:13/23",
"_string": "进度:-/-",
"_N$string": "进度:-/-",
"_fontSize": 28,
"_lineHeight": 32,
"_enableWrapText": true,
......@@ -2053,7 +2053,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 99.57,
"width": 93.32,
"height": 40.32
},
"_anchorPoint": {
......@@ -2105,8 +2105,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "成功:1",
"_N$string": "成功:1",
"_string": "成功:-",
"_N$string": "成功:-",
"_fontSize": 28,
"_lineHeight": 32,
"_enableWrapText": true,
......@@ -2148,7 +2148,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 99.57,
"width": 93.32,
"height": 40.32
},
"_anchorPoint": {
......@@ -2200,8 +2200,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "失败:2",
"_N$string": "失败:2",
"_string": "失败:-",
"_N$string": "失败:-",
"_fontSize": 28,
"_lineHeight": 32,
"_enableWrapText": true,
......
......@@ -64,6 +64,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.startBtn.on("click", ()=>{
this.startCheck();
})
this.stopBtn.on("click", ()=>{
this.stopTest();
})
}
initData() {
......@@ -71,18 +75,17 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
async startCheck() {
this.isStop = false;
const audioUrl = [];
this.data.forEach(item => {
audioUrl.push({
id: item.id,
type: "cn",
name: item.text_cn,
audio_url: item.audio_cn_url
})
audioUrl.push({
id: item.id,
type: "en",
name: item.text_en,
audio_url: item.audio_url
})
});
......@@ -94,11 +97,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.updateSummaryInfo()
for(let i=0; i<audioUrl.length; i++) {
const res = await this.testAudioPlay(audioUrl[i].audio_url)
if(this.isStop) {
break
}
this.summaryInfo_now = i + 1;
if(res) {
this.inputText(`播放成功! id:${audioUrl[i].id} 资源名:${audioUrl[i].name}`);
this.inputText(`播放成功! id:${audioUrl[i].id}`);
this.summaryInfo_success ++;
} else {
this.inputText(`播放失败! id:${audioUrl[i].id} 资源名:${audioUrl[i].name}`);
this.inputText(`播放失败! id:${audioUrl[i].id}`);
console.log(`Fail: id=${audioUrl[i].id} type=${audioUrl[i].type}`)
this.summaryInfo_fail ++;
}
......@@ -107,6 +114,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.inputText(`检测完成,总计【${this.summaryInfo_total}】 成功【${this.summaryInfo_success}】 失败【${this.summaryInfo_fail}】`);
}
isStop = false;
stopTest() {
if(this._intervalId) {
clearInterval(this._intervalId);
this._intervalId = null;
}
if(this._resovle) {
this._resovle(false);
this._resovle = null;
}
this.isStop = true;
}
// 输入文字
inputText(str) {
this.outputBox.getComponent(cc.Label).string = str;
......@@ -140,24 +161,30 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
_intervalId = null;
_resovle = null;
testAudioPlay(audio_url) {
return new Promise((resovle, reject) => {
cc.assetManager.loadRemote(audio_url, (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
const audioId = cc.audioEngine.play(audioClip, false, 0.1);
if(this._intervalId != null) {
clearInterval(this._intervalId);
this._intervalId = null;
}
let count = 0;
this._resovle = resovle;
this._intervalId = setInterval(() => {
if(cc.audioEngine.getCurrentTime(audioId) > 0) {
clearInterval(this._intervalId);
this._intervalId = null;
cc.audioEngine.stop(audioId);
this._resovle = null;
resovle(true)
} else {
if(count > 50) {
clearInterval(this._intervalId);
this._intervalId = null;
cc.audioEngine.stop(audioId);
this._resovle = null;
resovle(false)
} else {
count++
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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