播放h265流解决方案
文中代码:https://github.com/moxiefxj/video_vue
1. 视频WEB插件
- 视频WEB插件,下载的压缩包中含有播放监控所需要的插件、开发的demo等。
- 在项目中具体的实现(以vue组件实现为例)
<template>
<!--视频窗口展示-->
<div :id="id"></div>
</template>
<script>
export default {
name: "hkVideo",
data() {
return {
// 视频播放
initCount: 0, // 初始化重试次数,3次失败则报错
oWebControl: null, // 页面控制对象
pubKey: "",
cameraIp: "xxx.xxx.xx.xx", // 综合安防管理平台IP地址
};
},
props: ["code", "id"], // 接收父页面传来的摄像头 code
methods: {
// 创建播放实例
initPlugin() {
// 初始化播放插件
const _this = this;
_this.oWebControl = new WebControl({
szPluginContainer: _this.id, // 指定容器id
iServicePortStart: 15900, // 指定起止端口号,建议使用该值
iServicePortEnd: 15909,
szClassId: "23BF3B0A-2C56-4D97-9C03-0CB103AA8F11", // 用于IE10使用ActiveX的clsid
cbConnectSuccess: function () {
// 创建WebControl实例成功
console.log("创建WebControl实例成功");
_this.oWebControl
.JS_StartService("window", {
// WebControl实例创建成功后需要启动服务
dllPath: "./VideoPluginConnect.dll", // 值"./VideoPluginConnect.dll"写死
})
.then(
function () {
// 启动插件服务成功
console.log("启动插件服务成功");
_this.oWebControl.JS_SetWindowControlCallback({
// 设置消息回调
cbIntegrationCallBack: _this.cbIntegrationCallBack,
});
let divWidth = document.getElementById(_this.id).scrollWidth;
let divHeight = document.getElementById(_this.id).scrollHeight;
_this.oWebControl
.JS_CreateWnd(_this.id, divWidth, divHeight)
.then(function () {
//JS_CreateWnd创建视频播放窗口,宽高可设定
_this.init(); // 创建播放实例成功后初始化
});
},
function () {
// 启动插件服务失败
}
);
},
cbConnectError: function () {
// 创建WebControl实例失败
_this.oWebControl = null;
console.log("warn,插件未启动,正在尝试启动,请稍候...");
WebControl.JS_WakeUp("VideoWebPlugin://"); // 程序未启动时执行error函数,采用wakeup来启动程序
initCount++;
if