语音提示音改为之前电话铃声、语音播完再播另一个、其他语言问题

This commit is contained in:
dong 2023-11-29 17:24:46 +08:00
parent a95c91f640
commit 8e68e6e974
2 changed files with 36 additions and 17 deletions

View File

@ -123,12 +123,7 @@ export default {
}
},
id() {
this.currentAudioList = [];
this.messageList.forEach(item => {
this.$set(item, 'activeAuto', false);
});
const audioDom = document.querySelector('#audioPlay');
audioDom && audioDom.pause();
this.stopNoReadPlay();
this.cancelRecording();
}
},
@ -146,12 +141,29 @@ export default {
this.contentDom = '';
},
methods: {
stopNoReadPlay() {
this.currentAudioList = [];
this.messageList.forEach(item => {
this.$set(item, 'activeAuto', false);
});
const audioDom = document.querySelector('#audioPlay');
audioDom && audioDom.pause();
},
playNoReadMessage() {
if (!this.id && !this.privateChatId) return;
const list = this.getNoReadVoiceList();
if (list.length) {
this.currentAudioList = list;
this.playAllAudio();
if (this.play) {
const filterList = list.filter(item => {
return !this.currentAudioList.find(ii => {
return ii.id == item.id;
});
});
this.currentAudioList.push(...filterList);
} else {
if (list.length) {
this.currentAudioList = list;
this.playAllAudio();
}
}
},
getNoReadVoiceList() {
@ -160,12 +172,12 @@ export default {
});
return filter;
},
setActiveAutoFalse(ms) {
setActiveAutoStatus(ms, s = false) {
const findIndex = this.messageList.findIndex(item => {
return item.id == ms.id;
});
if (findIndex > -1) {
this.messageList.splice(findIndex, 1, {...this.messageList[findIndex], 'activeAuto': false});
this.$set(this.messageList[findIndex], 'activeAuto', s);
}
},
setIsBottomFn() {
@ -192,10 +204,11 @@ export default {
document.querySelector('#audioPlay').src = this.currentMessage.audioPath;
document.querySelector('#audioPlay').play();
this.$set(this.currentMessage, 'activeAuto', true);
this.setActiveAutoStatus(this.currentMessage, true);
this.play = true;
document.querySelector('#audioPlay').onended = () => {
this.$set(this.currentMessage, 'activeAuto', false);
this.setActiveAutoFalse(this.currentMessage);
this.setActiveAutoStatus(this.currentMessage);
if (!this.currentAudioList || !this.currentAudioList.length) {
this.play = false;
} else {
@ -205,8 +218,7 @@ export default {
});
},
playAudio(audioPath, data) {
this.$set(this.currentMessage, 'activeAuto', false);
this.currentAudioList = [];
this.stopNoReadPlay();
this.currentMessage = data;
this.play = true;
document.querySelector('#audioPlay').src = audioPath;
@ -263,6 +275,10 @@ export default {
},
//
stopRecording() {
if (this.seconds < 1) {
this.$message.info('录制语音时间太短!');
return;
}
this.audioPlay = true;
clearInterval(this.inter);
this.seconds = 0;

View File

@ -16,7 +16,7 @@
import { OperationEvent } from '@/scripts/cmdPlugin/OperationHandler';
// import {UserOperationType} from '@/scripts/ConstDic';
import chatDialog from './chatDialog';
import BuzzerAudio from '@/assets/buzzer.mp3';
import teleRing from '@/assets/teleRing.mp3';
export default {
name: 'ChatBox',
components: {
@ -25,7 +25,7 @@ export default {
data() {
return {
totalUnreadNum: 0,
buzzerAudio: BuzzerAudio
buzzerAudio: teleRing
};
},
computed:{
@ -53,7 +53,10 @@ export default {
methods: {
playBuzzer() {
const audioDom = document.querySelector('#chatBuzzer');
audioDom && audioDom.play();
if (audioDom) {
audioDom.currentTime = 0;
audioDom.play();
}
},
pauseBuzzer() {
const audioDom = document.querySelector('#chatBuzzer');