|
@@ -99,16 +99,24 @@ Page({
|
|
|
this.innerAudioContext = wx.createInnerAudioContext();
|
|
|
this.resultAudioContext = wx.createInnerAudioContext();
|
|
|
this.resultAudioContext.onEnded(res => {
|
|
|
+ console.log('102-resultAudioContext.ended');
|
|
|
this.setData({
|
|
|
exampleState: false
|
|
|
})
|
|
|
- this.stopMediaState()
|
|
|
+ if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
|
|
|
+ this.videoContext.stop()
|
|
|
+ this.videoContext.seek(0)
|
|
|
+ }
|
|
|
})
|
|
|
this.resultAudioContext.onStop((res) => {
|
|
|
+ console.log('109-resultAudioContext.onStop');
|
|
|
this.setData({
|
|
|
exampleState: false
|
|
|
})
|
|
|
- this.stopMediaState()
|
|
|
+ if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
|
|
|
+ this.videoContext.stop()
|
|
|
+ this.videoContext.seek(0)
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
// 获取阅读内容
|
|
@@ -130,17 +138,18 @@ Page({
|
|
|
if (!reset) {
|
|
|
this.getHeight()
|
|
|
}
|
|
|
- if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
|
|
|
+ if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
|
|
|
this.videoContext = wx.createVideoContext('myVideo')
|
|
|
} else {
|
|
|
+ console.log('走了136');
|
|
|
this.innerAudioContext.src = videoInfo.userRead.originVideo
|
|
|
this.innerAudioContext.onEnded(res => {
|
|
|
console.log("138innerAudioContext触发的");
|
|
|
- this.finishRecord()
|
|
|
+ this.resetReading()
|
|
|
})
|
|
|
this.innerAudioContext.onStop((res) => {
|
|
|
console.log("143innerAudioContext触发的");
|
|
|
- this.finishRecord()
|
|
|
+ // this.resetReading()
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -154,13 +163,13 @@ Page({
|
|
|
return this.selectComponent('#readingTips').showModal();
|
|
|
}
|
|
|
if (this.data.state) {
|
|
|
- this.finishRecord()
|
|
|
+ this.resetReading()
|
|
|
return
|
|
|
}
|
|
|
if (!this.data.readingReset) {
|
|
|
this.getHeight()
|
|
|
}
|
|
|
- this.stopMediaState()
|
|
|
+ this.resetReading()
|
|
|
this.setData({
|
|
|
readingReset: false,
|
|
|
'countDown.state': true
|
|
@@ -187,6 +196,7 @@ Page({
|
|
|
},
|
|
|
// 录音
|
|
|
soundRecording() {
|
|
|
+ console.log('zzz');
|
|
|
/*调用微信开始录音接口,并启动语音评测*/
|
|
|
let timeStamp = new Date().getTime()
|
|
|
let sig = sha1(`16075689600000da${timeStamp}caa8e60da6042731c230fe431ac9c7fd`)
|
|
@@ -272,19 +282,6 @@ Page({
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- // 结束录制
|
|
|
- finishRecord() {
|
|
|
- console.log('触发结束录制了');
|
|
|
- recorderManager.stop();
|
|
|
- this.stopMediaState()
|
|
|
- clearTimeout(this.setTimeoutObj)
|
|
|
- clearInterval(this.stl)
|
|
|
- this.setData({
|
|
|
- state: false,
|
|
|
- currentRow: null,
|
|
|
- scrollTop: 0
|
|
|
- })
|
|
|
- },
|
|
|
// 获取测评结果
|
|
|
getRecordScore(res) {
|
|
|
const result = res.result;
|
|
@@ -391,9 +388,13 @@ Page({
|
|
|
// 视频播放结束
|
|
|
videoEnd() {
|
|
|
console.log('视频播放结束触发的');
|
|
|
- this.finishRecord()
|
|
|
+ this.resetReading()
|
|
|
},
|
|
|
videoPlay() {
|
|
|
+ console.log("触发");
|
|
|
+ if (this.data.state) {
|
|
|
+ return
|
|
|
+ }
|
|
|
if (this.data.videoInfo.userReadExtend.resourcesType == 1) {
|
|
|
if (this.data.exampleState) {
|
|
|
this.setData({
|
|
@@ -408,6 +409,7 @@ Page({
|
|
|
})
|
|
|
} else {
|
|
|
if (this.data.readingReset) {
|
|
|
+ console.log('是我播放了');
|
|
|
this.resultAudioContext.src = this.data.readDetail.tempFilePath;
|
|
|
this.resultAudioContext.play();
|
|
|
this.setData({
|
|
@@ -422,16 +424,14 @@ Page({
|
|
|
}
|
|
|
this.videoContext.play()
|
|
|
}
|
|
|
- /* if (!this.data.readingReset) {
|
|
|
- this.startRecording()
|
|
|
- } */
|
|
|
},
|
|
|
// 控制视频或音频的播放状态
|
|
|
async playMediaState() {
|
|
|
+ console.log('触发');
|
|
|
this.setData({
|
|
|
muted: false
|
|
|
})
|
|
|
- if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
|
|
|
+ if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
|
|
|
this.videoContext.play()
|
|
|
} else {
|
|
|
this.innerAudioContext.play();
|
|
@@ -441,14 +441,35 @@ Page({
|
|
|
readId: this.data.videoInfo.userRead.id
|
|
|
})
|
|
|
},
|
|
|
- // 控制视频或音频的暂停状态
|
|
|
- stopMediaState() {
|
|
|
- if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
|
|
|
+ // 重置一切状态
|
|
|
+ resetReading() {
|
|
|
+ clearTimeout(this.setTimeoutObj)
|
|
|
+ clearInterval(this.stl)
|
|
|
+ console.log(this.data.exampleState, this.data.state, 'vvvvvvvvvvvvvvvvvvvvvvv');
|
|
|
+ // 重置视频
|
|
|
+ if (this.data.videoInfo.userReadExtend.resourcesType == 0) {
|
|
|
this.videoContext.stop()
|
|
|
this.videoContext.seek(0)
|
|
|
}
|
|
|
- this.innerAudioContext.stop()
|
|
|
- this.resultAudioContext.stop()
|
|
|
+ // 重置试听音频
|
|
|
+ if (this.data.exampleState) {
|
|
|
+ this.resultAudioContext.stop()
|
|
|
+ // 重置录音时的背景音乐
|
|
|
+ this.innerAudioContext.stop();
|
|
|
+ console.log('是我暂停了');
|
|
|
+ }
|
|
|
+ if (this.data.state) {
|
|
|
+ // 重置录音时的背景音乐
|
|
|
+ this.innerAudioContext.stop();
|
|
|
+ /*微信录音结束*/
|
|
|
+ recorderManager.stop();
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ exampleState: false,
|
|
|
+ state: false,
|
|
|
+ currentRow: null,
|
|
|
+ scrollTop: 0
|
|
|
+ })
|
|
|
},
|
|
|
// 获取设备高度与行高度
|
|
|
getHeight() {
|
|
@@ -463,18 +484,10 @@ Page({
|
|
|
}).exec()
|
|
|
},
|
|
|
onHide() {
|
|
|
- wsEngine.reset()
|
|
|
- if (this.innerAudioContext) {
|
|
|
- this.innerAudioContext.stop()
|
|
|
- }
|
|
|
- this.finishRecord()
|
|
|
+ this.resetReading()
|
|
|
},
|
|
|
onUnload() {
|
|
|
- wsEngine.reset()
|
|
|
- if (this.innerAudioContext) {
|
|
|
- this.innerAudioContext.stop()
|
|
|
- }
|
|
|
- this.finishRecord()
|
|
|
+ this.resetReading()
|
|
|
},
|
|
|
creatShare() {
|
|
|
return new Promise((resolve, reject) => {
|