|
@@ -26,7 +26,16 @@ Page({
|
|
|
pageNo: 1,
|
|
|
nextMargin: getApp().globalData.nextMargin,
|
|
|
lowerThresHold: 100,
|
|
|
- isVideoListShow: true
|
|
|
+ isVideoListShow: true,
|
|
|
+ overall: '',
|
|
|
+ integrity: '',
|
|
|
+ tone: '',
|
|
|
+ fluency: '',
|
|
|
+ accuracy: '',
|
|
|
+ star: [0, 0, 0, 0, 0],
|
|
|
+ ifTextShow: true,
|
|
|
+ ifScoreDialogShow: false,
|
|
|
+ ifScoreShow: false
|
|
|
},
|
|
|
onLoad: function (option) {
|
|
|
console.log(option);
|
|
@@ -56,97 +65,13 @@ Page({
|
|
|
|
|
|
})
|
|
|
})
|
|
|
- this.recorderManager = wx.getRecorderManager();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- this.recorderManager.onStart(() => {
|
|
|
-
|
|
|
- this.setData({
|
|
|
- btnImgFlag: true,
|
|
|
- btnFlag: false
|
|
|
- })
|
|
|
- console.log('recorder start')
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- let dialogFlag = true;
|
|
|
- this.recorderManager.onError(() => {
|
|
|
- wx.getSetting({
|
|
|
- success(res) {
|
|
|
- if (!res.authSetting['scope.record'] && dialogFlag) {
|
|
|
- wx.showModal({
|
|
|
- title: '录音前请打开麦克风权限',
|
|
|
- content: '点击右上角浮点...,选择:设置-麦克风,点击/打开。',
|
|
|
- confirmText: '我知道了',
|
|
|
- showCancel: false,
|
|
|
- success(res) {
|
|
|
- console.log('用户点击确定')
|
|
|
-
|
|
|
- }
|
|
|
- })
|
|
|
- dialogFlag = false;
|
|
|
- setTimeout(() => {
|
|
|
- dialogFlag = true;
|
|
|
- }, 1000)
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- this.recorderManager.onStop((res) => {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- this.videoCtx.stop();
|
|
|
- console.log('recorder stop', res)
|
|
|
- const recordFile = res.tempFilePath;
|
|
|
- this.setData({
|
|
|
- recordFlag: 0,
|
|
|
- recordSource: recordFile,
|
|
|
- btnFlag: true,
|
|
|
- btnImgFlag: false
|
|
|
- })
|
|
|
- })
|
|
|
},
|
|
|
onHide: function () {
|
|
|
console.log('onhide')
|
|
|
if (this.data.btnImgFlag) {
|
|
|
- this.recorderManager.stop();
|
|
|
- }
|
|
|
-
|
|
|
- if (this.innerAudioContext) {
|
|
|
- this.innerAudioContext.stop();
|
|
|
+ this.ss.stopRecord();
|
|
|
}
|
|
|
+ this.ss.destroyEngine();
|
|
|
this.setData({
|
|
|
recordFlag: 0
|
|
|
})
|
|
@@ -154,12 +79,10 @@ Page({
|
|
|
},
|
|
|
onUnload: function () {
|
|
|
console.log('onUnload')
|
|
|
- if (this.recorderManager) {
|
|
|
- this.recorderManager.stop();
|
|
|
- }
|
|
|
- if (this.innerAudioContext) {
|
|
|
- this.innerAudioContext.stop();
|
|
|
+ if (this.data.btnImgFlag) {
|
|
|
+ this.ss.stopRecord();
|
|
|
}
|
|
|
+ this.ss.destroyEngine();
|
|
|
},
|
|
|
onShow: function () {
|
|
|
this.setData({
|
|
@@ -169,16 +92,45 @@ Page({
|
|
|
},
|
|
|
})
|
|
|
this.videoCtx = wx.createVideoContext('myVideo', this);
|
|
|
+ let data = requirePlugin("myPlugin");
|
|
|
+ const obj = {
|
|
|
+ appid: 'a415',
|
|
|
+ userid: wx.getStorageSync('uid'),
|
|
|
+ getEvalMessage: (res) => {
|
|
|
+ this.getRecordScore(res)
|
|
|
+
|
|
|
+ },
|
|
|
+ recorderCallback: (type, data) => {
|
|
|
+
|
|
|
+ this.ssRecorderCallback(type, data)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ this.ss = new data.ssEngine(obj);
|
|
|
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ ssRecorderCallback: function (type, data) {
|
|
|
+ console.log('录音测评监控回调', type)
|
|
|
+ console.log('录音测评监控回调', data)
|
|
|
+
|
|
|
+ if (type === 'onStart') {
|
|
|
+ this.setData({
|
|
|
+ btnImgFlag: true,
|
|
|
+ btnFlag: false
|
|
|
+ })
|
|
|
+ console.log('recorder start')
|
|
|
+ }
|
|
|
+ if (type === 'onStop') {
|
|
|
+ this.videoCtx.stop();
|
|
|
+ this.setData({
|
|
|
+ recordFlag: 0,
|
|
|
+ recordSource: data.tempFilePath,
|
|
|
+ btnFlag: true,
|
|
|
+ btnImgFlag: false
|
|
|
+ })
|
|
|
+ console.log('recorder start')
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
recordingVideoEnd: function () {
|
|
|
console.log(this.data.videoCtr)
|
|
@@ -198,7 +150,8 @@ Page({
|
|
|
|
|
|
playingVideoEnd: function () {
|
|
|
console.log('playingVideoEnd')
|
|
|
- this.innerAudioContext.stop();
|
|
|
+
|
|
|
+ this.ss.stopPlay();;
|
|
|
},
|
|
|
|
|
|
* recordFlag:
|
|
@@ -216,12 +169,12 @@ Page({
|
|
|
this.videoCtx.stop();
|
|
|
this.videoCtx.seek(0);
|
|
|
}
|
|
|
- if (this.recorderManager) {
|
|
|
- this.recorderManager.stop();
|
|
|
- }
|
|
|
- if (this.innerAudioContext) {
|
|
|
- this.innerAudioContext.stop();
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
const that = this;
|
|
|
wx.getSetting({
|
|
|
success(res) {
|
|
@@ -267,30 +220,88 @@ Page({
|
|
|
format: 'mp3',
|
|
|
frameSize: 50
|
|
|
}
|
|
|
- this.recorderManager.start(options);
|
|
|
+ this.ss.startRecord({
|
|
|
+ coreType: 'cn.sent.score',
|
|
|
+ evalTime: 240000,
|
|
|
+ refText: this.data.readingText,
|
|
|
+ warrantId: 'c11163aa6c834a028da4a4b30955be96',
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
recordStop: function () {
|
|
|
+ this.ss.stopRecord();
|
|
|
console.log('录音结束')
|
|
|
- this.recorderManager.stop();
|
|
|
wx.hideLoading()
|
|
|
},
|
|
|
+
|
|
|
+ getRecordScore(res) {
|
|
|
+ console.log('测评结果', res)
|
|
|
+ const result = res.result;
|
|
|
+ const overall = result.overall;
|
|
|
+ const integrity = result.integrity;
|
|
|
+ const tone = result.tone;
|
|
|
+ const accuracy = result.accuracy;
|
|
|
+ const fluency = result.fluency.overall;
|
|
|
+ let starArray = [];
|
|
|
+ let score = overall / 20;
|
|
|
+ if (score <= 0) {
|
|
|
+ starArray = [0, 0, 0, 0, 0]
|
|
|
+ } else {
|
|
|
+ for (let i = 1; i < 5; i += 0.9) {
|
|
|
+ if (i < score) {
|
|
|
+ starArray.push(1);
|
|
|
+ } else {
|
|
|
+ starArray.push(0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ overall,
|
|
|
+ integrity,
|
|
|
+ tone,
|
|
|
+ accuracy,
|
|
|
+ fluency,
|
|
|
+ ifScoreDialogShow: true,
|
|
|
+ star: starArray
|
|
|
+ })
|
|
|
+ },
|
|
|
+ closeScoreDialog() {
|
|
|
+ this.setData({
|
|
|
+ ifScoreDialogShow: false,
|
|
|
+ ifScoreShow: true,
|
|
|
+ ifTextShow: false
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
audioPlay: function () {
|
|
|
+
|
|
|
this.setData({
|
|
|
videoUrl: this.data.videoUrl
|
|
|
})
|
|
|
- console.log('音频播放');
|
|
|
- if (this.innerAudioContext) {
|
|
|
- this.innerAudioContext.stop();
|
|
|
- this.videoCtx.stop();
|
|
|
- }
|
|
|
+
|
|
|
this.videoCtx.seek(0)
|
|
|
- this.innerAudioContext = wx.createInnerAudioContext();
|
|
|
- this.innerAudioContext.src = this.data.recordSource;
|
|
|
- console.log(this.innerAudioContext.src);
|
|
|
- this.videoCtx.play();
|
|
|
- this.innerAudioContext.play();
|
|
|
+ const recordSource = this.data.recordSource
|
|
|
+ wx.uploadFile({
|
|
|
+ url: 'https://reader.lingjiao.cn/readerBase/file/upload',
|
|
|
+ filePath: recordSource,
|
|
|
+ name: '朗读录音',
|
|
|
+ header: {
|
|
|
+ uid: wx.getStorageSync('uid')
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ const formateRes = JSON.parse(res.data);
|
|
|
+
|
|
|
+ let audioPath = formateRes.data;
|
|
|
+ this.setData({
|
|
|
+ audioPath,
|
|
|
+ audioPlaying: true
|
|
|
+ })
|
|
|
+ this.ss.startPlay(audioPath);
|
|
|
+ this.videoCtx.play();
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
videoComplete: function () {
|
|
@@ -312,76 +323,91 @@ Page({
|
|
|
if (this.videoCtx) {
|
|
|
this.videoCtx.stop();
|
|
|
}
|
|
|
- if (this.recorderManager) {
|
|
|
- this.recorderManager.stop();
|
|
|
- }
|
|
|
- if (this.innerAudioContext) {
|
|
|
- this.innerAudioContext.stop();
|
|
|
+ if (this.data.audioPlaying) {
|
|
|
+ this.ss.stopPlay();
|
|
|
+ this.setData({
|
|
|
+ audioPlaying: false
|
|
|
+ })
|
|
|
}
|
|
|
wx.showLoading({
|
|
|
title: '作品分享中',
|
|
|
mask: true
|
|
|
})
|
|
|
- const recordSource = this.data.recordSource;
|
|
|
- wx.uploadFile({
|
|
|
- url: 'https://reader.lingjiao.cn/readerBase/file/upload',
|
|
|
- filePath: recordSource,
|
|
|
- name: '朗读录音',
|
|
|
- header: {
|
|
|
- uid: wx.getStorageSync('uid')
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- const formateRes = JSON.parse(res.data);
|
|
|
- let audioPath = formateRes.data;
|
|
|
- let uid = wx.getStorageSync('uid');
|
|
|
- shareWorks(uid, audioPath);
|
|
|
- }
|
|
|
|
|
|
- })
|
|
|
- let shareWorks = (uid, audio) => {
|
|
|
- if (this.innerAudioContext) {
|
|
|
- this.innerAudioContext.stop();
|
|
|
- }
|
|
|
- const data = {
|
|
|
- "lessonId": this.data.id,
|
|
|
- "originVideo": this.data.videoUrl,
|
|
|
- "audioPath": audio,
|
|
|
- "title": this.data.title,
|
|
|
- "iconImg": this.data.img,
|
|
|
- "summary": this.data.summary,
|
|
|
- "productId": this.data.productId,
|
|
|
- "grade":this.data.grade,
|
|
|
- "exampleId": this.data.exampleId
|
|
|
- };
|
|
|
- httpRequestApi.postWork(uid, data).success(res => {
|
|
|
- wx.hideLoading({
|
|
|
- success: () => {
|
|
|
- wx.showToast({
|
|
|
- title: '上传成功',
|
|
|
- icon: 'success',
|
|
|
- duration: 1000,
|
|
|
- success: () => {
|
|
|
- console.log(res);
|
|
|
- wx.redirectTo({
|
|
|
- url: `../../social/works/works?id=${res.data.data.id}&flowerCount=${res.data.count}`
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- });
|
|
|
+ if (this.data.audioPath) {
|
|
|
+ this.shareWorks(uid, this.data.audioPath)
|
|
|
+ } else {
|
|
|
+ const recordSource = this.data.recordSource;
|
|
|
+ wx.uploadFile({
|
|
|
+ url: 'https://reader.lingjiao.cn/readerBase/file/upload',
|
|
|
+ filePath: recordSource,
|
|
|
+ name: '朗读录音',
|
|
|
+ header: {
|
|
|
+ uid: wx.getStorageSync('uid')
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ const formateRes = JSON.parse(res.data);
|
|
|
+ let audioPath = formateRes.data;
|
|
|
+ this.shareWorks(audioPath);
|
|
|
+ }
|
|
|
|
|
|
})
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ shareWorks: function (audio) {
|
|
|
+
|
|
|
+ const data = {
|
|
|
+ "lessonId": this.data.id,
|
|
|
+ "originVideo": this.data.videoUrl,
|
|
|
+ "audioPath": audio,
|
|
|
+ "title": this.data.title,
|
|
|
+ "iconImg": this.data.img,
|
|
|
+ "summary": this.data.summary,
|
|
|
+ "productId": this.data.productId,
|
|
|
+ "grade": this.data.grade,
|
|
|
+ "exampleId": this.data.exampleId
|
|
|
};
|
|
|
+ httpRequestApi.postWork(data).success(res => {
|
|
|
+ wx.hideLoading({
|
|
|
+ success: () => {
|
|
|
+ wx.showToast({
|
|
|
+ title: '上传成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 1000,
|
|
|
+ success: () => {
|
|
|
+ console.log(res);
|
|
|
+ const _data = this.data;
|
|
|
+ const scoreData = {
|
|
|
+ "userReadId": res.data.data.id,
|
|
|
+ "complete": _data.integrity,
|
|
|
+ "accuracy": _data.accuracy,
|
|
|
+ "speed": _data.fluency,
|
|
|
+ "intonation": _data.tone,
|
|
|
+ "score": _data.overall
|
|
|
+ }
|
|
|
+ httpRequestApi.postWorksScore(scoreData).success(res => {
|
|
|
+ console.log(res)
|
|
|
+ })
|
|
|
+ wx.redirectTo({
|
|
|
+ url: `../../social/works/works?id=${res.data.data.id}&flowerCount=${res.data.count}`
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
},
|
|
|
|
|
|
|
|
|
- getReadInfo: function (id,pageNo, pageSize) {
|
|
|
+ getReadInfo: function (id, pageNo, pageSize) {
|
|
|
|
|
|
const data = {
|
|
|
exampleId: this.data.id || id,
|
|
|
pageNo: this.data.pageNo,
|
|
|
pageSize: 3,
|
|
|
- type:'READ'
|
|
|
+ type: 'READ'
|
|
|
};
|
|
|
httpRequestApi.getClassRead(this.uid, data).success(res => {
|
|
|
const readInfo = res.data.data.list;
|