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

.

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