video-play.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div class="dialog-video">
  3. <video
  4. v-if="isShow"
  5. id="videoEle"
  6. class="video-box"
  7. :src="videoData"
  8. controls
  9. autoplay
  10. />
  11. </div>
  12. </template>
  13. <script lang="ts" setup>
  14. import { ref } from '../../adapter-vue';
  15. import { TUIGlobal } from '@tencentcloud/universal-api';
  16. import { onLoad, onReady } from '@dcloudio/uni-app';
  17. const videoData = ref();
  18. const isShow = ref(false);
  19. const videoContext = ref();
  20. onLoad((option: any) => {
  21. const decodedUrl = decodeURIComponent(option?.videoUrl);
  22. videoData.value = decodedUrl;
  23. isShow.value = true;
  24. });
  25. onReady(() => {
  26. isShow.value = true;
  27. videoContext.value = TUIGlobal.createVideoContext('videoEle');
  28. });
  29. </script>
  30. <style lang="scss" scoped>
  31. .dialog-video {
  32. position: fixed;
  33. z-index: 999;
  34. width: 100vw;
  35. height: 100vh;
  36. background: rgba(#000, 0.6);
  37. top: 0;
  38. left: 0;
  39. right: 0;
  40. bottom: 0;
  41. display: flex;
  42. justify-content: center;
  43. align-items: center;
  44. .video-box {
  45. position: absolute;
  46. width: 100vw;
  47. height: 100vh;
  48. top: 0;
  49. left: 0;
  50. right: 0;
  51. bottom: 0;
  52. }
  53. }
  54. </style>