index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <div class="app-container">
  3. {{areaName}}<br/>
  4. <el-button type="text" @click="handleDevClick('设备1')">设备1</el-button>
  5. <el-button type="text" @click="handleDevClick('设备2')">设备2</el-button>
  6. <el-button type="text" @click="handleDevClick('设备3')">设备3</el-button>
  7. <el-dialog
  8. :title="dialogTitle"
  9. :visible.sync="dialogVisible"
  10. width="80%">
  11. <div class="video-player-container">
  12. <video-player
  13. class="video-player"
  14. ref="videoPlayer"
  15. :playsinline="true"
  16. :options="playerOptions"
  17. style="width: 100%;"
  18. ></video-player>
  19. </div>
  20. </el-dialog>
  21. </div>
  22. </template>
  23. <script>
  24. import { getDevVideoByAreaAndDev } from "@/api/aerial/devVideo";
  25. import { videoPlayer } from "vue-video-player";
  26. export default {
  27. name: "",
  28. components: {videoPlayer},
  29. props: {},
  30. data() {
  31. return {
  32. areaName: '',
  33. dialogVisible: false,
  34. dialogTitle: '',
  35. playerOptions: {
  36. playbackRates: [0.5, 1.0, 1.5, 2.0],
  37. autoplay: true,
  38. muted: false,
  39. loop: true,
  40. preload: "auto",
  41. language: "zh-CN",
  42. aspectRatio: "16:9",
  43. fluid: true,
  44. sources: [
  45. {
  46. type: "video/mp4",
  47. // src: "http://www.html5videoplayer.net/videos/madagascar3.mp4",
  48. src: '',
  49. },
  50. ],
  51. poster: "", // 封面地址
  52. width: document.documentElement.clientWidth,
  53. notSupportedMessage: "加载中......", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
  54. controlBar: {
  55. timeDivider: true, // 当前时间和持续时间的分隔符
  56. durationDisplay: true, // 显示持续时间
  57. remainingTimeDisplay: true, // 是否显示剩余时间功能
  58. fullscreenToggle: true, // 是否显示全屏按钮
  59. },
  60. },
  61. }
  62. },
  63. created() {
  64. this.areaName = this.$route.query.areaName;
  65. },
  66. methods: {
  67. handleDevClick(devName) {
  68. this.playerOptions.sources = [
  69. {
  70. type: "video/mp4",
  71. src: '',
  72. },
  73. ];
  74. this.playerOptions.notSupportedMessage = '加载中......';
  75. getDevVideoByAreaAndDev({
  76. "areaName": this.areaName,
  77. "devName": devName,
  78. }).then(response => {
  79. if (response.data != null && response.data != "") {
  80. this.playerOptions.sources = [
  81. {
  82. type: "video/mp4",
  83. src: 'http://localhost:8090'+ response.data.fileUrl,
  84. },
  85. ];
  86. } else {
  87. this.playerOptions.notSupportedMessage = '视频未上传......';
  88. }
  89. this.dialogTitle = this.areaName + " - " + devName;
  90. this.dialogVisible = true;
  91. });
  92. },
  93. }
  94. }
  95. </script>
  96. <style scoped>
  97. /deep/.video-js .vjs-big-play-button {
  98. width: 88px !important;
  99. height: 88px !important;
  100. border-radius: 50% !important;
  101. border: 0;
  102. line-height: 88px;
  103. font-size: 56px;
  104. object-fit: cover;
  105. text-align: center;
  106. background-color: rgba(0, 0, 0, 0.5);
  107. display: none;
  108. }
  109. </style>