index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div class="video-player-container" v-if="visible">
  3. <div class="video-player-title">
  4. <span class="title-text">{{ title }}</span>
  5. <img src="@/assets/image/common/close.png" style="cursor: pointer" alt="" @click="openTsModal" />
  6. </div>
  7. <Artplayer :option="option" :style="style" @getInstance="getInstance" />
  8. <el-dialog title="提示" :visible.sync="tsModalVisible" width="60%">
  9. <span>是否中断当前巡查点监控,进行下一个巡查点视频播放?</span>
  10. <span slot="footer" class="dialog-footer">
  11. <el-button type="primary" @click="closeVideoDialog">中断当前视频</el-button>
  12. <el-button @click="toNext">播放下一个视频</el-button>
  13. <el-button @click="tsModalVisible = false">取 消</el-button>
  14. </span>
  15. </el-dialog>
  16. </div>
  17. </template>
  18. <script>
  19. import Artplayer from '@/components/video-player/video-player.vue'
  20. import flvjs from 'flv.js'
  21. export default {
  22. name: 'WaterStationPopup',
  23. data() {
  24. return {
  25. visible: false,
  26. title: '巡查点',
  27. option: {
  28. url: 'ws://10.157.200.5:9381/live/43010000831327000018_0_0_39f33131b0ac4611a4e7da4d692a1195.flv',
  29. isLive: true, //使用直播模式,会隐藏进度条和播放时间
  30. autoplay: true,
  31. muted: true, //是否静音
  32. type: 'flv',
  33. autoSize: true,
  34. customType: {
  35. flv: (video, url, art) => {
  36. if (flvjs.isSupported()) {
  37. if (art.flv) art.flv.destroy()
  38. const flv = flvjs.createPlayer({ type: 'flv', url })
  39. flv.attachMediaElement(video)
  40. flv.load()
  41. art.flv = flv
  42. art.on('destroy', () => flv.destroy())
  43. }
  44. }
  45. }
  46. },
  47. tsModalVisible: false,
  48. style: {
  49. width: '600px',
  50. height: '350px'
  51. }
  52. }
  53. },
  54. components: {
  55. Artplayer
  56. },
  57. mounted() {
  58. this.$globalEventBus.$on('clickVideoPlay', (data) => {
  59. console.info(data)
  60. this.visible = data.visible
  61. this.tsModalVisible = false
  62. this.title = data.point?data.point.devName:''
  63. })
  64. },
  65. destroyed() {
  66. this.$globalEventBus.$off('clickVideoPlay')
  67. },
  68. methods: {
  69. getInstance(art) {
  70. console.info(art)
  71. },
  72. openTsModal() {
  73. this.tsModalVisible = true
  74. },
  75. toNext() {},
  76. closeVideoDialog() {
  77. this.visible = false
  78. }
  79. }
  80. }
  81. </script>
  82. <style scoped lang="scss">
  83. .video-player-container {
  84. position: absolute;
  85. top: 50%;
  86. left: 50%;
  87. transform: translate(-50%, -80%);
  88. width: 600px;
  89. z-index: 9999;
  90. .video-player-title {
  91. background: url('@/assets/image/common/popup_title_bg.png') no-repeat;
  92. background-size: 100% 100%;
  93. height: px-to-rem(39);
  94. display: flex;
  95. justify-content: space-between;
  96. align-items: center;
  97. padding: 0 px-to-rem(20);
  98. font-size: px-to-rem(16);
  99. color: #fff;
  100. .title-text {
  101. font-weight: bold;
  102. margin-left: px-to-rem(20);
  103. }
  104. }
  105. }
  106. </style>