camera.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <div
  3. :id="cameraBoxId"
  4. class="camera_box"
  5. v-show="
  6. isLeader &&
  7. isRTCJoined &&
  8. isPanoramaMode &&
  9. hosterhasVideo &&
  10. globalVideoEnable &&
  11. !muteVideoLeader
  12. "
  13. >
  14. <!-- -->
  15. <span class="micBox">
  16. <i class="speak_mic" v-if="!roomLeader?.IsMuted"></i>
  17. <i class="speak_mic_off" v-else></i>
  18. </span>
  19. </div>
  20. <!-- :id="cameraRemoteBoxId" -->
  21. <!-- muteVideoLeader:{{ muteVideoLeader }} -->
  22. <div
  23. id="cameraRemoteBox"
  24. class="camera_box"
  25. v-show="
  26. !isLeader &&
  27. isRTCJoined &&
  28. roomLeader &&
  29. isPanoramaMode &&
  30. !muteVideoLeader &&
  31. globalVideoEnable
  32. "
  33. >
  34. <span class="micBox">
  35. <i class="speak_mic" v-if="!roomLeader?.IsMuted"></i>
  36. <i class="speak_mic_off" v-else></i>
  37. </span>
  38. </div>
  39. </template>
  40. <script lang="ts" setup>
  41. import { computed, onMounted } from 'vue';
  42. import { useAppStore } from '/@/store/modules/app';
  43. import { useRtcSdk } from '/@/hooks/useTRTC';
  44. import { useRtcStore } from '/@/store/modules/rtc';
  45. const rtcStore = useRtcStore();
  46. const appStore = useAppStore();
  47. const isRTCJoined = computed(() => rtcStore.isRTCJoined);
  48. const isLeader = computed(() => rtcStore.isLeader);
  49. const roomLeader = computed(() => rtcStore.getRoomLeader());
  50. const cameraBoxId = computed(() => 'camera_box_' + rtcStore.userId);
  51. // const cameraRemoteBoxId = computed(() => 'camera_remote_box_' + rtcStore.userId);
  52. const isPanoramaMode = computed(() => appStore.mode === 'panorama');
  53. const { muteVideoLeader, globalVideoEnable } = useRtcSdk();
  54. const hosterhasVideo = computed(() => rtcStore.isHasCamera);
  55. // const remoteStreams = computed(() => rtcStore.remoteStreams);
  56. // console.log('hosterhasVideo', unref(hosterhasVideo));
  57. onMounted(() => {});
  58. </script>
  59. <style lang="scss">
  60. .camera_box {
  61. width: 1.94rem;
  62. height: 1.94rem;
  63. position: fixed;
  64. top: 1.59rem;
  65. left: 0.53rem;
  66. overflow: hidden;
  67. z-index: 10000;
  68. border-radius: 50%;
  69. video {
  70. display: none;
  71. }
  72. video:last-child {
  73. display: block;
  74. }
  75. > div {
  76. background-color: transparent !important;
  77. position: absolute !important;
  78. top: 0;
  79. left: 0;
  80. right: 0;
  81. bottom: 0;
  82. z-index: 10;
  83. }
  84. .micBox {
  85. width: 100%;
  86. height: 0.44rem;
  87. background: rgba(0, 0, 0, 0.3);
  88. position: absolute;
  89. left: 0;
  90. bottom: 0 !important;
  91. top: unset;
  92. z-index: 100;
  93. display: flex;
  94. align-items: center;
  95. justify-content: center;
  96. .speak_mic {
  97. display: block;
  98. background-size: 720px auto;
  99. width: 12px;
  100. height: 12px;
  101. background-image: url(/@/assets/images/rtcLive/speed.png);
  102. // width: 0.69rem;
  103. // height: 0.69rem;
  104. animation: myAnimation 3s steps(59) infinite;
  105. }
  106. .speak_mic_off {
  107. display: block;
  108. background-size: center center;
  109. background-size: contain;
  110. width: 12px;
  111. height: 12px;
  112. background-image: url(/@/assets/images/rtcLive/scene_mic_off@2x.png);
  113. }
  114. }
  115. }
  116. @keyframes myAnimation {
  117. 0% {
  118. background-position: 0px 0px;
  119. }
  120. 100% {
  121. background-position: -708px 0px;
  122. }
  123. }
  124. </style>