fix: 语音录音时长获取方式调整
This commit is contained in:
@@ -694,7 +694,7 @@
|
||||
voiceTime.value = (Math.ceil(talkVoiceObj.value.duration) || 0) + 's';
|
||||
} else {
|
||||
if (sum === 100) {
|
||||
voiceTime.value = 0 + 's';
|
||||
voiceTime.value = (unref(dataInfo).voiceTime || 0) + 's';
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -174,6 +174,7 @@
|
||||
const initRecord = () => {
|
||||
recordObjCom.value = uni.getRecorderManager();
|
||||
unref(recordObjCom)?.onStop((res, duration) => {
|
||||
isRecording.value = false
|
||||
if(isGettingPermission.value){
|
||||
isGettingPermission.value = false
|
||||
return
|
||||
@@ -196,13 +197,20 @@
|
||||
});
|
||||
} else {
|
||||
closeModel();
|
||||
emit('uploadVoice', audioPath.value);
|
||||
emit('uploadVoice', audioPath.value, recordTime.value);
|
||||
}
|
||||
} else {
|
||||
closeModel();
|
||||
}
|
||||
});
|
||||
unref(recordObjCom).onStart(() => {
|
||||
isRecording.value = true
|
||||
recordTime.value = 0
|
||||
setRecordTime()
|
||||
if(isGettingPermission.value){
|
||||
isGettingPermission.value = false
|
||||
return
|
||||
}
|
||||
startFlag.value = 1;
|
||||
setTimeout(() => {
|
||||
startFlag.value = 2;
|
||||
@@ -219,6 +227,16 @@
|
||||
}
|
||||
});
|
||||
};
|
||||
const setRecordTime = () => {
|
||||
setTimeout(()=>{
|
||||
if(isRecording.value){
|
||||
recordTime.value += 1
|
||||
setRecordTime()
|
||||
}
|
||||
},1000)
|
||||
}
|
||||
const isRecording = ref(false)
|
||||
const recordTime = ref(0)
|
||||
const startFlag = ref(1);
|
||||
// const canStart = ref(true)
|
||||
const startRecord = () => {
|
||||
|
||||
@@ -839,7 +839,7 @@ const testAnswer = computed(() => {
|
||||
let _num = _arr.map(t => [1, 2, 6].indexOf(Number(t.type)) >= 0).filter(t => !!t)
|
||||
return _num.length < 5
|
||||
})
|
||||
const uploadRecordNow = voicePath => {
|
||||
const uploadRecordNow = (voicePath, voiceTime) => {
|
||||
if (!testAnswer.value) {
|
||||
common.msg('每个问题最多连续发送五次答案!')
|
||||
return
|
||||
@@ -911,7 +911,8 @@ const uploadRecordNow = voicePath => {
|
||||
userInfo: {
|
||||
...choiceTeacherInfo.value
|
||||
},
|
||||
id: _id
|
||||
id: _id,
|
||||
voiceTime: voiceTime
|
||||
}
|
||||
} else {
|
||||
return t
|
||||
|
||||
@@ -131,7 +131,7 @@ import { onUnload } from '@dcloudio/uni-app';
|
||||
voiceTime.value = (Math.ceil(talkVoiceObj.value.duration) || 1 ) + 's'
|
||||
}else{
|
||||
if(sum === 20) {
|
||||
voiceTime.value = 0 + 's'
|
||||
voiceTime.value = (unref(dataInfo).voiceTime || 0) + 's';
|
||||
return
|
||||
}
|
||||
setTimeout(()=>{
|
||||
|
||||
@@ -662,7 +662,7 @@
|
||||
submitAnswerNow(item);
|
||||
};
|
||||
// 发送语音
|
||||
const uploadRecordNow = (voicePath) => {
|
||||
const uploadRecordNow = (voicePath, voiceTime) => {
|
||||
// /traask/traAskchat/voiceTrans
|
||||
//#ifndef APP-PLUS
|
||||
// h5 假数据
|
||||
@@ -683,7 +683,8 @@
|
||||
intrctContent: _res.body.transContent,
|
||||
bucketKey: _res.body.fileId,
|
||||
ossFileAddr: _res.body.ossFileAddr,
|
||||
talkingVoice: voicePath
|
||||
talkingVoice: voicePath,
|
||||
voiceTime: voiceTime
|
||||
};
|
||||
sendMessage({
|
||||
commond: 'ASK',
|
||||
|
||||
@@ -130,8 +130,12 @@
|
||||
talkUserVoiceObj.value.onError(() => {
|
||||
talkUserVoiceObj.value.src = ''
|
||||
})
|
||||
talkUserVoiceObj.value.onCanplay(() => {
|
||||
setVoiceTime(0)
|
||||
})
|
||||
itemVoice.value = unref(dataInfo).talkingVoice
|
||||
talkUserVoiceObj.value.src = itemVoice.value
|
||||
talkUserVoiceObj.value.sessionCategory = 'soloAmbient'
|
||||
//#ifdef APP-PLUS
|
||||
// 安卓端 须播放一次,不然再次播放会没有声音
|
||||
if (IsAndEnv) {
|
||||
@@ -141,9 +145,9 @@
|
||||
// talkUserVoiceObj.value.pause()
|
||||
}
|
||||
// #endif
|
||||
setTimeout(() => {
|
||||
setVoiceTime(0)
|
||||
}, 100)
|
||||
// setTimeout(() => {
|
||||
// setVoiceTime(0)
|
||||
// }, 100)
|
||||
}
|
||||
const isTesting = ref(false)
|
||||
const setVoiceTime = (sum) => {
|
||||
@@ -152,7 +156,7 @@
|
||||
voiceTime.value = (Math.ceil(talkUserVoiceObj.value.duration) || 1) + 's'
|
||||
} else {
|
||||
if (sum === 20) {
|
||||
voiceTime.value = 0 + 's'
|
||||
voiceTime.value = (props.dataInfo.voiceTime|| 0) + 's'
|
||||
return
|
||||
}
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
const initRecord = () => {
|
||||
recordObjCom.value = uni.getRecorderManager();
|
||||
unref(recordObjCom)?.onStop((res, duration) => {
|
||||
isRecording.value = false
|
||||
if(isGettingPermission.value){
|
||||
isGettingPermission.value = false
|
||||
return
|
||||
@@ -141,13 +142,16 @@
|
||||
});
|
||||
} else {
|
||||
closeModel();
|
||||
emit('uploadVoice', audioPath.value);
|
||||
emit('uploadVoice', audioPath.value, recordTime.value);
|
||||
}
|
||||
} else {
|
||||
closeModel();
|
||||
}
|
||||
});
|
||||
unref(recordObjCom).onStart(() => {
|
||||
isRecording.value = true
|
||||
recordTime.value = 0
|
||||
setRecordTime()
|
||||
if(isGettingPermission.value){
|
||||
stopRecord();
|
||||
return
|
||||
@@ -167,6 +171,16 @@
|
||||
}
|
||||
});
|
||||
};
|
||||
const setRecordTime = () => {
|
||||
setTimeout(()=>{
|
||||
if(isRecording.value){
|
||||
recordTime.value += 1
|
||||
setRecordTime()
|
||||
}
|
||||
},1000)
|
||||
}
|
||||
const isRecording = ref(false)
|
||||
const recordTime = ref(0)
|
||||
const startFlag = ref(1);
|
||||
const startRecord = () => {
|
||||
isStartNum.value += 1;
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
}, time);
|
||||
});
|
||||
};
|
||||
const uploadRecordNow = (voicePath) => {
|
||||
const uploadRecordNow = (voicePath, voiceTime) => {
|
||||
//#ifndef APP-PLUS
|
||||
// h5 假数据
|
||||
// #endif
|
||||
@@ -211,7 +211,8 @@
|
||||
intrctContent: _res.body.transContent,
|
||||
fileId: _res.body.fileId,
|
||||
ossFileAddr: _res.body.ossFileAddr,
|
||||
talkingVoice: voicePath
|
||||
talkingVoice: voicePath,
|
||||
voiceTime: voiceTime
|
||||
};
|
||||
sendMessage({
|
||||
commond: 'ASK',
|
||||
|
||||
Reference in New Issue
Block a user