|
@@ -167,7 +167,10 @@ export default {
|
|
|
// 开始录音
|
|
|
microphone() {
|
|
|
let _this = this;
|
|
|
- if (!this.microphoneStatus) {
|
|
|
+
|
|
|
+ if (!_this.microphoneStatus) {
|
|
|
+ _this.hasMicro = "";
|
|
|
+ _this.$root.isRecording = true;
|
|
|
_this.$emit("getWavblob", null);
|
|
|
this.$emit("getSelectData", { type: '' });
|
|
|
// 开始录音
|
|
@@ -193,6 +196,7 @@ export default {
|
|
|
} else {
|
|
|
this.hasMicro = "normal";
|
|
|
this.recorder.stop();
|
|
|
+ _this.$root.isRecording = false;
|
|
|
clearInterval(_this.timer);
|
|
|
// if (
|
|
|
// (this.type && this.type == "normal") ||
|
|
@@ -227,44 +231,46 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
playmicrophone(totalTimes) {
|
|
|
- this.isPlaying = true;
|
|
|
- if (this.selectIndex || this.selectIndex == 0) {
|
|
|
- let totalTime = totalTimes;
|
|
|
- let _this = this;
|
|
|
- if (!this.audio.paused) {
|
|
|
- this.audio.pause();
|
|
|
- clearInterval(_this.timer);
|
|
|
- } else if (this.audio.paused && _this.oldIndex == _this.selectIndex) {
|
|
|
- _this.audio.play();
|
|
|
- if (_this.recordtime == 0) {
|
|
|
- _this.recordtime = totalTimes;
|
|
|
+ if(this.hasMicro){
|
|
|
+ this.isPlaying = true;
|
|
|
+ if (this.selectIndex || this.selectIndex == 0) {
|
|
|
+ let totalTime = totalTimes;
|
|
|
+ let _this = this;
|
|
|
+ if (!this.audio.paused) {
|
|
|
+ this.audio.pause();
|
|
|
+ clearInterval(_this.timer);
|
|
|
+ } else if (this.audio.paused && _this.oldIndex == _this.selectIndex) {
|
|
|
+ _this.audio.play();
|
|
|
+ if (_this.recordtime == 0) {
|
|
|
+ _this.recordtime = totalTimes;
|
|
|
+ _this.playtime = 0;
|
|
|
+ }
|
|
|
+ _this.timer = setInterval(() => {
|
|
|
+ if (_this.playtime < totalTime) {
|
|
|
+ _this.playtime++;
|
|
|
+ _this.recordtime = totalTime - _this.playtime;
|
|
|
+ } else {
|
|
|
+ clearInterval(_this.timer);
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ } else {
|
|
|
+ _this.audio.pause();
|
|
|
+ _this.audio.load();
|
|
|
+ _this.audio.src = _this.wavblob;
|
|
|
+ _this.oldIndex = _this.selectIndex;
|
|
|
+ _this.audio.play();
|
|
|
_this.playtime = 0;
|
|
|
+ _this.recordtime = totalTime;
|
|
|
+ clearInterval(_this.timer);
|
|
|
+ _this.timer = setInterval(() => {
|
|
|
+ if (_this.playtime < totalTime) {
|
|
|
+ _this.playtime++;
|
|
|
+ _this.recordtime = totalTime - _this.playtime;
|
|
|
+ } else {
|
|
|
+ clearInterval(_this.timer);
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
}
|
|
|
- _this.timer = setInterval(() => {
|
|
|
- if (_this.playtime < totalTime) {
|
|
|
- _this.playtime++;
|
|
|
- _this.recordtime = totalTime - _this.playtime;
|
|
|
- } else {
|
|
|
- clearInterval(_this.timer);
|
|
|
- }
|
|
|
- }, 1000);
|
|
|
- } else {
|
|
|
- _this.audio.pause();
|
|
|
- _this.audio.load();
|
|
|
- _this.audio.src = _this.wavblob;
|
|
|
- _this.oldIndex = _this.selectIndex;
|
|
|
- _this.audio.play();
|
|
|
- _this.playtime = 0;
|
|
|
- _this.recordtime = totalTime;
|
|
|
- clearInterval(_this.timer);
|
|
|
- _this.timer = setInterval(() => {
|
|
|
- if (_this.playtime < totalTime) {
|
|
|
- _this.playtime++;
|
|
|
- _this.recordtime = totalTime - _this.playtime;
|
|
|
- } else {
|
|
|
- clearInterval(_this.timer);
|
|
|
- }
|
|
|
- }, 1000);
|
|
|
}
|
|
|
}
|
|
|
},
|