1v1.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <uni-shadow-root class="trtc-room-template-1v1-1v1"><template v-if="wxTemplateName === '1v1'">
  3. <view class="template-1v1">
  4. <view v-for="(item,index) in (streamList)" :key="item.streamID" v-if="item.src && (item.hasVideo || item.hasAudio)" :class="'view-container player-container '+(item.isVisible?'':'none')">
  5. <live-player class="player" :id="item.streamID" :data-userid="item.userID" :data-streamid="item.streamID" :data-streamtype="item.streamType" :src="item.src" mode="RTC" :autoplay="item.autoplay" :mute-audio="item.muteAudio" :mute-video="item.muteVideo" :orientation="item.orientation" :object-fit="item.objectFit" :background-mute="item.enableBackgroundMute" :min-cache="item.minCache" :max-cache="item.maxCache" :sound-mode="item.soundMode" :enable-recv-message="item.enableRecvMessage" :auto-pause-if-navigate="item.autoPauseIfNavigate" :auto-pause-if-open-native="item.autoPauseIfOpenNative" :debug="debug" @statechange="_$self.$parent[('_playerStateChange')]($event)" @fullscreenchange="_$self.$parent[('_playerFullscreenChange')]($event)" @netstatus="_$self.$parent[('_playerNetStatus')]($event)" @audiovolumenotify="_$self.$parent[('_playerAudioVolumeNotify')]($event)"></live-player>
  6. </view>
  7. <view :class="'view-container pusher-container '+(pusher.isVisible?'':'none')+' '+(streamList.length===0? 'fullscreen':'')">
  8. <live-pusher class="pusher" :url="pusher.url" :mode="pusher.mode" :autopush="pusher.autopush" :enable-camera="pusher.enableCamera" :enable-mic="pusher.enableMic" :muted="(!pusher.enableMic)" :enable-agc="pusher.enableAgc" :enable-ans="pusher.enableAns" :enable-ear-monitor="pusher.enableEarMonitor" :auto-focus="pusher.enableAutoFocus" :zoom="pusher.enableZoom" :min-bitrate="pusher.minBitrate" :max-bitrate="pusher.maxBitrate" :video-width="pusher.videoWidth" :video-height="pusher.videoHeight" :beauty="pusher.beautyLevel" :whiteness="pusher.whitenessLevel" :orientation="pusher.videoOrientation" :aspect="pusher.videoAspect" :device-position="pusher.frontCamera" :remote-mirror="pusher.enableRemoteMirror" :local-mirror="pusher.localMirror" :background-mute="pusher.enableBackgroundMute" :audio-quality="pusher.audioQuality" :audio-volume-type="pusher.audioVolumeType" :audio-reverb-type="pusher.audioReverbType" :waiting-image="pusher.waitingImage" :debug="debug" @statechange="_$self.$parent[('_pusherStateChangeHandler')]($event)" @netstatus="_$self.$parent[('_pusherNetStatusHandler')]($event)" @error="_$self.$parent[('_pusherErrorHandler')]($event)" @bgmstart="_$self.$parent[('_pusherBGMStartHandler')]($event)" @bgmprogress="_$self.$parent[('_pusherBGMProgressHandler')]($event)" @bgmcomplete="_$self.$parent[('_pusherBGMCompleteHandler')]($event)" @audiovolumenotify="_$self.$parent[('_pusherAudioVolumeNotify')]($event)"></live-pusher>
  9. <view class="loading" v-if="streamList.length === 0">
  10. <view class="loading-img">
  11. <image src="./static/loading.png" class="rotate-img"></image>
  12. </view>
  13. <view class="loading-text">等待接听中...</view>
  14. </view>
  15. </view>
  16. <view class="handle-btns">
  17. <view class="btn-normal" @click="_$self.$parent[('_toggleAudio')]($event)">
  18. <image class="btn-image" :src="(pusher.enableMic? './static/audio-true.png': './static/audio-false.png')+' '"></image>
  19. </view>
  20. <view class="btn-normal" @click="_$self.$parent[('switchCamera')]($event)">
  21. <image class="btn-image" src="./static/switch.png"></image>
  22. </view>
  23. <view class="btn-normal" @click="_$self.$parent[('_toggleSoundMode')]($event)">
  24. <image class="btn-image" :src="(streamList[0].soundMode === 'ear' ? './static/phone.png': './static/speaker-true.png')+' '"></image>
  25. </view>
  26. </view>
  27. <view class="bottom-btns">
  28. <view class="btn-normal" data-key="beautyLevel" data-value="9|0" data-value-type="number" @click="_$self.$parent[('_setPuserProperty')]($event)">
  29. <image class="btn-image" :src="(pusher.beautyLevel == 9 ? './static/beauty-true.png': './static/beauty-false.png')+' '"></image>
  30. </view>
  31. <view class="btn-hangup" @click="_$self.$parent[('_hangUp')]($event)">
  32. <image class="btn-image" src="./static/hangup.png"></image>
  33. </view>
  34. <view class="btn-normal" @click="_$self.$parent[('_toggleIMPanel')]($event)">
  35. <image class="btn-image" :src="enableIM? './static/im.png': './static/im-disable.png'"></image>
  36. </view>
  37. </view>
  38. </view>
  39. </template></uni-shadow-root>
  40. </template>
  41. <script>
  42. global['__wxRoute'] = 'trtc-room/template/1v1/1v1'
  43. Component({})
  44. export default global['__wxComponents']['trtc-room/template/1v1/1v1']
  45. </script>
  46. <style platform="mp-weixin">
  47. /* 1v1 视频电话模式 */
  48. .template-1v1{
  49. width: 100vw;
  50. height: 100vh;
  51. position: relative;
  52. }
  53. .template-1v1 .pusher-container{
  54. width: 240rpx;
  55. height: 320rpx;
  56. position: absolute;
  57. right: 20rpx;
  58. top: 160rpx;
  59. z-index: 2;
  60. }
  61. .template-1v1 .pusher-container.fullscreen{
  62. width: 100vw;
  63. height: 100vh;
  64. top: 0;
  65. right: 0;
  66. }
  67. .template-1v1 .loading {
  68. position: absolute;
  69. top: 40vh;
  70. left: 50vw;
  71. transform: translate(-50%, 0);
  72. width: 300rpx;
  73. height: 250rpx;
  74. border-radius: 12rpx;
  75. background: rgba(0,0,0,0.6);
  76. color: white;
  77. padding: 40rpx;
  78. display: flex;
  79. flex-direction: column;
  80. }
  81. .template-1v1 .loading-img {
  82. height: 200rpx;
  83. display:flex;
  84. justify-content: center;
  85. align-items: center;
  86. animation: rotate 2s linear infinite;
  87. }
  88. .template-1v1 .rotate-img {
  89. width:160rpx;
  90. height: 160rpx;
  91. }
  92. .template-1v1 .loading-text {
  93. width: 100%;
  94. padding-top: 40rpx;
  95. text-align: center;
  96. }
  97. @keyframes rotate {
  98. 0%{ transform: rotate(0deg);}
  99. 50%{ transform: rotate(180deg);}
  100. 100%{ transform: rotate(360deg);}
  101. }
  102. .template-1v1 .player-container:nth-child(1){
  103. width: 100vw;
  104. height: 100vh;
  105. }
  106. .template-1v1 .handle-btns {
  107. position: absolute;
  108. z-index: 3;
  109. bottom: 15vh;
  110. width: 100vw;
  111. display: flex;
  112. flex-direction: row;
  113. justify-content: space-around;
  114. }
  115. .template-1v1 .bottom-btns {
  116. position: absolute;
  117. z-index: 3;
  118. bottom: 3vh;
  119. width: 100vw;
  120. display: flex;
  121. flex-direction: row;
  122. justify-content: space-around;
  123. }
  124. /* .template-1v1 image {
  125. width: 4vh;
  126. height: 4vh;
  127. } */
  128. .template-1v1 .btn-normal {
  129. width: 8vh;
  130. height: 8vh;
  131. box-sizing: border-box;
  132. display: flex;
  133. background: white;
  134. justify-content: center;
  135. align-items: center;
  136. border-radius: 50%;
  137. }
  138. .template-1v1 .btn-hangup .btn-image,
  139. .template-1v1 .btn-normal .btn-image{
  140. width: 4vh;
  141. height: 4vh;
  142. }
  143. .template-1v1 .btn-hangup {
  144. width: 8vh;
  145. height: 8vh;
  146. background: #f75c45;
  147. box-sizing: border-box;
  148. display: flex;
  149. justify-content: center;
  150. align-items: center;
  151. border-radius: 50%;
  152. }
  153. </style>