cloudCoachPlayer.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div
  3. class="cloudCoachPlayer"
  4. :style="{
  5. width: width * scale + 'px',
  6. height: height * scale + 'px',
  7. transform: `scale(${1 / scale})`
  8. }"
  9. >
  10. <div v-if="loading" class="loading-overlay">
  11. <div class="loadingBox">
  12. <div class="loadingItem"></div>
  13. <div class="loadingItem"></div>
  14. <div class="loadingItem"></div>
  15. <div class="loadingItem"></div>
  16. </div>
  17. </div>
  18. <iframe class="musicIframe" frameborder="0" :src="url" @load="handleIframeLoad"></iframe>
  19. </div>
  20. </template>
  21. <script setup lang="ts">
  22. import { ref, computed } from "vue"
  23. import { getToken } from "@/libs/auth"
  24. import { YJL_URL_API } from "@/config/index"
  25. import queryParams from "@/queryParams"
  26. const props = withDefaults(
  27. defineProps<{
  28. width: number
  29. height: number
  30. id: string
  31. scale?: number
  32. }>(),
  33. {
  34. scale: 1
  35. }
  36. )
  37. const url = computed(() => {
  38. return `${YJL_URL_API}?v=${Date.now()}&showGuide=true&showWebGuide=false&platform=pc&imagePos=right&zoom=0.8&modelType=practise&instrumentId=${queryParams.instrumentId}&iscurseplay=play&id=${props.id}&Authorization=${getToken()}`
  39. })
  40. // 先关闭这个功能
  41. const loading = ref(true)
  42. function handleIframeLoad() {
  43. loading.value = false
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. .cloudCoachPlayer {
  48. width: 100%;
  49. height: 100%;
  50. position: relative;
  51. overflow: hidden;
  52. user-select: none;
  53. line-height: 1;
  54. transform-origin: 0 0;
  55. background-color: #213793;
  56. .musicIframe {
  57. width: 100%;
  58. height: 100%;
  59. }
  60. .loading-overlay {
  61. position: absolute;
  62. top: 0;
  63. left: 0;
  64. width: 100%;
  65. height: 100%;
  66. display: flex;
  67. justify-content: center;
  68. align-items: center;
  69. flex-direction: column;
  70. z-index: 10;
  71. color: #fff;
  72. background: url("../cloudCoachList/imgs/musicBg.png");
  73. background-size: cover;
  74. .loadingBox {
  75. width: 30px;
  76. height: 30px;
  77. display: flex;
  78. justify-content: space-between;
  79. flex-wrap: wrap;
  80. align-content: space-between;
  81. animation: rotate 1.5s linear infinite;
  82. .loadingItem {
  83. width: 12px;
  84. height: 12px;
  85. border-radius: 50%;
  86. background: #20bdff;
  87. opacity: 0.5;
  88. &:nth-child(2) {
  89. opacity: 1;
  90. }
  91. }
  92. }
  93. @keyframes rotate {
  94. from {
  95. transform: rotate(0deg);
  96. }
  97. to {
  98. transform: rotate(360deg);
  99. }
  100. }
  101. }
  102. }
  103. </style>