Video.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <div style="display: flex">
  3. <div class="item-video">
  4. <div class="video-box">
  5. <video
  6. ref="videoPlayer"
  7. :preload="preload"
  8. :poster="videoImg"
  9. :height="height"
  10. :width="width"
  11. align="center"
  12. :controls="controls"
  13. :autoplay="autoplay"
  14. class="video video-js vjs-default-skin vjs-big-play-centered"
  15. >
  16. </video>
  17. <div class="line"></div>
  18. <div class="text">
  19. <span class="items" v-for="(item, index) in typeList" :key="index" @click="Onchange(item)">{{
  20. item.lable
  21. }}</span>
  22. </div>
  23. </div>
  24. <div></div>
  25. <div></div>
  26. </div>
  27. <div></div>
  28. </div>
  29. </template>
  30. <script>
  31. import { getCarVideo } from '@/api/iot'
  32. import axios from 'axios'
  33. export default {
  34. data() {
  35. return {
  36. videoSrc: null,
  37. videoImg: '',
  38. playStatus: '',
  39. muteStatus: '',
  40. isMute: true,
  41. isPlay: false,
  42. width: '420', // 设置视频播放器的显示宽度(以像素为单位)
  43. height: '500', // 设置视频播放器的显示高度(以像素为单位)
  44. preload: 'auto', // 建议浏览器是否应在<video>加载元素后立即开始下载视频数据。
  45. controls: true, // 确定播放器是否具有用户可以与之交互的控件。没有控件,启动视频播放的唯一方法是使用autoplay属性或通过Player API。
  46. autoplay: '',
  47. typeList: [
  48. {
  49. id: 2,
  50. lable: '大巴摄像头',
  51. },
  52. {
  53. id: 3,
  54. lable: '驾驶员',
  55. },
  56. {
  57. id: 4,
  58. lable: '车内',
  59. },
  60. {
  61. id: 5,
  62. lable: '车前方',
  63. },
  64. {
  65. id: 6,
  66. lable: '车后方',
  67. },
  68. {
  69. id: 7,
  70. lable: '车左侧',
  71. },
  72. {
  73. id: 8,
  74. lable: '车右侧',
  75. },
  76. ],
  77. carId: 2,
  78. }
  79. },
  80. methods: {
  81. FunVdieoList() {
  82. const params = {
  83. vehicleId: '1656135934669',
  84. channel: this.carId,
  85. }
  86. getCarVideo(params).then((res) => {
  87. this.videoSrc = `blob:${res.msg.replace('http://183.66.101.92:1078/video', '/video')}`
  88. var flvPlayer = flvjs.createPlayer({
  89. type: 'flv',
  90. url: res.msg
  91. });
  92. //url: xxx 为后台请求数据的视频
  93. flvPlayer.attachMediaElement(this.$refs.videoPlayer);
  94. flvPlayer.load();
  95. flvPlayer.play();
  96. })
  97. },
  98. Onchange(val) {
  99. this.carId = val.id
  100. },
  101. },
  102. created() {
  103. this.FunVdieoList()
  104. },
  105. mounted() {
  106. },
  107. }
  108. </script>
  109. <style lang="less" scoped>
  110. .item-video {
  111. display: flex;
  112. flex-direction: column;
  113. align-items: center;
  114. justify-content: center;
  115. .line {
  116. width: 330px;
  117. height: 1px;
  118. display: inline-block;
  119. border-bottom: 1px dashed #000;
  120. }
  121. .text {
  122. display: flex;
  123. flex-wrap: wrap;
  124. .items {
  125. width: 80px;
  126. text-align: center;
  127. margin-top: 5px;
  128. border-right: 1px solid #f1f1f1;
  129. cursor: pointer;
  130. }
  131. }
  132. }
  133. .video-box {
  134. width: 350px;
  135. height: 350px;
  136. background: #fff;
  137. margin-top: 20px;
  138. padding: 8px 9px;
  139. .video {
  140. width: 330px;
  141. height: 260px;
  142. object-fit: fill;
  143. }
  144. }
  145. </style>