|
@@ -39,17 +39,21 @@
|
|
const regex = new RegExp(`\\${placeholder}`, 'g');
|
|
const regex = new RegExp(`\\${placeholder}`, 'g');
|
|
if (!this.isplaying) {
|
|
if (!this.isplaying) {
|
|
|
|
|
|
- const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}`:`t_${this.question.stId}_${index}`
|
|
|
|
|
|
+ const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}` :
|
|
|
|
+ `t_${this.question.stId}_${index}`
|
|
result = result.replace(regex,
|
|
result = result.replace(regex,
|
|
`<view class="yingyu-canplay-img" id="${cId}"></view>`
|
|
`<view class="yingyu-canplay-img" id="${cId}"></view>`
|
|
);
|
|
);
|
|
- } else if (this.isplaying && this.question.stId == this.isplaying.stId && this.isplaying.index == index) {
|
|
|
|
- const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}`:`t_${this.question.stId}_${index}`
|
|
|
|
|
|
+ } else if (this.isplaying && this.question.stId == this.isplaying.stId && this.isplaying
|
|
|
|
+ .index == index) {
|
|
|
|
+ const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}` :
|
|
|
|
+ `t_${this.question.stId}_${index}`
|
|
result = result.replace(regex,
|
|
result = result.replace(regex,
|
|
`<view class="yingyu-playing-img" id="${cId}"></view>`
|
|
`<view class="yingyu-playing-img" id="${cId}"></view>`
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
- const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}`:`t_${this.question.stId}_${index}`
|
|
|
|
|
|
+ const cId = this.code ? `t_${this.question.stId}_${index}_${this.code}` :
|
|
|
|
+ `t_${this.question.stId}_${index}`
|
|
result = result.replace(regex,
|
|
result = result.replace(regex,
|
|
`<view class="yingyu-canplay-img" id="${cId}"></view>`
|
|
`<view class="yingyu-canplay-img" id="${cId}"></view>`
|
|
);
|
|
);
|
|
@@ -69,67 +73,64 @@
|
|
this.isFirst = -1
|
|
this.isFirst = -1
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
if (this.isplaying) {
|
|
if (this.isplaying) {
|
|
uni.$emit('do-yy-audio-stop', data);
|
|
uni.$emit('do-yy-audio-stop', data);
|
|
this.isFirst++;
|
|
this.isFirst++;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
// 初次播放
|
|
// 初次播放
|
|
if (!this.isplaying) {
|
|
if (!this.isplaying) {
|
|
uni.$emit('do-yy-audio-play', data);
|
|
uni.$emit('do-yy-audio-play', data);
|
|
this.isFirst++;
|
|
this.isFirst++;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- created() {
|
|
|
|
- // 切换不同播放音频时 重置状态
|
|
|
|
- uni.$on('reset-playing-status', (data) => {
|
|
|
|
- if (this.isplaying) {
|
|
|
|
- if (data.stId == this.isplaying.stId && data.index == this.isplaying.index) {
|
|
|
|
- this.isplaying = null;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- // 音频播放
|
|
|
|
- uni.$on('yy-audio-playing', (data) => {
|
|
|
|
- if (this.isplaying) {
|
|
|
|
- // 存在播放实例 并且播放非同一音频
|
|
|
|
- if (this.isplaying.stId != data.value.stId) {
|
|
|
|
- this.isplaying = null;
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- // 不存在播放实例
|
|
|
|
- this.isplaying = data;
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- // 音频异常 重置音频
|
|
|
|
- uni.$on('yy-audio-error', (data) => {
|
|
|
|
- this.isplaying = null;
|
|
|
|
- })
|
|
|
|
- // 音频自然播放结束 重置音频
|
|
|
|
- uni.$on('yy-audio-end', (data) => {
|
|
|
|
- this.isplaying = null;
|
|
|
|
- })
|
|
|
|
- // 音频销毁 重置音频
|
|
|
|
- uni.$on('destory-stop', (data) => {
|
|
|
|
- this.isplaying = null;
|
|
|
|
- })
|
|
|
|
- // 试题切换 重置音频
|
|
|
|
- uni.$on('swiper-change', () => {
|
|
|
|
- this.isplaying = null;
|
|
|
|
- })
|
|
|
|
- // 解析关闭 重置音频
|
|
|
|
- uni.$on('question-jiexi-close', () => {
|
|
|
|
|
|
+ created() {
|
|
|
|
+ // 切换不同播放音频时 重置状态
|
|
|
|
+ uni.$on('reset-playing-status', (data) => {
|
|
|
|
+ if (this.isplaying) {
|
|
|
|
+ if (data.stId == this.isplaying.stId && data.index == this.isplaying.index) {
|
|
this.isplaying = null;
|
|
this.isplaying = null;
|
|
- })
|
|
|
|
- uni.$on('unitTest-submit', () => {
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ // 音频播放
|
|
|
|
+ uni.$on('yy-audio-playing', (data) => {
|
|
|
|
+ if (this.isplaying) {
|
|
|
|
+ // 存在播放实例 并且播放非同一音频
|
|
|
|
+ if (this.isplaying.stId != data.value.stId) {
|
|
this.isplaying = null;
|
|
this.isplaying = null;
|
|
- })
|
|
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 不存在播放实例
|
|
|
|
+ this.isplaying = data;
|
|
}
|
|
}
|
|
|
|
+ })
|
|
|
|
+ // 音频异常 重置音频
|
|
|
|
+ uni.$on('yy-audio-error', (data) => {
|
|
|
|
+ this.isplaying = null;
|
|
|
|
+ })
|
|
|
|
+ // 音频自然播放结束 重置音频
|
|
|
|
+ uni.$on('yy-audio-end', (data) => {
|
|
|
|
+ this.isplaying = null;
|
|
|
|
+ })
|
|
|
|
+ // 音频销毁 重置音频
|
|
|
|
+ uni.$on('destory-stop', (data) => {
|
|
|
|
+ this.isplaying = null;
|
|
|
|
+ })
|
|
|
|
+ // 试题切换 重置音频
|
|
|
|
+ uni.$on('swiper-change', () => {
|
|
|
|
+ this.isplaying = null;
|
|
|
|
+ })
|
|
|
|
+ // 解析关闭 重置音频
|
|
|
|
+ uni.$on('question-jiexi-close', () => {
|
|
|
|
+ this.isplaying = null;
|
|
|
|
+ })
|
|
|
|
+ uni.$on('unitTest-submit', () => {
|
|
|
|
+ this.isplaying = null;
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
<script module="YY" lang="renderjs">
|
|
<script module="YY" lang="renderjs">
|