Commit ba3e915d authored by Tt's avatar Tt

录音回拨功能增加

parent a2d2680c
......@@ -55,8 +55,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
960,
540,
0,
0,
0,
......@@ -268,7 +268,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "87B5iKbmVCG49S3eGPMX6Y",
"sync": false
......@@ -375,7 +375,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "0dJz4b1ElNA4O7qSiigyoD",
"sync": false
......@@ -482,7 +482,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "29MTzfz4ZJY5RAZYwGGyzy",
"sync": false
......@@ -589,7 +589,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "4bI88i+L9GR5mwmTy9p9U4",
"sync": false
......@@ -704,7 +704,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "bfmkl7sk1AkKt8zX7VXGXI",
"sync": false
......@@ -847,7 +847,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "9dj4iTb+pEI58ageziAqnd",
"sync": false
......@@ -873,7 +873,7 @@
"__id__": 31
}
],
"_active": false,
"_active": true,
"_components": [
{
"__id__": 34
......@@ -931,7 +931,7 @@
},
{
"__type__": "cc.Node",
"_name": "p1",
"_name": "p0",
"_objFlags": 0,
"_parent": {
"__id__": 21
......@@ -1009,7 +1009,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "84c11178-f263-4e14-aa51-104545bb5499"
"__uuid__": "c9eb055f-e3e0-4f6e-9e05-45d7c4608877"
},
"_type": 0,
"_sizeMode": 1,
......@@ -1031,14 +1031,14 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "fbQ2idx8VGzpMfXJAlUOXZ",
"fileId": "bdZKY4yrNNrp3uiGJ2mSt/",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "p0",
"_name": "p1",
"_objFlags": 0,
"_parent": {
"__id__": 21
......@@ -1116,7 +1116,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "c9eb055f-e3e0-4f6e-9e05-45d7c4608877"
"__uuid__": "84c11178-f263-4e14-aa51-104545bb5499"
},
"_type": 0,
"_sizeMode": 1,
......@@ -1138,9 +1138,9 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "bdZKY4yrNNrp3uiGJ2mSt/",
"fileId": "fbQ2idx8VGzpMfXJAlUOXZ",
"sync": false
},
{
......@@ -1245,7 +1245,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "50FwDbDDFGEpKc84rgx9jB",
"sync": false
......@@ -1352,7 +1352,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "c0INCALCJCWbSmpeyJ9a58",
"sync": false
......@@ -1390,7 +1390,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "c1eTuWbUBDEofGhSF4EZXo",
"sync": false
......@@ -1428,7 +1428,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "2ertaiEAVHrqIyQ0eZHP8i",
"sync": false
......@@ -1476,7 +1476,7 @@
"__id__": 1
},
"asset": {
"__id__": 0
"__uuid__": "35fbe4f1-249e-4263-90a1-de923c148363"
},
"fileId": "",
"sync": false
......
......@@ -21,14 +21,17 @@ export default class LayerRecord extends cc.Component {
}
private letter: string;
private targetTime: number;
private recordAudio: string;
initEvent() {
pg.event.on('layer_record_setting', (data) => {
this.letter = data.letter
this.targetTime = data.targetTime
})
let btn_record = pg.view.find(this.layout_record, 'btn_record');
let btn_play = pg.view.find(this.layout_record, 'btn_play');
btn_record.on(cc.Node.EventType.TOUCH_START, this.onTouchRecord, this);
btn_record.on(cc.Node.EventType.TOUCH_END, this.onTouchRecordEnd, this);
btn_play.on(cc.Node.EventType.TOUCH_END, this.onTouchPlayRecord, this);
}
showVoiceWhite() {
......@@ -58,6 +61,68 @@ export default class LayerRecord extends cc.Component {
let record_time = pg.view.find(this.layout_record, 'record_time');
record_time.getComponent(cc.Sprite).fillRange = 0;
}
showPlay() {
let btn_play = pg.view.find(this.layout_record, 'btn_play')
btn_play.active = !!this.recordAudio
let p0 = pg.view.find(btn_play, 'p0')
let p1 = pg.view.find(btn_play, 'p1')
let p2 = pg.view.find(btn_play, 'p2')
let p3 = pg.view.find(btn_play, 'p3')
p0.active = true;
p1.active = false;
p2.active = false;
p3.active = false;
}
private recordAudioId;
onTouchPlayRecord() {
if (!this.recordAudio) return;
if (this.playVoiceCount && this.playVoiceCount > -1) {
if (this.recordAudioId) {
cc.audioEngine.stopEffect(this.recordAudioId)
}
this.playVoiceEnd();
} else {
this.playVoiceStart();
pg.audio.playAudioByUrl(this.recordAudio, () => {
this.recordAudioId = null;
this.playVoiceEnd();
}, (audioId) => {
this.recordAudioId = audioId;
});
}
}
private playVoiceCount: number;
playVoiceStart() {
if (this.playVoiceCount > 0) return;
this.playVoiceCount = 0;
this.schedule(this.playVoiceRunning, 0.3)
}
playVoiceRunning() {
this.playVoiceCount++;
let btn_play = pg.view.find(this.layout_record, 'btn_play');
let p0 = btn_play.getChildByName('p0')
let p1 = btn_play.getChildByName('p1')
let p2 = btn_play.getChildByName('p2')
let p3 = btn_play.getChildByName('p3')
p0.active = false;
p1.active = this.playVoiceCount % 3 == 0;
p2.active = this.playVoiceCount % 3 == 1;
p3.active = this.playVoiceCount % 3 == 2;
}
playVoiceEnd() {
let btn_play = pg.view.find(this.layout_record, 'btn_play');
this.unschedule(this.playVoiceRunning)
this.playVoiceCount = 0;
let p0 = btn_play.getChildByName('p0')
let p1 = btn_play.getChildByName('p1')
let p2 = btn_play.getChildByName('p2')
let p3 = btn_play.getChildByName('p3')
p0.active = true;
p1.active = false;
p2.active = false;
p3.active = false;
}
protected update(dt: number): void {
......@@ -65,6 +130,8 @@ export default class LayerRecord extends cc.Component {
}
//按钮触发,使用的方法
async onTouchRecord() {
this.recordAudio = '';
this.showPlay();
let AniNode = pg.view.find(this.layout_record, 'AniNode');
AniNode.active = true;
this.showTimeStart();
......@@ -81,13 +148,14 @@ export default class LayerRecord extends cc.Component {
"refText": "I haven't found anything out about him yet.",
"recordId": "6144295213f0a2200000ed93",
"eof": 1,
audioUrl: 'http://staging-teach.cdn.ireadabc.com/43839adb578c7e01456748b8a176a0c3_l.mp3',
"result": {
"pronunciation": 25,
"resource_version": "3.1.0",
"fluency": 60,
"rhythm": 90,
"kernel_version": "5.2.4",
"overall": 25,//75
"overall": 8,//75
"integrity": 100,
"duration": "6.779",
"rear_tone": "fall",
......@@ -96,13 +164,17 @@ export default class LayerRecord extends cc.Component {
"tokenId": "6144295408558b08dd000001",
"applicationId": "154838659000009e"
}
if (!courseware) return this.recrodEnd(testData)
courseware && courseware.stopTest((data) => {
data = JSON.parse(data);
this.recrodEnd(data);
if (!courseware) {
return this.recrodEnd(testData)
}
courseware && courseware.stopTest((res) => {
res = JSON.parse(res);
this.recrodEnd(res);
}); //结束录音
}
async recrodEnd(data) {
this.recordAudio = data.audioUrl;
this.showPlay();
let score = data.result.overall;
pg.event.emit('layer_record_score', score);
}
......
......@@ -109,6 +109,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (score < 10) {
pg.event.on('layer_right_show_tryagain_end', () => {
// alert('test')
if (this.recordFlag) {
this.layer_record.active = true;
}
})
pg.event.emit('layer_right_show_tryagain')
} else if (score < 60) {
......
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