videoPlay.vue
3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<template>
<div class="ocx-box" id="ocx-box" v-show="isShow">
<object
id="VionVideo"
classid="clsid:93F960BB-5AF9-402B-A3DF-06112F14DC02"
codebase="VionPlatformVideo.ocx"
width="100%"
height="100%"
>
<!-- <param name="_Version" value="65536">
<param name="_ExtentX" value="2646">
<param name="_ExtentY" value="1323">
<param name="_StockProps" value="0"> -->
</object>
</div>
</template>
<script>
import { mapState } from "vuex";
export default {
data() {
return {
urlFlag: false,
isShow: true
};
},
props: ["playurl", "type"],
methods: {
videoPlay: function() {
this.urlFlag = false;
if (!this.playurl.sip_serv_ip) {
let url = this.playurl.rtsp_url;
let myVideo = document.getElementById("VionVideo");
try {
let isLoadingOcx = typeof myVideo.GetVersion() === "string" ? true : false;
if (isLoadingOcx) {
let ocxPlayRes = document.getElementById("VionVideo").StartPlay(url, 0);
console.log("video Ocx播放rtsp流返回值:", ocxPlayRes);
} else {
this.installOcxInfo();
}
if (ocxPlayRes != 0) {
alert("播放失败!");
}
} catch (error) {
console.log(error);
}
} else {
let OcxResponse = document
.getElementById("VionVideo")
.StartPlaySip(
this.playurl.sip_serv_id,
this.playurl.sip_serv_ip,
this.playurl.sip_serv_port,
this.playurl.sip_unid,
this.playurl.sip_password,
this.playurl.devId,
0
);
console.log("video Ocx播放sip流返回值:", OcxResponse);
if (OcxResponse != 0 && OcxResponse != 200) {
alert("播放失败!");
}
}
},
downOcx: function() {
if (this.fileUrl !== "" && !this.installOcx) {
location.href = this.fileUrl;
}
},
installOcxInfo: function() {
this.$confirm("为了正常使用,是否安装OCX控件?", "友情提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.installOcx = false;
this.downloadOCx();
})
.catch(() => {
this.installOcxInfo();
});
},
initocx() {
VionVideo.Init(0, "Null", 4);
},
downloadOCx() {
if (navigator.userAgent.indexOf("Trident") > -1) {
let params = {
file_type: "video_ocx"
};
this.$api.ops.downloadOcx(params).then(response => {
location.href = response.data.file_url;
});
} else {
this.$message.error("视频控件加载失败请用IE10及以上版本打开!");
}
},
checkIE() {
var agent = navigator.userAgent.toLowerCase();
if (
/(msie\s|trident.*rv:)([\w.]+)/.test(agent) &&
document.documentMode < 10
) {
this.$message.error("IE 版本过低请升级到IE10级以上版本!");
}
}
},
created() {
// this.checkIE();
},
computed: {
...mapState(["ocxstate"])
},
watch: {
ocxstate(val) {
try {
if (val == 0) {
this.isShow = false;
document.getElementById("VionVideo").StartPlay(1);
} else {
this.isShow = true;
document.getElementById("VionVideo").StartPlay(0);
}
} catch (error) {
console.log(error);
}
}
},
beforeDestroy: function() {
// if (this.videoplayer.techName_ == "Flash" && this.videoplayer.pause) {
// this.videoplayer.pause();
// }
}
};
</script>
<style lang="stylus" scoped>
.ocx-box{
height 100%
width 100%
}
</style>