video.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <script setup lang="ts">
  2. import { onMounted } from "vue";
  3. import { deviceDetection } from "@pureadmin/utils";
  4. import { useRenderIcon } from "@/components/ReIcon/src/hooks";
  5. import VideoPlay from "~icons/ep/video-play";
  6. import Player from "xgplayer";
  7. import "xgplayer/dist/index.min.css";
  8. defineOptions({
  9. name: "VideoPage"
  10. });
  11. onMounted(() => {
  12. new Player({
  13. id: "mse",
  14. lang: "zh",
  15. // 默认静音
  16. volume: 0,
  17. autoplay: false,
  18. screenShot: true,
  19. videoAttributes: {
  20. crossOrigin: "anonymous"
  21. },
  22. url: "//lf3-static.bytednsdoc.com/obj/eden-cn/nupenuvpxnuvo/xgplayer_doc/xgplayer-demo.mp4",
  23. poster:
  24. "//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/byted-player-videos/1.0.0/poster.jpg",
  25. fluid: deviceDetection(),
  26. //传入倍速可选数组
  27. playbackRate: [0.5, 0.75, 1, 1.5, 2]
  28. });
  29. });
  30. </script>
  31. <template>
  32. <el-card shadow="never">
  33. <template #header>
  34. <div class="card-header">
  35. <span class="font-medium">
  36. 视频组件,采用开源的
  37. <el-link
  38. href="https://v3.h5player.bytedance.com/"
  39. target="_blank"
  40. :icon="useRenderIcon(VideoPlay)"
  41. style="margin: 0 4px 5px; font-size: 16px"
  42. >
  43. 西瓜播放器
  44. </el-link>
  45. </span>
  46. </div>
  47. <el-link
  48. class="mt-2"
  49. href="https://github.com/pure-admin/vue-pure-admin/blob/main/src/views/able/video.vue"
  50. target="_blank"
  51. >
  52. 代码位置 src/views/able/video.vue
  53. </el-link>
  54. </template>
  55. <div id="mse" />
  56. </el-card>
  57. </template>
  58. <style scoped>
  59. #mse {
  60. flex: auto;
  61. }
  62. </style>