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>
    

相关推荐

  1. vueswiper使用

    2024-03-28 07:04:04       48 阅读
  2. Vue 如何模块化使用 Vuex

    2024-03-28 07:04:04       53 阅读
  3. vue使用webrtc streamer linux

    2024-03-28 07:04:04       50 阅读
  4. Vue使用watch监听Vuex的数据变化

    2024-03-28 07:04:04       35 阅读
  5. vue字典的使用

    2024-03-28 07:04:04       53 阅读
  6. vue的常见使用

    2024-03-28 07:04:04       44 阅读
  7. IDEA如何使用Vue

    2024-03-28 07:04:04       57 阅读
  8. vuewebsocket的使用

    2024-03-28 07:04:04       65 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-28 07:04:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-28 07:04:04       101 阅读
  3. 在Django里面运行非项目文件

    2024-03-28 07:04:04       82 阅读
  4. Python语言-面向对象

    2024-03-28 07:04:04       91 阅读

热门阅读

  1. tensorflow | no module name tf_slim

    2024-03-28 07:04:04       41 阅读
  2. 什么是软件缺陷(bug)?

    2024-03-28 07:04:04       37 阅读
  3. Should的形式化

    2024-03-28 07:04:04       44 阅读
  4. 为什么ConcurrentHashMap不允许null值?

    2024-03-28 07:04:04       41 阅读
  5. 腾讯云轻量8核16G18M服务器多少钱一年?

    2024-03-28 07:04:04       40 阅读
  6. 机器学习:概念、步骤、分类和实践

    2024-03-28 07:04:04       35 阅读
  7. uniapp 用web-view 嵌套uniapp

    2024-03-28 07:04:04       33 阅读
  8. Floyd算法 【多源最短路】模板

    2024-03-28 07:04:04       39 阅读
  9. 服务器硬件基础知识详解

    2024-03-28 07:04:04       35 阅读