videoForMod.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <!-- 视频组件外科 -->
  2. <template>
  3. <div class="videoForMod">
  4. <H5PlayerVideo v-if="videoData" :videoProps="videoData"></H5PlayerVideo>
  5. <fullH5PlayerVideo v-if="fullVideoType" :fullVideoProps="fullVideoProps"></fullH5PlayerVideo>
  6. </div>
  7. </template>
  8. <script>
  9. import { iotCameraGetPreviewURLs } from '@/api/index'
  10. import H5PlayerVideo from '@/components/H5PlayerVideo/H5PlayerVideo.vue'
  11. import fullH5PlayerVideo from '@/components/fullH5PlayerVideo/fullH5PlayerVideo.vue'
  12. export default {
  13. name: 'videoForMod',
  14. components: {
  15. H5PlayerVideo,
  16. fullH5PlayerVideo
  17. },
  18. props:{
  19. deviceNo:{},
  20. },
  21. data() {
  22. return {
  23. width:470,
  24. height:290,
  25. videoData:null,
  26. //全屏视频参数
  27. fullVideoProps:{},
  28. fullVideoType:false,
  29. }
  30. },
  31. created() {
  32. },
  33. mounted() {
  34. if(this.deviceNo){
  35. this.iotCameraGetPreviewURLs();
  36. }
  37. },
  38. methods: {
  39. async iotCameraGetPreviewURLs() {
  40. try {
  41. let obj = {
  42. streamType:1,
  43. cameraIndexCode:this.deviceNo,
  44. protocol: window.location.href.indexOf('https') !== -1 ? 'wss' : 'ws',
  45. }
  46. const response = await iotCameraGetPreviewURLs(obj);
  47. if(response.code == 200){
  48. this.$set(this, 'videoData', {
  49. width: this.width,
  50. height: this.height,
  51. url: response.data,
  52. })
  53. this.$forceUpdate();
  54. }
  55. } catch (error) {
  56. this.$message.error(error.message);
  57. // 不再向上抛出,错误被吞掉
  58. }
  59. },
  60. //全屏开启-关闭轮播
  61. stopTime(cameraIndexCode){
  62. this.$set(this,'fullVideoProps',{cameraIndexCode:cameraIndexCode});
  63. this.$set(this,'fullVideoType',true);
  64. },
  65. //全屏关闭-开启轮播
  66. outFullScreen(){
  67. let self = this;
  68. this.$set(this,'fullVideoType',false);
  69. this.$set(this,'fullVideoProps',{});
  70. },
  71. }
  72. }
  73. </script>
  74. <style scoped lang="scss">
  75. .videoForMod {
  76. display: inline-block;
  77. width:470px;
  78. height:290px;
  79. margin:0 0 0 5px;
  80. }
  81. </style>