index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div class="video-player-container" v-if="visible">
  3. <Artplayer :option="option" :style="style" @getInstance="getInstance" />
  4. </div>
  5. </template>
  6. <script>
  7. import Artplayer from '@/components/video-player/video-player.vue'
  8. import flvjs from 'flv.js'
  9. export default {
  10. name: 'WaterStationPopup',
  11. data() {
  12. return {
  13. visible: false,
  14. title:'',
  15. option:{
  16. url:"ws://10.157.200.5:9381/live/43010000831327000018_0_0_39f33131b0ac4611a4e7da4d692a1195.flv",
  17. isLive:true,//使用直播模式,会隐藏进度条和播放时间
  18. autoplay:true,
  19. muted: true,//是否静音
  20. type:"flv",
  21. customType: {
  22. flv: (video, url, art) => {
  23. if (flvjs.isSupported()) {
  24. if (art.flv) art.flv.destroy()
  25. const flv = flvjs.createPlayer({ type: 'flv', url })
  26. flv.attachMediaElement(video)
  27. flv.load()
  28. art.flv = flv
  29. art.on('destroy', () => flv.destroy())
  30. }
  31. }
  32. }
  33. },
  34. style:{
  35. width: '600px',
  36. height: '400px',
  37. margin: '60px auto 0',
  38. }
  39. }
  40. },
  41. components:{
  42. Artplayer
  43. },
  44. mounted() {
  45. this.$globalEventBus.$on('clickVideoPlay', (data) => {
  46. this.visible = true
  47. this.title = '巡查点'
  48. })
  49. },
  50. destroyed() {
  51. this.$globalEventBus.$off('clickVideoPlay')
  52. },
  53. methods: {
  54. getInstance(art){
  55. console.info(art)
  56. }
  57. }
  58. }
  59. </script>
  60. <style scoped lang="scss">
  61. .video-player-container {
  62. position: absolute;
  63. top: 50%;
  64. left: 50%;
  65. transform: translate(-50%, -80%);
  66. width: px-to-rem(600);
  67. z-index: 9999;
  68. }
  69. </style>