index_mute.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="videoBox">
  3. <div class="box">
  4. <div class="list">
  5. <ul>
  6. <li
  7. v-for="(item, index) in cList"
  8. :key="index"
  9. @click="play(item.uuid)"
  10. >
  11. {{ item.name }}
  12. </li>
  13. </ul>
  14. </div>
  15. <video
  16. id="test"
  17. crossorigin="anonymous"
  18. autoplay
  19. playsinline
  20. muted
  21. controls
  22. />
  23. </div>
  24. <div class="contrl">
  25. <n-button @click="contrl(8)">
  26. </n-button>
  27. <n-button @click="contrl(2)">
  28. </n-button>
  29. <n-button @click="contrl(4)">
  30. </n-button>
  31. <n-button @click="contrl(6)">
  32. </n-button>
  33. <n-button @click="contrl(10)">
  34. 放大
  35. </n-button>
  36. <n-button @click="contrl(11)">
  37. 缩小
  38. </n-button>
  39. </div>
  40. </div>
  41. </template>
  42. <script setup lang="ts">
  43. import axios from '@/utils/axios'
  44. import { onMounted, ref } from 'vue'
  45. import WebRtcPlayer from '@/utils/SRSWebRtcPlayer'
  46. const TOKEN = '833cd2ff8851509d0c4b2cab0dbdb74d'
  47. const cList = ref()
  48. const CUUID = ref('')
  49. let play1 = null as any
  50. // 获取摄像头播放地址
  51. const getCamer = async () => {
  52. const { data } = await axios.post('http://20.20.20.9:8089', {
  53. code: 'categorycamera.list',
  54. token: TOKEN,
  55. body: {}
  56. })
  57. // 35可控
  58. cList.value = data.filter((el: { name: string }) => (el.name.includes('35')))
  59. console.log('摄像头列表', cList.value)
  60. }
  61. // 播放
  62. const play = async (uuid:string) => {
  63. if (play1) play1.close()
  64. CUUID.value = uuid
  65. play1 = new WebRtcPlayer({
  66. HOST: '20.20.20.9',
  67. TOKEN,
  68. UUID: uuid,
  69. PROFILE: 0,
  70. PORT: 1985,
  71. DOM: document.getElementById('test') as any
  72. })
  73. }
  74. /**
  75. * 云台控制
  76. * @param command 指令:数字键盘1-9去掉5,10:焦距放大,11:焦距缩小 12:亮度,13:色彩饱和度,14:对比度,15:清晰度
  77. * @param number [云台速度|焦距参数|色彩饱和度]等值 亮度值 0-100
  78. */
  79. const contrl = (command: number, number = 1) => {
  80. if (!play1) return
  81. play1.contrl('http://20.20.20.9:8089', CUUID.value, TOKEN, command, number)
  82. }
  83. // 获取目录
  84. // const proList = async () => {
  85. // const { data } = await axios.post('http://20.20.20.9:8089', {
  86. // code: 'category.list',
  87. // token: '833cd2ff8851509d0c4b2cab0dbdb74d',
  88. // body: {}
  89. // })
  90. // // 零食取一个测试
  91. // console.log(666, data)
  92. // }
  93. onMounted(() => {
  94. getCamer()
  95. })
  96. </script>
  97. <style lang="less" scoped>
  98. .videoBox {
  99. .box {
  100. display: flex;
  101. justify-content: center;
  102. .list {
  103. width: 150px;
  104. color: white;
  105. li {
  106. padding: 10px;
  107. &:hover {
  108. color: aqua;
  109. cursor: pointer;
  110. }
  111. }
  112. }
  113. video {
  114. width: 800px;
  115. height: 500px;
  116. background: none;
  117. object-fit: fill;
  118. font-size: 0;
  119. }
  120. }
  121. .contrl {
  122. margin-top: 10px;
  123. text-align: center;
  124. button {
  125. margin-left: 10px;
  126. }
  127. }
  128. }
  129. </style>