vue中使用webrtc streamer linux中

docker 部署webrtc streamer

docker run -itd --net=host --name webrtc-streamer mpromonet/webrtc-streamer

** 要加–net=host ** 不然预览相机画面时会出现一直转圈无法加载的问题

vue 利用webrtc streamer 播放rtsp

  1. 下webrtcstreamer.js文件和html/libs文件夹下adapter.min.js文件复制到VUE项目public目录下。在index.html文件里引入这两个js文件
  2. 示例代码
    <template>
      <div>
        <video id="video" autoplay width="900" height="900"></video>
      </div>
    </template>
    
    <script setup>
    // const webRtcServer = ref();
    
    import { ref } from 'vue';
    import { computed } from 'vue';
    import { nextTick } from 'vue';
    
    
    
    //获取webRtc服务
    const webRtcServer = ref()
    const initWebRtcServer = async () => {
      nextTick(() => {
        // video:需要绑定的video控件ID
        // rtspUrl = "rtsp://127.0.0.1:8554/";
    
        let option = "rtptransport=tcp";
        // webRtcServer.value = new WebRtcStreamer('video', location.protocol + '//192.168.0.35:8000')
        //需要查看的rtsp地址
        webRtcServer.value.connect(rtspUrl, null, option, null);
        //webRtcServer.value.connect(rtspUrl);
      })
    }
    //页面销毁时销毁webRtc
    const webRtcServerDis = computed(() => {
      webRtcServer.value.disconnect()
      webRtcServer.value = null
    })
    
    initWebRtcServer()
    
    </script>
    
    <style scoped></style>
    
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值