Commit e9a32d1f authored by liujiangnan's avatar liujiangnan

feat:

parent 7812fa56
......@@ -43,6 +43,7 @@ export function initAir(_this) {
startBuyToAppStoreCallBack: null,
recognitionCameraCallBack: null,
testCallBack: null,
testConvertCallBack: null,
recordCallBack: null,
onCourseInScreen: null,
};
......@@ -173,6 +174,53 @@ export function initAir(_this) {
window.courseware.callOcMethod("stopTest", {});
},
startTestConvert(testText, option) {
window.courseware.hasCalledStartTestConvert = true;
_this.log(`===成功调用startTestConvert=== testText == ${testText}`);
window.courseware.callOcMethod("startTestConvert", { ...option, "params": testText });
},
stopTestConvert(testCallback, convertCallback) {
window.courseware.hasCalledStartTestConvert = false;
_this.log(`===成功调用stopTestConvert===`);
if (!testCallback) {
// 不传回调函数就表示取消评测
_this.log(`===成功取消录音评测===`);
window.courseware.callOcMethod("stopTestConvert", { isBreak: 1 });
return;
}
// 结束录音
window.air.testCallBack = (res) => {
res = typeof(res) == 'string' ? res : JSON.stringify(res);
_this.log(`===成功调用testCallBack=== res == ${res}`);
// 录音异常兼容处理
const resObj = JSON.parse(res);
if (resObj.errCode) {
resObj.result = {overall:0};
resObj.audioUrl = "";
res = JSON.stringify(resObj);
_this.showTips(`评测服务信号弱,可能会造成评分不准确,请稍后再来录音评测吧~`);
}
testCallback && testCallback(res);
window.air.testCallBack = null;
};
// 结束变声
window.air.testConvertCallBack = (res) => {
res = typeof(res) == 'string' ? res : JSON.stringify(res);
_this.log(`===成功调用testConvertCallBack=== res == ${res}`);
// 录音异常兼容处理
const resObj = JSON.parse(res);
if (resObj.errCode) {
resObj.convertUrl = "";
res = JSON.stringify(resObj);
_this.showTips(`变声失败,请稍后再来尝试吧~`);
}
convertCallback && convertCallback(res);
window.air.testConvertCallBack = null;
};
window.courseware.callOcMethod("stopTestConvert", {});
},
startRealtimeRecord(params = {}) {
window.courseware.hasCalledRealtimeRecord = true;
_this.log(`===成功调用startRealtimeRecord===${JSON.stringify(params)}`);
......@@ -369,6 +417,9 @@ export function initAir(_this) {
if (window.courseware.hasCalledStartTest) {
window.courseware.stopTest();
}
if (window.courseware.hasCalledStartTestConvert) {
window.courseware.stopTestConvert();
}
if (window.courseware.hasCalledRealtimeRecord) {
window.courseware.stopRealtimeRecord();
}
......
import { middleLayerBase } from "./middleLayerBase";
import { initAir } from './air';
import { playAudioByUrl } from './util';
const { ccclass, property } = cc._decorator;
......@@ -481,44 +483,10 @@ export default class NewClass extends middleLayerBase {
});
}
jjDemo() {
cc.find('middleLayer/ui/jjdemo/goDebug').on('click', () => {
cc.find(`middleLayer/ui/jjdemo`).active = false;
});
cc.find('middleLayer/ui/jjdemo/ox').on('click', () => {
this.hideUI();
const engineObj = JSON.parse((<any>window).air.engineInfo);
if (engineObj.isDev == 1) {
this.loadOnlineCourseWare(27333, false, null);
} else {
this.loadOnlineCourseWare(45892, false, null);
}
});
cc.find('middleLayer/ui/jjdemo/pp').on('click', () => {
cc.find('middleLayer/ui/jjdemo/web').active = true;
cc.find('middleLayer/ui/jjdemo/webBar').active = true;
});
cc.find('middleLayer/ui/jjdemo/webBar/btnLeft').on('click', () => {
cc.find('middleLayer/ui/jjdemo/web').active = false;
cc.find('middleLayer/ui/jjdemo/webBar').active = false;
});
cc.find('middleLayer/ui/jjdemo/faf').on('click', () => {
this.hideUI();
const engineObj = JSON.parse((<any>window).air.engineInfo);
if (engineObj.isDev == 1) {
this.loadOnlineCourseWare(29235, false, null);
} else {
this.loadOnlineCourseWare(55645, false, null);
}
});
}
covertUrl = null;
initListener() {
// 剑津DEMO
this.jjDemo();
const exitBtn = cc.find('middleLayer/ExitBtn');
exitBtn.on('click', () => {
cc.find('middleLayer/BtnRight').active = false;
......@@ -635,7 +603,8 @@ export default class NewClass extends middleLayerBase {
});
cc.find('middleLayer/ui/BtnOpenTest').on('click', () => {
(<any>window).courseware.startTest('apple');
// (<any>window).courseware.startTest('apple');
(<any>window).courseware.startTestConvert('My name is Lucy');
});
cc.find('middleLayer/ui/BtnCloseTest').on('click', () => {
......@@ -643,11 +612,20 @@ export default class NewClass extends middleLayerBase {
this.log('--------录音评测返回结果 stopTest ---------');
this.log(res)
this.log('------------------------------');
this.log(`录音apple的评分是${JSON.parse(res).result.overall}`);
this.log(`录音apple的音频URL是${JSON.parse(res).audioUrl}`);
this.log(`录音的评分是${JSON.parse(res).result.overall}`);
this.log(`录音的音频URL是${JSON.parse(res).audioUrl}`);
}, covert => {
this.log('--------变声返回结果 ---------');
this.log(covert)
this.covertUrl = JSON.parse(covert).convertUrl;
this.log(`变声的URL:${JSON.parse(covert).convertUrl}`);
this.log('------------------------------');
});
});
cc.find('middleLayer/ui/BtnCovert').on('click', () => {
playAudioByUrl(this.covertUrl);
});
const BtnStartLocal = cc.find('middleLayer/ui/BtnStartLocal');
......
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