From 41a7f6de32bb90f71a8db7d2bb5ba98f2aa74c5f Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Mon, 01 Feb 2021 16:41:01 +0800
Subject: [PATCH] 修改PCM处理
---
src/views/realTimePolice/real.vue | 90 ++++++++++++++-------------------------------
1 files changed, 28 insertions(+), 62 deletions(-)
diff --git a/src/views/realTimePolice/real.vue b/src/views/realTimePolice/real.vue
index 12c8078..d45e609 100644
--- a/src/views/realTimePolice/real.vue
+++ b/src/views/realTimePolice/real.vue
@@ -273,17 +273,8 @@
</el-form>
</el-dialog>
- <el-drawer
- title="电子地图"
- append-to-body="true"
- :visible.sync="showMap"
- >
- <iframe
- :src="mapUrl"
- frameborder="0"
- width="100%"
- height="100%"
- ></iframe>
+ <el-drawer title="电子地图" append-to-body="true" :visible.sync="showMap">
+ <iframe :src="mapUrl" frameborder="0" width="100%" height="100%"></iframe>
</el-drawer>
</basic-container>
</template>
@@ -302,7 +293,7 @@
data() {
return {
showMap: false,
- mapUrl:"https://s16s652780.51mypc.cn/jfpt/map/index.html",
+ mapUrl: "https://s16s652780.51mypc.cn/jfpt/map/index.html",
hls: "",
videoSource: "",
dialogTableVisible: false,
@@ -764,7 +755,8 @@
},
handleMap() {
this.showMap = true;
- this.mapUrl = "https://s16s652780.51mypc.cn/jfpt/map/index.html?openid=PatrolManagement"
+ this.mapUrl =
+ "https://s16s652780.51mypc.cn/jfpt/map/index.html?openid=PatrolManagement";
},
handleManage(row) {
this.form = row;
@@ -906,7 +898,6 @@
};
},
queryOldVideo(data) {
- console.log(data);
var newAxios = axios.create({
baseURL: "https://s16s652780.51mypc.cn",
withCredentials: false,
@@ -928,8 +919,6 @@
}
)
.then(res => {
- console.log(res.data.data.accessToken);
-
newAxios
.get(
`/GetPlayUrl?deviceCode=${data.channelNumber}&chl=${data.serialNumber}`
@@ -974,11 +963,7 @@
this.hls = new Hls();
- console.log(this.videoSource, "19028321321r073");
-
var m3u8Url = decodeURIComponent(this.videoSource);
-
- console.log(m3u8Url);
this.hls.loadSource(m3u8Url);
@@ -999,7 +984,7 @@
}
},
aKeyToCall(e, form) {
- var newAxios = axios.create({
+ var newCallAxios = axios.create({
baseURL: "https://s16s652780.51mypc.cn",
withCredentials: false,
headers: {
@@ -1011,7 +996,7 @@
if (this.isActive == true) {
this.isActive = false;
- newAxios
+ newCallAxios
.post(
`/api_control`,
{},
@@ -1022,18 +1007,29 @@
}
)
.then(result => {
- console.log(result, 11111111);
var formData = new FormData();
- var blob = this.recorder.getPCMBlob() //获取wav格式音频数据
+ var blob = this.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);
- console.log(blob, newbolb, fileOfBlob, 99999);
+ document
+ .getElementById("real_audio")
+ .setAttribute("src", URL.createObjectURL(blob));
- newAxios
- .post(`/api_control`, formData, {
+ console.log(
+ blob,
+ newbolb,
+ fileOfBlob,
+ window.URL.createObjectURL(blob),
+ 99999
+ );
+
+ this.recorder.play();
+
+ newCallAxios
+ .post(`/api_control`, blob, {
params: {
param: {
PktType: "Talk",
@@ -1042,46 +1038,16 @@
}
}
})
- .then(result => {
- console.log(result);
- });
+ .then(result => {});
});
} else {
this.isActive = true;
- Recorder.getPermission().then(
- () => {
- console.log("给权限了");
-
- this.recorder.start().then(
- () => {
- // 开始录音
- console.log("开始录音了");
- },
- error => {
- // 出错了
- console.log(`${error.name} : ${error.message}`);
- }
- );
- },
- error => {
- console.log(`${error.name} : ${error.message}`);
- }
- );
-
- var newAxios = axios.create({
- baseURL: "https://s16s652780.51mypc.cn",
- withCredentials: false,
- headers: {
- "Content-Type": "application/json;"
- }
- });
-
- newAxios
- .post(`/talk?deviceCode=${form.channelNumber}`, "12345")
- .then(result => {
- console.log(result);
+ Recorder.getPermission().then(() => {
+ this.recorder.start().then(() => {
+ // 开始录音
});
+ });
}
}
}
--
Gitblit v1.9.3