index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <div class="vent-flex-row-wrap">
  3. <div v-for="i in num" :key="i">
  4. <video :id="'video'+i" muted autoplay width="400" height="400"></video>
  5. </div>
  6. </div>
  7. </template>
  8. <script lang="ts" setup>
  9. import {onMounted, onUnmounted} from 'vue';
  10. const webRtcServerList = <any[]>[]
  11. const num = 10
  12. const urls = [
  13. 'rtsp://76.75.8.120/axis-media/media.amp',
  14. 'rtsp://80.90.151.112/axis-media/media.amp',
  15. 'rtsp://174.6.126.86/axis-media/media.amp',
  16. 'rtsp://213.34.225.97/axis-media/media.amp',
  17. 'rtsp://76.75.8.120/axis-media/media.amp',
  18. 'rtsp://176.65.94.105/axis-media/media.amp',
  19. 'rtsp://37.157.51.30/axis-media/media.amp',
  20. 'rtsp://64.187.201.16/axis-media/media.amp',
  21. 'rtsp://194.32.173.211/axis-media/media.amp',
  22. 'rtsp://admin:admin12345@192.168.1.64:554/Streaming/Channels/1'
  23. ]
  24. function getVideo() {
  25. for(let i =1; i<= num; i++){
  26. const webRtcServer = new window['WebRtcStreamer']('video'+i , location.protocol + '//192.168.183.216:8000')
  27. webRtcServerList.push(webRtcServer)
  28. webRtcServer.connect('rtsp://admin:admin12345@192.168.183.64:554/Streaming/Channels/1')
  29. // webRtcServer.connect(urls[i])
  30. }
  31. }
  32. onMounted(() => {
  33. getVideo()
  34. })
  35. onUnmounted(() => {
  36. for (let i = 0; i < num; i++) {
  37. webRtcServerList[i].disconnect()
  38. webRtcServerList[i] = null
  39. }
  40. })
  41. </script>
  42. <style lang="less">
  43. </style>