VideoNowPagebak.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div>
  3. <el-dialog v-dialogDrag
  4. :before-close="handleClose"
  5. :visible.sync="dialogVisible"
  6. append-to-body class="statistic_base"
  7. title="实时监控"
  8. width="60%"
  9. >
  10. <video-player ref="vueMiniPlayer" :options="playerOptions" class="video-player vjs-custom-skin"></video-player>
  11. <span slot="footer" class="dialog-footer">
  12. <!-- <el-button :loading="loading" @click="dialogVisible=false">关闭</el-button> -->
  13. </span>
  14. </el-dialog>
  15. </div>
  16. </template>
  17. <script>
  18. import { videoPlayer } from 'vue-video-player'
  19. import hls from 'videojs-contrib-hls'
  20. // 引入样式
  21. import 'video.js/dist/video-js.css'
  22. import 'vue-video-player/src/custom-theme.css'
  23. import '../../assets/drag'
  24. export default {
  25. name:'videoNowPage',
  26. components: {
  27. videoPlayer,
  28. hls
  29. },
  30. data() {
  31. return {
  32. loading: false,
  33. dialogVisible: false,
  34. playerOptions: {
  35. playbackRates: [1.0], // 可选的播放速度
  36. autoplay: true, // 如果为true,浏览器准备好时开始回放。
  37. muted: false, // 默认情况下将会消除任何音频。
  38. loop: false, // 是否视频一结束就重新开始。
  39. preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
  40. language: "zh-CN",
  41. aspectRatio: "16:9", // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  42. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  43. sources: [
  44. {
  45. src: '',
  46. type: "application/x-mpegURL", // 类型
  47. // src: 'https://media.w3.org/2010/05/sintel/trailer.mp4',
  48. // type: "video/mp4", // 类型
  49. // type: "rtmp/mp4"
  50. },
  51. ],
  52. poster: "", // 封面地址
  53. notSupportedMessage: "此视频暂无法播放,请稍后再试", // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
  54. controlBar: {
  55. timeDivider: true, // 当前时间和持续时间的分隔符
  56. durationDisplay: true, // 显示持续时间
  57. remainingTimeDisplay: true, // 是否显示剩余时间功能
  58. fullscreenToggle: true, // 是否显示全屏按钮
  59. },
  60. },
  61. }
  62. },
  63. watch: {
  64. dialogVisible(newValue, oldValue) {
  65. if(!newValue){
  66. this.$nextTick(() => {
  67. this.$refs.vueMiniPlayer.player.pause();
  68. });
  69. // this.$refs.vueMiniPlayer.player.pause()
  70. }else{
  71. // this.$refs.vueMiniPlayer.player.play()
  72. }
  73. }
  74. },
  75. methods: {
  76. stop(){
  77. //console.log(this.$refs.vueMiniPlayer)
  78. this.$refs.vueMiniPlayer.player.pause();//暂停
  79. },
  80. handleOk() {
  81. this.loading = true
  82. setTimeout(() => {
  83. this.loading = false
  84. }, 3000)
  85. this.dialogVisible = false
  86. },
  87. setVisible(url) {
  88. // this.playerOptions.sources[0].src = 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8';
  89. // this.dialogVisible = true
  90. // this.$refs.vueMiniPlayer.player.play()
  91. console.log("参数——:", url);
  92. this.playerOptions.sources[0].src = url;
  93. this.dialogVisible = true
  94. //console.log("视频组件——:",this.$refs , this.$refs["vueMiniPlayer"])
  95. this.$refs.vueMiniPlayer.player.play()
  96. },
  97. handleClose(done) {
  98. this.dialogVisible=false
  99. }
  100. }
  101. }
  102. </script>
  103. <style>
  104. .span_red {
  105. color: red;
  106. }
  107. </style>