|
@@ -40,7 +40,7 @@
|
|
|
<div
|
|
|
:class="[
|
|
|
'NPC-word-row',
|
|
|
- mp3_index == sItem.sIndex ? 'active' : '',
|
|
|
+ playClass && mp3_index == sItem.sIndex ? 'active' : '',
|
|
|
]"
|
|
|
v-for="(sItem, sIndex) in item"
|
|
|
:key="'curQue.option.child' + sIndex"
|
|
@@ -59,7 +59,7 @@
|
|
|
: themeColor == 'red'
|
|
|
? 'NPC-play-btn-red'
|
|
|
: 'NPC-play-btn-brown',
|
|
|
- mp3_index == sItem.sIndex ? 'active' : '',
|
|
|
+ playClass && mp3_index == sItem.sIndex ? 'active' : '',
|
|
|
]"
|
|
|
@click="palyAudio(sItem.sIndex)"
|
|
|
></span>
|
|
@@ -215,7 +215,7 @@ export default {
|
|
|
detailIndex: 0,
|
|
|
audio: new Audio(),
|
|
|
playClass: "",
|
|
|
- mp3_index: -1,
|
|
|
+ mp3_index: 0,
|
|
|
playWord: null,
|
|
|
optionRes: [],
|
|
|
mp3List: [],
|
|
@@ -265,12 +265,16 @@ export default {
|
|
|
let _this = this;
|
|
|
if (_this.playWord) {
|
|
|
let _this = this;
|
|
|
- _this.playWord.addEventListener("play", function () {});
|
|
|
+ _this.playWord.addEventListener("play", function () {
|
|
|
+ _this.playClass = "nn";
|
|
|
+ });
|
|
|
_this.playWord.addEventListener("pause", function () {
|
|
|
- _this.mp3_index = -1;
|
|
|
+ _this.mp3_index = 0;
|
|
|
+ _this.playClass = "";
|
|
|
});
|
|
|
_this.playWord.addEventListener("ended", function () {
|
|
|
- _this.mp3_index = -1;
|
|
|
+ _this.mp3_index = 0;
|
|
|
+ _this.playClass = "";
|
|
|
});
|
|
|
}
|
|
|
},
|
|
@@ -303,25 +307,38 @@ export default {
|
|
|
if (_this.playWord) {
|
|
|
_this.playWord.pause();
|
|
|
}
|
|
|
- let mp3_index = 0;
|
|
|
- let leg = _this.mp3List.length;
|
|
|
- let mp3 = _this.mp3List[mp3_index].mp3_list[0].id;
|
|
|
- _this.mp3_index = _this.mp3List[mp3_index].sIndex;
|
|
|
- _this.handlePlayVoice(mp3);
|
|
|
- _this.$refs.newwordAudio.addEventListener("ended", function () {
|
|
|
- if (mp3_index < leg - 1) {
|
|
|
- mp3_index = mp3_index + 1;
|
|
|
- _this.mp3_index = _this.mp3List[mp3_index].sIndex;
|
|
|
- mp3 =
|
|
|
- _this.mp3List[mp3_index].mp3_list.length > 0 &&
|
|
|
- _this.mp3List[mp3_index].mp3_list[0].id;
|
|
|
- if (mp3) {
|
|
|
- _this.handlePlayVoice(mp3);
|
|
|
- }
|
|
|
- } else {
|
|
|
- _this.mp3_index = -1;
|
|
|
- }
|
|
|
- });
|
|
|
+ if (_this.playClass) {
|
|
|
+ _this.$refs.newwordAudio.pause();
|
|
|
+ // _this.mp3_index = -1;
|
|
|
+ _this.playClass = "";
|
|
|
+ } else {
|
|
|
+ let mp3_index = _this.mp3_index;
|
|
|
+ let leg = _this.mp3List.length;
|
|
|
+ let mp3 = _this.mp3List[mp3_index].mp3_list[0].id;
|
|
|
+ _this.mp3_index = _this.mp3List[mp3_index].sIndex;
|
|
|
+ _this.handlePlayVoice(mp3);
|
|
|
+ _this.$refs.newwordAudio.addEventListener("ended", function () {
|
|
|
+ setTimeout(() => {
|
|
|
+ if (_this.playClass != "nn") {
|
|
|
+ if (mp3_index < leg - 1) {
|
|
|
+ if (_this.playClass) {
|
|
|
+ mp3_index = mp3_index + 1;
|
|
|
+ _this.mp3_index = _this.mp3List[mp3_index].sIndex;
|
|
|
+ mp3 =
|
|
|
+ _this.mp3List[mp3_index].mp3_list.length > 0 &&
|
|
|
+ _this.mp3List[mp3_index].mp3_list[0].id;
|
|
|
+ if (mp3) {
|
|
|
+ _this.handlePlayVoice(mp3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ _this.mp3_index = 0;
|
|
|
+ _this.playClass = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
handlePlayVoice3(mp3) {
|
|
|
let _this = this;
|
|
@@ -356,17 +373,12 @@ export default {
|
|
|
if (!mp3) {
|
|
|
return;
|
|
|
}
|
|
|
- if (!_this.$refs.newwordAudio.paused) {
|
|
|
- _this.$refs.newwordAudio.pause();
|
|
|
- _this.mp3_index = -1;
|
|
|
- } else {
|
|
|
- setTimeout(() => {
|
|
|
- _this.$refs.newwordAudio.pause();
|
|
|
- _this.$refs.newwordAudio.src = mp3;
|
|
|
- _this.$refs.newwordAudio.load();
|
|
|
- _this.$refs.newwordAudio.play();
|
|
|
- }, 10);
|
|
|
- }
|
|
|
+ // setTimeout(() => {
|
|
|
+ //_this.$refs.newwordAudio.pause();
|
|
|
+ _this.$refs.newwordAudio.src = mp3;
|
|
|
+ //_this.$refs.newwordAudio.load();
|
|
|
+ _this.$refs.newwordAudio.play();
|
|
|
+ // }, 1000);
|
|
|
},
|
|
|
stopAudio() {
|
|
|
this.$refs.newwordAudio.pause();
|
|
@@ -410,10 +422,7 @@ export default {
|
|
|
_this.playClass = "active";
|
|
|
});
|
|
|
_this.$refs.newwordAudio.addEventListener("pause", function () {
|
|
|
- _this.playClass = "";
|
|
|
- });
|
|
|
- _this.$refs.newwordAudio.addEventListener("ended", function () {
|
|
|
- _this.playClass = "";
|
|
|
+ //_this.playClass = "";
|
|
|
});
|
|
|
},
|
|
|
//生命周期-创建之前
|