checkVideo.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <el-dialog
  3. :title="dialogTitle"
  4. v-model="dialogVisible"
  5. width="600px"
  6. @close="closeDialog(0)"
  7. @open="open"
  8. >
  9. <!-- <div>{{ deviceCode }}</div> -->
  10. <!-- <div style="background: #000">
  11. <video
  12. id="myVideo"
  13. :src="videoUrl"
  14. style="width: 100%; height: 400px"
  15. poster
  16. loop="loop"
  17. autoplay="autoplay"
  18. ></video>
  19. </div> -->
  20. <video
  21. id="my-video"
  22. class="video-js vjs-default-skin"
  23. controls
  24. preload="auto"
  25. style="width: 100%; height: 400px"
  26. poster
  27. loop="loop"
  28. autoplay="autoplay"
  29. >
  30. <!-- <source
  31. src="http://cctvalih5ca.v.myalicdn.com/live/cctv1_2/index.m3u8"
  32. type="application/x-mpegURL"
  33. /> -->
  34. <source :src="videoUrl" type="application/x-mpegURL" />
  35. </video>
  36. </el-dialog>
  37. </template>
  38. <script>
  39. import { defineComponent, ref, watchEffect } from 'vue'
  40. import videojs from 'video.js'
  41. import 'videojs-contrib-hls'
  42. export default defineComponent({
  43. name: 'CheckVideo',
  44. emits: ['closeDialog'],
  45. props: {
  46. flag: Boolean,
  47. dialogTitle: String,
  48. itemInfo: Object,
  49. deviceCode: String,
  50. },
  51. setup(props, context) {
  52. context
  53. const dialogVisible = ref(false)
  54. const videoUrl = ref('')
  55. // open(): Dialog弹窗打开之前做的事
  56. const open = () => {
  57. window.setTimeout(function () {
  58. videojs(
  59. 'my-video',
  60. {
  61. bigPlayButton: false,
  62. textTrackDisplay: false,
  63. posterImage: true,
  64. errorDisplay: false,
  65. controlBar: true,
  66. },
  67. function () {
  68. // alert(1);
  69. console.log(this)
  70. this.play()
  71. }
  72. )
  73. }, 5000)
  74. // videoUrl.value = 'http://47.103.74.123/hls/'+props.deviceCode+'.m3u8';
  75. videoUrl.value =
  76. 'http://cctvalih5ca.v.myalicdn.com/live/cctv1_2/index.m3u8'
  77. }
  78. const options = []
  79. // 关闭弹框
  80. const closeDialog = () => {
  81. context.emit('closeDialog', false)
  82. dialogVisible.value = false
  83. }
  84. watchEffect((fn, options) => {
  85. fn, options
  86. dialogVisible.value = props.flag
  87. })
  88. return {
  89. closeDialog,
  90. dialogVisible,
  91. options,
  92. open,
  93. videoUrl,
  94. }
  95. },
  96. })
  97. </script>
  98. <style scoped lang="scss">
  99. .el-input,
  100. .el-select {
  101. width: 240px;
  102. }
  103. // label样式
  104. .el-form-item__label {
  105. width: 150px;
  106. }
  107. .el-form-item__content {
  108. margin-left: 150px;
  109. }
  110. </style>