新增控制指令

This commit is contained in:
weipengfei 2023-10-14 17:10:03 +08:00
parent 1341bc0438
commit 95a6257c53
1 changed files with 40 additions and 18 deletions

View File

@ -47,6 +47,45 @@ const connection = new Push({
// //
const recordFalg = ref(0) const recordFalg = ref(0)
/**
* APP端命令目录
* start 开始录音
* end 录音完成
* re 重新录制
* clear 清空对话
* pause 暂停播放
* play 继续播放
* stop 停止播放
* re-play 重新播放
*/
const runOrder = (e)=>{
switch(e){
case 'start': startOrder();break;
case 'end':endOrder();break;
}
}
const startOrder = ()=>{
if (recordFalg.value == 0) {
RecordXunfei()
recordFalg.value = 1
nowStatus.value = 'record'
}else {
console.log('无效指令');
}
}
const endOrder = ()=>{
if(recordFalg.value==1){
RecordXunfei()
recordFalg.value = 0
nowStatus.value = 'loding'
handleSubmit()
}else {
console.log('无效指令');
}
}
// uid1 // uid1
const uid = 1 const uid = 1
// user-1uid1 // user-1uid1
@ -56,24 +95,7 @@ console.log(user_channel)
user_channel.on('message', (data: any) => { user_channel.on('message', (data: any) => {
// data // data
console.log('收到命令', data) console.log('收到命令', data)
return null runOrder(data.content)
if (messageRef.value?.length > 0)
messageRef.value[messageRef.value.length - 1].stopPlay()
if (socket?.readyState < 2)
socket.close()
// return
if (recordFalg.value == 0) {
RecordXunfei()
recordFalg.value = 1
nowStatus.value = 'record'
}
else {
RecordXunfei()
recordFalg.value = 0
nowStatus.value = 'loding'
handleSubmit()
}
}) })
const changeRecord = () => { const changeRecord = () => {