1.首先引入H5player
下载地址:海康开放平台
我是把demo的文件直接放到staic文件直接用他的demo.html,也能用bin文件自己创建html文件引入h5player.min.js文件 根据自己的需求
2.在需要用的页面直接
<iframe :src="this.webURL" frameborder="0" :style="styleObject"></iframe>
webURL:'./static/h5player/demo.html?data=',
async getData(params) {
uni.request({
url: 'http:xxxxxxxxxxxx',//请求地址
data: {
cameraIndexCode: this.code,
protocol: 'ws'
},
method: 'GET',
success: (res) => {
this.url = res.data.result
let playURL = this.url
this.webURL += playURL
}
})
},
3.在staic-h5player-demo.html
realplay() {
const paramsStr = window.location.search
const params = new URLSearchParams(paramsStr)//获取url的参数
this.urls.realplay = params.get('data')//获取url的参数播放地址
let realplay= params.get('data')
let {
player,
mode,
urls
} = this,
index = player.currentWindowIndex,
playURL = realplay
player.JS_Play(playURL, {
playURL,
mode
}, index).then(
() => {
console.log('realplay success')
},
e => {
console.error(e)
}
)
},
4.完成