videoDetail.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view>
  3. <view class="timeBox flex justify-between align-center padding-lr-sm">
  4. <view class="time">火点侦测摄像机</view>
  5. </view>
  6. <view class="basic-info">
  7. <view class="info-tit margin-left-xs">
  8. <text class="cuIcon-titles margin-right-xs"></text>
  9. 基本信息
  10. </view>
  11. <view class="info-content">
  12. <view class="info-one-info ">
  13. <text>设备名称:</text>
  14. <text>{{videoDetail.deviceName}}</text>
  15. </view>
  16. <view>
  17. <text>设备编号:</text>
  18. <text>{{videoDetail.deviceCode}}</text>
  19. </view>
  20. <view>
  21. <text style="width:auto!important">物联网卡号:</text>
  22. <text>{{videoDetail.sim}}</text>
  23. </view>
  24. <view>
  25. <text>安装位置:</text>
  26. <text>{{videoDetail.deviceInstallationPosition}}</text>
  27. </view>
  28. <view>
  29. <text>添加时间:</text>
  30. <text>{{videoDetail.addTime}}</text>
  31. </view>
  32. <view>
  33. <text>设备地址:</text>
  34. <text>{{videoDetail.address}}</text>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 处理状态start -->
  39. <view class="processStatus">
  40. <view class="info-tit margin-left-xs">
  41. <text class="cuIcon-titles margin-right-xs"></text>
  42. 视频
  43. </view>
  44. <view class="padding-lr padding-bottom-lg video-js" ref="video"
  45. style="width: 95%; margin: 0 auto; height: 250px;">
  46. <!-- <video ref="myVideo" :src="videoUrl" style="width:100%" loop="loop" autoplay="autoplay"></video> -->
  47. <!-- <view class="video-js" ref="video" style="text-align:center;width:100%;height:400rpx">
  48. </view> -->
  49. <!-- <video id="example_video_1" style="width:100%" class="video-js vjs-default-skin" controls preload="none"
  50. width="640" height="264" poster="http://vjs.zencdn.net/v/oceans.png">
  51. <source :src="videoUrl" type="application/x-mpegURL">
  52. </video> -->
  53. </view>
  54. </view>
  55. <!-- 处理状态end -->
  56. </view>
  57. </template>
  58. <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
  59. <script>
  60. import Videojs from 'video.js'
  61. import 'video.js/dist/video-js.min.css'
  62. export default {
  63. data() {
  64. return {
  65. videoDetail: '',
  66. videoUrl: "",
  67. player: '',
  68. video: '',
  69. // VideoJs: null,
  70. }
  71. },
  72. onReady() {},
  73. onLoad: function(option) {
  74. console.log(111)
  75. console.log(option.deviceCode)
  76. this.companyCode = option.companyCode
  77. this.deviceType = option.deviceType
  78. // this.videoUrl = 'http://cctvalih5ca.v.myalicdn.com/live/cctv1_2/index.m3u8'
  79. // this.videoUrl = 'http://videocdn.didano.com/school765class0channelId2761namedingdangm/playlist.m3u8'
  80. // this.videoUrl = 'https://iot.usky.cn/hls/' + option.deviceCode + '.m3u8';
  81. this.videoUrl = 'http://47.103.74.123/hls/' + option.deviceCode + '.m3u8';
  82. console.log(this.videoUrl)
  83. this.getDeviceDetail({
  84. "companyCode": option.companyCode,
  85. "deviceType": option.deviceType,
  86. "deviceCode": option.deviceCode
  87. })
  88. },
  89. methods: {
  90. async getDeviceDetail(ming = {}) {
  91. let that = this;
  92. const res = await this.$myRequest({
  93. url: 'OperationMonitoring/getMonitoringScreen',
  94. data: ming
  95. })
  96. console.log(res.data.data[0])
  97. this.videoDetail = res.data.data[0]
  98. setTimeout(() => {
  99. let video = document.createElement('video');
  100. video.id = 'video';
  101. video.style = 'width: 100%; height: 100%;';
  102. video.controls = true;
  103. video.preload = "auto"
  104. // video.autoplay = 'autoplay'
  105. video.setAttribute('playsinline', true) //IOS微信浏览器支持小窗内播放
  106. video.setAttribute('webkit-playsinline', true);
  107. video.setAttribute('custom-cache', false)//禁用第三方缓存加载
  108. //这个bai属性是ios 10中设置可以让视频在小du窗内播放,也就是不是全zhi屏播放的video标签的一个属性
  109. // video.setAttribute('x5-video-player-type', 'h5') //安卓 声明启用同层H5播放器 可以在video上面加东西
  110. let source = document.createElement('source');
  111. // source.src = 'http://cctvalih5ca.v.myalicdn.com/live/cctv1_2/index.m3u8'
  112. // source.src = 'http' + this.videoUrl.split('https')[1]
  113. source.src = this.videoUrl
  114. // source.src = './12/C60389215.m3u8'
  115. // console.log(source.src)
  116. source.type = 'application/x-mpegURL';
  117. video.appendChild(source);
  118. this.$refs.video.$el.appendChild(video);
  119. this.player = Videojs('video', {
  120. bigPlayButton: true, //是否显示播放按钮
  121. poster: '', // 视频封面图地址
  122. title: '4564564',
  123. playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
  124. autoDisable: true,
  125. preload: 'none', //auto - 当页面加载后载入整个视频 meta - 当页面加载后只载入元数据 none - 当页面加载后不载入视频
  126. language: 'zh-CN',
  127. fluid: true, // 自适应宽高
  128. muted: false, // 是否静音
  129. aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  130. controls: true, //是否拥有控制条 【默认true】,如果设为false ,那么只能通过api进行控制了。也就是说界面上不会出现任何控制按钮
  131. autoplay: false, //如果true,浏览器准备好时开始回放。 autoplay: "muted", // //自动播放属性,muted:静音播放
  132. loop: true, // 导致视频一结束就重新开始。 视频播放结束后,是否循环播放
  133. screenshot: true,
  134. controlBar: {
  135. volumePanel: { //声音样式
  136. inline: false // 不使用水平方式
  137. },
  138. timeDivider: true, // 时间分割线
  139. durationDisplay: true, // 总时间
  140. progressControl: true, // 进度条
  141. remainingTimeDisplay: true, //当前以播放时间
  142. fullscreenToggle: true, //全屏按钮
  143. pictureInPictureToggle: true, //画中画
  144. }
  145. }, function() {
  146. // this.play()
  147. // 播放 this.play()
  148. // 停止 – video没有stop方法,可以用pause 暂停获得同样的效果
  149. // 暂停 this.pause()
  150. // 销毁 this.dispose()
  151. // 监听 this.on(‘click‘,fn)
  152. // 触发事件this.trigger(‘dispose‘)
  153. this.on('error', function(err) { //请求数据时遇到错误
  154. console.log("请求数据时遇到错误", err)
  155. });
  156. this.on('stalled', function(stalled) { //网速失速
  157. console.log("网速失速", stalled)
  158. });
  159. this.on('play', function() { //开始播放
  160. console.log("开始播放")
  161. });
  162. this.on('pause', function() { //暂停
  163. console.log("暂停")
  164. });
  165. // this.on('timeupdate', function(timeupdate) {
  166. // console.log(timeupdate)
  167. // })
  168. });
  169. }, 1000)
  170. },
  171. }
  172. }
  173. </script>
  174. <style lang="scss">
  175. /deep/.vjs-big-play-button {
  176. position: absolute;
  177. left: 0;
  178. right: 0;
  179. top: 90px;
  180. margin: 0 auto;
  181. }
  182. </style>