From 488bc04d746bded791dad0bec3551228d2bca78b Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Thu, 02 Jun 2022 10:43:56 +0800
Subject: [PATCH] 海康语音对讲推送
---
src/components/real-popup/main.vue | 82 +++++++++++++++++++++++++++++++++++-----
1 files changed, 71 insertions(+), 11 deletions(-)
diff --git a/src/components/real-popup/main.vue b/src/components/real-popup/main.vue
index f2467cb..030779d 100644
--- a/src/components/real-popup/main.vue
+++ b/src/components/real-popup/main.vue
@@ -157,6 +157,7 @@
<el-col span="12">
<el-form-item label="监控视频">
<el-button :class="{ active: isActive }"
+ v-if="form.manufacturers != 'HK'"
type="success"
@click.stop="
(videoConversationReal = true), (oldVideoSatart = false)
@@ -164,16 +165,17 @@
@mousedown.native="aKeyToCall"
@mouseup.native="aKeyStopCall">视频通话
</el-button>
+
<el-button :class="{ active: isActive }"
+ v-if="form.manufacturers == 'HK'"
type="success"
- @click.stop="HKCall(form)"
- >海康语音通话
+ @click.stop="
+ (videoConversationReal = true), (oldVideoSatart = false)
+ "
+ @mousedown.native="HKCall(form)"
+ @mouseup.native="HKStopCall(form)">海康语音通话
</el-button>
- <el-button :class="{ active: isActive }"
- type="success"
- @click.stop="HKStopCall(form)"
- >关闭语音通话
- </el-button>
+
<el-button v-show="false"
type="primary"
@click.stop="
@@ -327,10 +329,10 @@
szId: 'play_window',
szBasePath: "/",
iMaxSplit: 4,
- iCurrentSplit: 1 ,
+ iCurrentSplit: 1,
openDebug: true,
oStyle: {
- borderSelect: '#000',
+ borderSelect: '#000',
}
});
// 事件回调绑定
@@ -364,6 +366,16 @@
},
methods: {
HKCall(e) {
+ this.isActive = true;
+ var that = this;
+ if (this.recorder == null) {
+ this.recorder = new Recorder({
+ sampleBits: 16, // 采样位数,支持 8 或 16,默认是16
+ sampleRate: 8000, // 采样率,支持 11025、16000、22050、24000、44100、48000,根据浏览器默认值,我的chrome是48000
+ numChannels: 1, // 声道,支持 1 或 2, 默认是1
+ // compiling: false,(0.x版本中生效,1.x增加中) // 是否边录边转换,默认是false
+ });
+ }
axios({
method: "get",
url: `/api/blade-jfpts/equipment/equipment/EquimentVoice?`,
@@ -377,6 +389,16 @@
this.player.JS_StartTalk(url).then(
() => {
console.log('talkStart success')
+ // 一键呼叫相关函数
+ that.recorder.start().then(
+ () => {
+ // 开始录音
+ },
+ (error) => {
+ // 出错了
+ console.log(`${error.name} : ${error.message}`);
+ }
+ );
},
e => {
console.error(e)
@@ -386,9 +408,47 @@
});
},
HKStopCall() {
+ this.isActive = false;
+ var that = this;
this.player.JS_StopTalk().then(
- () => { console.log('talkStop success') },
- e => { console.error(e) }
+ () => {
+ console.log('talkStop success')
+ var formData = new FormData();
+ // that.recorder.downloadWAV("新文件");
+
+ var blob = that.recorder.getPCMBlob(); //获取pcm格式音频数据
+ //此处获取到blob对象后需要设置fileName满足当前项目上传需求,其它项目可直接传把blob作为file塞入formData
+ var newbolb = new Blob([blob], {type: "audio/pcm"});
+ var fileOfBlob = new File([newbolb], new Date().getTime() + ".pcm");
+ formData.append("file", fileOfBlob);
+
+ var wavBlob = that.recorder.getWAVBlob();
+
+ var wavformData = new FormData();
+ var wavform = new File([wavBlob], new Date().getTime() + ".wav");
+ wavformData.append("file", wavform);
+ console.log(
+ wavBlob,
+ wavform,
+ wavformData,
+ wavformData.entries(),
+ 132
+ );
+ axios({
+ method: "post",
+ url: "/api/blade-jfpts/xlfeedback/xlfeedback/put-objecty",
+ data: wavformData,
+ params: {
+ jid: that.form.id,
+ },
+ }).then((resdata) => {
+
+ console.log(resdata);
+ });
+ },
+ e => {
+ console.error(e)
+ }
)
},
realOpenVideoDialog() {
--
Gitblit v1.9.3