index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div class="player">
  3. <vue-video-player
  4. ref="videoPlayer"
  5. :playsinline="true"
  6. :options="playerOptions"
  7. class="video-player vjs-custom-skin"
  8. />
  9. </div>
  10. </template>
  11. <script>
  12. import { videoPlayer } from 'vue-video-player'
  13. import 'video.js/dist/video-js.css'
  14. import 'vue-video-player/src/custom-theme.css'
  15. export default {
  16. name: 'ibps-file-video',
  17. components: {
  18. 'vue-video-player': videoPlayer
  19. },
  20. props: {
  21. url: {
  22. type: String
  23. },
  24. ext: {
  25. type: String,
  26. default: 'mp4'
  27. }
  28. },
  29. data() {
  30. return {
  31. playerOptions: {
  32. autoplay: false, // 如果true,浏览器准备好时开始回放。
  33. muted: false, // 默认情况下将会消除任何音频。
  34. loop: false, // 导致视频一结束就重新开始。
  35. preload: 'auto', // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
  36. language: 'zh-CN', // 国际化
  37. aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  38. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  39. sources: [{
  40. type: 'video/' + this.ext,
  41. src: this.url
  42. }],
  43. width: document.documentElement.clientWidth,
  44. notSupportedMessage: '此视频暂无法播放,请稍后再试' // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
  45. }
  46. }
  47. },
  48. computed: {
  49. player() {
  50. return this.$refs.videoPlayer.player
  51. }
  52. }
  53. }
  54. </script>