4 changed files with 165 additions and 53 deletions
-
6src/views/assetManage/monitor/deviceList.vue
-
20src/views/assetManage/monitor/index.vue
-
71src/views/components/hkVideo-old.vue
-
117src/views/components/hkVideo.vue
@ -0,0 +1,71 @@ |
|||||
|
<template> |
||||
|
<div style="width: 100%; height: 100%; overflow: hidden;"> |
||||
|
<!-- <h1>海康威视视频流</h1> --> |
||||
|
<!-- <h3>400W</h3> |
||||
|
<VideoCom :rtsp="rtspurl1" ref="video1"></VideoCom> |
||||
|
<h3>800W</h3> |
||||
|
<VideoCom :rtsp="rtspurl2" ref="video2"></VideoCom> --> |
||||
|
|
||||
|
<video id="video" controls autoplay muted width="100%" height="100%" /> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
// import VideoCom from '../components/video' |
||||
|
// rtsp://admin:ftzn83560792@192.168.99.23:554/h264/ch1/main/av_stream |
||||
|
// rtsp://admin:ftzn83560792@192.168.99.26:554/Streaming/Channels/101 |
||||
|
export default { |
||||
|
name: 'Home', |
||||
|
components: { |
||||
|
// VideoCom |
||||
|
}, |
||||
|
props: { |
||||
|
hkConfig: { |
||||
|
type: Object, |
||||
|
required: true |
||||
|
} |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
webRtcServer: null, |
||||
|
camera_ip: '127.0.0.1:8000' |
||||
|
} |
||||
|
}, |
||||
|
created() { |
||||
|
// this.controlVolume() |
||||
|
}, |
||||
|
mounted() { |
||||
|
|
||||
|
}, |
||||
|
// 销毁视频流 |
||||
|
beforeDestroy() { |
||||
|
this.webRtcServer.disconnect() |
||||
|
this.webRtcServer = null |
||||
|
}, |
||||
|
methods: { |
||||
|
controlVolume() { |
||||
|
this.$nextTick(() => { |
||||
|
this.$refs.video1.volume = 0 |
||||
|
this.$refs.video2.volume = 0 |
||||
|
}) |
||||
|
}, |
||||
|
initVideo() { |
||||
|
// video:需要绑定的video控件ID |
||||
|
// 127.0.0.1:8000:启动webrtc-streamer的设备IP和端口,默认8000 |
||||
|
const linkSrc = process.env.NODE_ENV === 'production' ? window.g.ApiWebRtcServerUrl : process.env.VUE_APP_WEBRTCSTREAMER_API |
||||
|
this.camera_ip = linkSrc |
||||
|
console.log('hkConfig', this.hkConfig) |
||||
|
// eslint-disable-next-line no-undef |
||||
|
this.webRtcServer = new WebRtcStreamer('video', location.protocol + '//' + this.camera_ip) |
||||
|
// 需要查看的rtsp地址,根据自己的摄像头传入对应的rtsp地址即可。注意:视频编码格式必须是H264的,否则无法正常显示,编码格式可在摄像头的后台更改 |
||||
|
this.webRtcServer.connect('rtsp://' + this.hkConfig.username + ':' + this.hkConfig.devicePassword + '@' + this.hkConfig.ip + ':' + this.hkConfig.port + '/h264/ch1/main/av_stream') |
||||
|
// 测试用 |
||||
|
// this.webRtcServer.connect('rtsp://admin:ftzn83560792@192.168.99.120:554/h264/1/1') |
||||
|
// this.webRtcServer.connect(rtsp_url) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss"> |
||||
|
</style> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue