windows基于webrtc-streamer的rtsp播放(vue)

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>
 

5.效果

在这里插入图片描述

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值