下载webtrc-streamer的压缩包,在github上有 https://github.com/mpromonet/webrtc-streamer/releases
将下载包html文件夹下webrtcstreamer.js文件和html/libs文件夹下adapter.min.js文件复制到VUE项目public/stactic目录下,在index.html文件里引入这两个js文件。
解压之后打开exe文件就可以播放了。(想做到把exe变成开机自启,这样就不用打开了。但是没做),有需要自行百度吧。
<template><video id="video" autoplay></video>
</template>
data() {
return {webRtcServer: null,videoPath_Channel1: "rtsp://", videoPath_Channel2: "rtsp:// ",
}
}mounted() {this.getVideoSatusPlay();},methods: {// 获取实时视频流rtsp
getVideoSatusPlay() {//192.168.1.100是启动webrtc-streamer的服务器IP,8000是webrtc-streamer的默认端口号,可以在服务端启动的时候更改的this.webRtcServer = new WebRtcStreamer("video",location.protocol + "//127.0.0.1:8000" // 本地);//需要看的rtsp视频地址,可以在网上找在线的rtsp视频地址来进行demo实验,在vlc中能播放就能用this.webRtcServer.connect(this.typeName == '可见光' ? this.videoPath_Channel1 : this.videoPath_Channel2);
},
}
beforeDestroy() {this.webRtcServer.disconnect();this.webRtcServer = null;
}