|
@@ -37,6 +37,8 @@ Page({
|
|
|
videoInfo: {},
|
|
|
currentRow: null,
|
|
|
state: false,
|
|
|
+ // 示例播放状态
|
|
|
+ exampleState: false,
|
|
|
// 是否静音播放视频
|
|
|
muted: false,
|
|
|
countDown: {
|
|
@@ -95,6 +97,20 @@ Page({
|
|
|
wsEngine.onErrorResult((res) => {
|
|
|
console.log("===收到错误结果=============", res)
|
|
|
});
|
|
|
+ this.innerAudioContext = wx.createInnerAudioContext();
|
|
|
+ this.resultAudioContext = wx.createInnerAudioContext();
|
|
|
+ this.resultAudioContext.onEnded(res => {
|
|
|
+ this.setData({
|
|
|
+ exampleState: false
|
|
|
+ })
|
|
|
+ this.stopMediaState()
|
|
|
+ })
|
|
|
+ this.resultAudioContext.onStop((res) => {
|
|
|
+ this.setData({
|
|
|
+ exampleState: false
|
|
|
+ })
|
|
|
+ this.stopMediaState()
|
|
|
+ });
|
|
|
},
|
|
|
// 获取阅读内容
|
|
|
async getreadInfo(videoId, reset = false) {
|
|
@@ -118,7 +134,6 @@ Page({
|
|
|
if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
|
|
|
this.videoContext = wx.createVideoContext('myVideo')
|
|
|
} else {
|
|
|
- this.innerAudioContext = wx.createInnerAudioContext();
|
|
|
this.innerAudioContext.src = videoInfo.userRead.originVideo
|
|
|
this.innerAudioContext.onEnded(res => {
|
|
|
this.finishRecord()
|
|
@@ -142,13 +157,11 @@ Page({
|
|
|
return
|
|
|
}
|
|
|
if (this.data.readingReset) {
|
|
|
- if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
|
|
|
- this.stopMediaState()
|
|
|
- }
|
|
|
- this.clearReset()
|
|
|
this.getHeight()
|
|
|
}
|
|
|
+ this.stopMediaState()
|
|
|
this.setData({
|
|
|
+ readingReset: false,
|
|
|
'countDown.state': true
|
|
|
})
|
|
|
this.stl = setInterval(() => {
|
|
@@ -348,15 +361,6 @@ Page({
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
- // 测试的
|
|
|
- pkResult() {
|
|
|
- wx.redirectTo({
|
|
|
- url: `/pages/score/index?readingType=${this.data.readingType}`
|
|
|
- })
|
|
|
- /* wx.redirectTo({
|
|
|
- url: `/pages/pkResult/index`,
|
|
|
- }) */
|
|
|
- },
|
|
|
// 字体换行
|
|
|
startRecording() {
|
|
|
if (this.data.currentRow == null) {
|
|
@@ -381,30 +385,39 @@ Page({
|
|
|
},
|
|
|
// 视频播放结束
|
|
|
videoEnd() {
|
|
|
+ console.log('视频播放结束触发的');
|
|
|
this.finishRecord()
|
|
|
},
|
|
|
videoPlay() {
|
|
|
- if (this.data.readingReset) {
|
|
|
- console.log(this.resultAudioContext, 'videoPlay');
|
|
|
- if (this.resultAudioContext) {
|
|
|
- this.resultAudioContext.stop()
|
|
|
+ if (this.data.videoInfo.userReadExtend.resourcesType == 1) {
|
|
|
+ if (this.data.exampleState) {
|
|
|
+ this.setData({
|
|
|
+ exampleState: false
|
|
|
+ })
|
|
|
+ return this.resultAudioContext.stop()
|
|
|
}
|
|
|
+ this.resultAudioContext.src = this.data.readingReset ? this.data.readDetail.tempFilePath : this.data.videoInfo.userRead.audioPath;
|
|
|
+ this.resultAudioContext.play();
|
|
|
this.setData({
|
|
|
- muted: true
|
|
|
+ exampleState: true
|
|
|
})
|
|
|
- this.resultAudioContext = wx.createInnerAudioContext();
|
|
|
- this.resultAudioContext.src = this.data.readDetail.tempFilePath; // 这里可以是录音的临时路径
|
|
|
- this.resultAudioContext.play();
|
|
|
- }
|
|
|
- },
|
|
|
- // 清除试听状态
|
|
|
- clearReset() {
|
|
|
- if (this.resultAudioContext) {
|
|
|
- this.resultAudioContext.stop()
|
|
|
+ } else {
|
|
|
+ if (this.data.readingReset) {
|
|
|
+ this.resultAudioContext.src = this.data.readDetail.tempFilePath;
|
|
|
+ this.resultAudioContext.play();
|
|
|
+ this.setData({
|
|
|
+ muted: true,
|
|
|
+ exampleState: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ muted: false,
|
|
|
+ exampleState: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.videoContext.play()
|
|
|
}
|
|
|
- this.setData({
|
|
|
- readingReset: false
|
|
|
- })
|
|
|
+ this.startRecording()
|
|
|
},
|
|
|
// 控制视频或音频的播放状态
|
|
|
async playMediaState() {
|
|
@@ -426,9 +439,9 @@ Page({
|
|
|
if (!this.data.videoInfo.userReadExtend || this.data.videoInfo.userReadExtend.resourcesType == 0) {
|
|
|
this.videoContext.stop()
|
|
|
this.videoContext.seek(0)
|
|
|
- } else {
|
|
|
- this.innerAudioContext.stop()
|
|
|
}
|
|
|
+ this.innerAudioContext.stop()
|
|
|
+ this.resultAudioContext.stop()
|
|
|
},
|
|
|
// 获取设备高度与行高度
|
|
|
getHeight() {
|