1.html栏里有关于html版本的
2.将html/webrtcstreamer.js、html/libs/adapter.min.js复制到vue项目里的public目录里。
3.修改index.html文件
<script src="<%= BASE_URL %>adapter.min.js"></script>
<script src="<%= BASE_URL %>webrtcstreamer.js"></script>
4.index.vue
<template>
<div>
<!-- <el-button @click="handleChange">切换</el-button> -->
<video id="video" muted autoplay width="400" height="300" style="border:1px solid #333;"></video>
</div>
</template>
<script>
export default {
name: 'videos',
data() {
return {
webRtcServer: null
}
},
mounted() {
//video:需要绑定的video控件ID
//127.0.0.1:8000:启动webrtc-streamer的设备IP和端口,默认8000
this.webRtcServer = new WebRtcStreamer('video', 'http://127.0.0.1:9001')
//需要查看的rtsp地址
this.webRtcServer.connect("rtsp://admin:password@ip:prod/ch1/main/av_stream",null ,"rtptransport=tcp")
//rtsp://user:password@ip:port/h264/ch1/main/av_stream--海康
//rtsp://user:password@ip:port/cam/realmonitor?channel=1&subtype=0--大华
},
beforeDestroy() {
this.webRtcServer.disconnect()
this.webRtcServer = null
},
methods: {
handleChange() {
this.webRtcServer.connect('rtsp://admin:password@ip:prod/ch1/main/av_stream')
}
}
}
</script>