ScreenVideoElement.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div
  3. class="base-element-video screen-element-video"
  4. :style="{
  5. top: elementInfo.top + 'px',
  6. left: elementInfo.left + 'px',
  7. width: elementInfo.width + 'px',
  8. height: elementInfo.height + 'px'
  9. }"
  10. >
  11. <div class="rotate-wrapper" :style="{ transform: `rotate(${elementInfo.rotate}deg)` }">
  12. <div class="element-content">
  13. <VideoPlayer
  14. v-if="inCurrentSlide"
  15. :width="elementInfo.width"
  16. :height="elementInfo.height"
  17. :src="elementInfo.src"
  18. :poster="elementInfo.poster"
  19. :autoplay="elementInfo.autoplay"
  20. :scale="scale"
  21. :needWaitAnimation="needWaitAnimation"
  22. />
  23. </div>
  24. </div>
  25. </div>
  26. </template>
  27. <script lang="ts" setup>
  28. import { computed, inject, ref } from "vue"
  29. import { storeToRefs } from "pinia"
  30. import { useSlidesStore } from "@/store"
  31. import type { PPTVideoElement } from "@/types/slides"
  32. import { injectKeySlideId, injectKeySlideScale } from "@/types/injectKey"
  33. import VideoPlayer from "./VideoPlayer/index.vue"
  34. defineProps<{
  35. elementInfo: PPTVideoElement
  36. needWaitAnimation: boolean
  37. }>()
  38. const { currentSlide } = storeToRefs(useSlidesStore())
  39. const scale = inject(injectKeySlideScale) || ref(1)
  40. const slideId = inject(injectKeySlideId) || ref("")
  41. const inCurrentSlide = computed(() => currentSlide.value.id === slideId.value)
  42. </script>
  43. <style lang="scss" scoped>
  44. .screen-element-video {
  45. position: absolute;
  46. }
  47. .rotate-wrapper {
  48. width: 100%;
  49. height: 100%;
  50. }
  51. .element-content {
  52. width: 100%;
  53. height: 100%;
  54. }
  55. </style>