|
@@ -5,19 +5,19 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {DataFunc} from '@/utils/datafunc';
|
|
|
-import {Aes} from '@/utils/encrypt';
|
|
|
+import { DataFunc } from '@/utils/datafunc';
|
|
|
+import { Aes } from '@/utils/encrypt';
|
|
|
|
|
|
|
|
|
export default {
|
|
|
name: "VideoComponent",
|
|
|
data() {
|
|
|
return {
|
|
|
- cacheData: {linkDoms: []},
|
|
|
+ cacheData: { linkDoms: [] },
|
|
|
clientId: "UVP" + Math.floor(Math.random() * 99999999),
|
|
|
nrUvpVideoObj: '',
|
|
|
cameraConfig: {},
|
|
|
- location:'',
|
|
|
+ location: '',
|
|
|
};
|
|
|
},
|
|
|
destroyed() {
|
|
@@ -43,9 +43,9 @@ export default {
|
|
|
that.importJsFile();
|
|
|
|
|
|
window.onEventNotify = (type, context) => {
|
|
|
- console.log("==播放回调==",type, context);
|
|
|
+ console.log("==播放回调==", type, context);
|
|
|
if (type === 100) {
|
|
|
- if (!that.nrUvpVideoObj){
|
|
|
+ if (!that.nrUvpVideoObj) {
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -65,7 +65,7 @@ export default {
|
|
|
// },
|
|
|
|
|
|
//引入外部js文件
|
|
|
- importJsFile () {
|
|
|
+ importJsFile() {
|
|
|
const that = this;
|
|
|
const linkData = [
|
|
|
{
|
|
@@ -121,34 +121,34 @@ export default {
|
|
|
|
|
|
//授权验证
|
|
|
initViewer() {
|
|
|
- const that = this;
|
|
|
- let apiUrl = '/uvp-backend-common/api/v1/authorization';
|
|
|
- if (apiUrl.startsWith('/sxgw')) {
|
|
|
- apiUrl = apiUrl.substring(4);
|
|
|
- }
|
|
|
- DataFunc.post(apiUrl, {
|
|
|
- ak: that.cameraConfig.ak,
|
|
|
- sk: that.cameraConfig.sk
|
|
|
- }, { location: true }).then(res => {
|
|
|
- console.log("==获取的授权信息==", res);
|
|
|
- if (res && res.resultValue) {
|
|
|
- that.cameraConfig.token = res.resultValue.token;
|
|
|
- // 加载播放器
|
|
|
- this.$emit("videoLoad", this);
|
|
|
- }
|
|
|
- }).catch(error => {
|
|
|
- console.error("请求失败:", error);
|
|
|
- });
|
|
|
-},
|
|
|
+ const that = this;
|
|
|
+ let apiUrl = '/uvp-backend-common/api/v1/authorization';
|
|
|
+ if (apiUrl.startsWith('/sxgw')) {
|
|
|
+ apiUrl = apiUrl.substring(4);
|
|
|
+ }
|
|
|
+ DataFunc.post(apiUrl, {
|
|
|
+ ak: that.cameraConfig.ak,
|
|
|
+ sk: that.cameraConfig.sk
|
|
|
+ }, { location: true }).then(res => {
|
|
|
+ console.log("==获取的授权信息==", res);
|
|
|
+ if (res && res.resultValue) {
|
|
|
+ that.cameraConfig.token = res.resultValue.token;
|
|
|
+ // 加载播放器
|
|
|
+ this.$emit("videoLoad", this);
|
|
|
+ }
|
|
|
+ }).catch(error => {
|
|
|
+ console.error("请求失败:", error);
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
//开始播放
|
|
|
videoPlay(options) {
|
|
|
const that = this;
|
|
|
- if(!options || !options.code) {
|
|
|
- console.log("==设备编码不全,无法播放==");
|
|
|
+ if (!options || !options.code) {
|
|
|
+ console.log("==设备编码不全,无法播放==");
|
|
|
return;
|
|
|
}
|
|
|
- if(!that.nrUvpVideoObj) {
|
|
|
+ if (!that.nrUvpVideoObj) {
|
|
|
console.log("==创建播放器==");
|
|
|
that.nrUvpVideoObj = new UVPVideoObj({
|
|
|
id: that.clientId,
|
|
@@ -160,7 +160,7 @@ export default {
|
|
|
callback: onEventNotify
|
|
|
});
|
|
|
}
|
|
|
- console.log("==开始播放==>参数集: ",JSON.stringify(options));
|
|
|
+ console.log("==开始播放==>参数集: ", JSON.stringify(options));
|
|
|
that.nrUvpVideoObj.uvpVideoPlay({
|
|
|
winNum: options.winNum,
|
|
|
devCode: options.code,
|
|
@@ -171,64 +171,64 @@ export default {
|
|
|
|
|
|
// 云台控制
|
|
|
videoControl(options) {
|
|
|
- if (!options?.code) return;
|
|
|
- // if (!this.nrUvpVideoObj) {
|
|
|
- // this.nrUvpVideoObj = new UVPVideoObj({
|
|
|
- // id: that.clientId,
|
|
|
- // winNum: options.winNum,
|
|
|
- // ip: that.cameraConfig.ip,
|
|
|
- // port: that.cameraConfig.port,
|
|
|
- // token: that.cameraConfig.token,
|
|
|
- // ak: that.cameraConfig.ak,
|
|
|
- // callback: onEventNotify
|
|
|
- // });
|
|
|
- // }
|
|
|
- console.log("==进入云台操作==>参数集: ",JSON.stringify(options));
|
|
|
- this.nrUvpVideoObj.uvpVideoControl({
|
|
|
- devCode: options.code,
|
|
|
- cmd: options.control,
|
|
|
- lspeed: 5,
|
|
|
- rspeed: 5,
|
|
|
- });
|
|
|
- },
|
|
|
+ if (!options?.code) return;
|
|
|
+ // if (!this.nrUvpVideoObj) {
|
|
|
+ // this.nrUvpVideoObj = new UVPVideoObj({
|
|
|
+ // id: that.clientId,
|
|
|
+ // winNum: options.winNum,
|
|
|
+ // ip: that.cameraConfig.ip,
|
|
|
+ // port: that.cameraConfig.port,
|
|
|
+ // token: that.cameraConfig.token,
|
|
|
+ // ak: that.cameraConfig.ak,
|
|
|
+ // callback: onEventNotify
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ console.log("==进入云台操作==>参数集: ", JSON.stringify(options));
|
|
|
+ this.nrUvpVideoObj.uvpVideoControl({
|
|
|
+ devCode: options.code,
|
|
|
+ cmd: options.control,
|
|
|
+ lspeed: 5,
|
|
|
+ rspeed: 5,
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
|
|
|
// 视频截图
|
|
|
- capture(options){
|
|
|
- if (!options?.code) return;
|
|
|
- console.log("==开始截图==>参数集: ",JSON.stringify(options));
|
|
|
+ capture(options) {
|
|
|
+ if (!options?.code) return;
|
|
|
+ console.log("==开始截图==>参数集: ", JSON.stringify(options));
|
|
|
this.nrUvpVideoObj.uvpCapture({
|
|
|
winNum: options.winNum,
|
|
|
- fileName:"",
|
|
|
- fileType:1
|
|
|
+ fileName: "",
|
|
|
+ fileType: 1
|
|
|
});
|
|
|
|
|
|
},
|
|
|
//播放结束
|
|
|
videoStop(winNum) {
|
|
|
const that = this;
|
|
|
- that.nrUvpVideoObj && that.nrUvpVideoObj.uvpVideoClose({winNum});
|
|
|
+ that.nrUvpVideoObj && that.nrUvpVideoObj.uvpVideoClose({ winNum });
|
|
|
},
|
|
|
// 生成UUID
|
|
|
- generateUUID() {
|
|
|
- var d = new Date().getTime();
|
|
|
- var d2 = (performance && performance.now && (performance.now()*1000)) || 0;
|
|
|
- return 'xxxxxxxxxxxx4xxxy'.replace(/[xy]/g, function(c) {
|
|
|
+ generateUUID() {
|
|
|
+ var d = new Date().getTime();
|
|
|
+ var d2 = (performance && performance.now && (performance.now() * 1000)) || 0;
|
|
|
+ return 'xxxxxxxxxxxx4xxxy'.replace(/[xy]/g, function (c) {
|
|
|
var r = Math.random() * 16;
|
|
|
- if(d > 0) {
|
|
|
- r = (d + r)%16 | 0;
|
|
|
- d = Math.floor(d/16);
|
|
|
+ if (d > 0) {
|
|
|
+ r = (d + r) % 16 | 0;
|
|
|
+ d = Math.floor(d / 16);
|
|
|
} else {
|
|
|
- r = (d2 + r)%16 | 0;
|
|
|
- d2 = Math.floor(d2/16);
|
|
|
+ r = (d2 + r) % 16 | 0;
|
|
|
+ d2 = Math.floor(d2 / 16);
|
|
|
}
|
|
|
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
|
|
- });
|
|
|
-},
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
getCurrentTimestamp() {
|
|
|
- return new Date().getTime();
|
|
|
- }
|
|
|
+ return new Date().getTime();
|
|
|
+ }
|
|
|
|
|
|
},
|
|
|
};
|