liyubing

feat:直播间背景图 高斯模糊

1 -import { ContentDetailDTO, LiveDetailsBean } from 'wdBean/Index'; 1 +import { ContentDetailDTO } from 'wdBean/Index';
2 import { Logger, StringUtils } from 'wdKit/Index'; 2 import { Logger, StringUtils } from 'wdKit/Index';
3 import { PlayerConstants, WDAliPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index'; 3 import { PlayerConstants, WDAliPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index';
4 import { PlayUIComponent } from './PlayUIComponent'; 4 import { PlayUIComponent } from './PlayUIComponent';
5 import { PictureLoading } from '../../vertical/PictureLoading'; 5 import { PictureLoading } from '../../vertical/PictureLoading';
6 -import { ParamType, TrackConstants } from 'wdTracking/Index'; 6 +import { TrackConstants } from 'wdTracking/Index';
7 7
8 const TAG: string = 'TopPlayComponent' 8 const TAG: string = 'TopPlayComponent'
9 9
@@ -25,7 +25,7 @@ export struct TopPlayComponent { @@ -25,7 +25,7 @@ export struct TopPlayComponent {
25 //播放错误 25 //播放错误
26 @State isError: boolean = false 26 @State isError: boolean = false
27 // loading 控制字段 27 // loading 控制字段
28 - @State isLoading: boolean = false 28 + @State isHideLoading: boolean = false
29 // 获取播放资源能播放了 29 // 获取播放资源能播放了
30 @State isCanPlay: boolean = false 30 @State isCanPlay: boolean = false
31 // 当前播放资源的状态 31 // 当前播放资源的状态
@@ -38,7 +38,7 @@ export struct TopPlayComponent { @@ -38,7 +38,7 @@ export struct TopPlayComponent {
38 38
39 this.playerController.onCanplay = () => { 39 this.playerController.onCanplay = () => {
40 this.isCanPlay = true 40 this.isCanPlay = true
41 - this.isLoading = true 41 + this.isHideLoading = true
42 this.playerController?.play() 42 this.playerController?.play()
43 } 43 }
44 44
@@ -48,7 +48,7 @@ export struct TopPlayComponent { @@ -48,7 +48,7 @@ export struct TopPlayComponent {
48 Logger.debug(TAG, 'status==>' + status) 48 Logger.debug(TAG, 'status==>' + status)
49 if (status === PlayerConstants.STATUS_ERROR) { 49 if (status === PlayerConstants.STATUS_ERROR) {
50 this.isError = true 50 this.isError = true
51 - this.isLoading = true 51 + this.isHideLoading = true
52 this.isCanPlay = false 52 this.isCanPlay = false
53 } else if (status === PlayerConstants.STATUS_COMPLETION) { 53 } else if (status === PlayerConstants.STATUS_COMPLETION) {
54 // 播放完成 54 // 播放完成
@@ -68,6 +68,7 @@ export struct TopPlayComponent { @@ -68,6 +68,7 @@ export struct TopPlayComponent {
68 updateData() { 68 updateData() {
69 // 检测等待中的直播预告是否视频资源 69 // 检测等待中的直播预告是否视频资源
70 if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.previewType === 1 70 if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.previewType === 1
  71 + && this.contentDetailData?.liveInfo?.liveState == 'wait'
71 && this.contentDetailData.liveInfo.previewUrl && 72 && this.contentDetailData.liveInfo.previewUrl &&
72 this.contentDetailData.liveInfo.previewUrl.length > 0) { 73 this.contentDetailData.liveInfo.previewUrl.length > 0) {
73 // 预告资源是视频 74 // 预告资源是视频
@@ -87,18 +88,17 @@ export struct TopPlayComponent { @@ -87,18 +88,17 @@ export struct TopPlayComponent {
87 88
88 if (this.isVideoSource) { 89 if (this.isVideoSource) {
89 this.isWait = false 90 this.isWait = false
90 - this.isLoading = false 91 + this.isHideLoading = false
91 } else { 92 } else {
92 this.isWait = this.contentDetailData?.liveInfo?.liveState == 'wait' 93 this.isWait = this.contentDetailData?.liveInfo?.liveState == 'wait'
93 if (this.isWait) { 94 if (this.isWait) {
94 - this.isLoading = true 95 + this.isHideLoading = true
95 } 96 }
96 } 97 }
97 98
98 this.isEnd = this.contentDetailData?.liveInfo?.liveState === 'end' && 99 this.isEnd = this.contentDetailData?.liveInfo?.liveState === 'end' &&
99 StringUtils.isEmpty(this.contentDetailData?.liveInfo?.vlive[0]?.replayUri) 100 StringUtils.isEmpty(this.contentDetailData?.liveInfo?.vlive[0]?.replayUri)
100 101
101 - // Logger.debug(TAG, `---0------>` + this.isWait + ' ->' + this.isLoading + ' ->' + this.isEnd)  
102 if (!this.isWait) { 102 if (!this.isWait) {
103 if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.vlive.length > 0) { 103 if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.vlive.length > 0) {
104 let playUrl = '' 104 let playUrl = ''
@@ -114,31 +114,38 @@ export struct TopPlayComponent { @@ -114,31 +114,38 @@ export struct TopPlayComponent {
114 } else { 114 } else {
115 Logger.debug(TAG, `---0------>${playUrl}`) 115 Logger.debug(TAG, `---0------>${playUrl}`)
116 if (StringUtils.isNotEmpty(playUrl)) { 116 if (StringUtils.isNotEmpty(playUrl)) {
  117 + Logger.debug(TAG, `---isNotEmpty------>`)
117 this.playUrl = playUrl 118 this.playUrl = playUrl
118 this.tryToPlay() 119 this.tryToPlay()
119 } 120 }
120 } 121 }
121 } else { 122 } else {
122 this.isWait = true 123 this.isWait = true
123 - this.isLoading = true 124 + this.isHideLoading = true
124 } 125 }
125 } 126 }
  127 + // 直播结束
  128 + if (this.contentDetailData?.liveInfo?.liveState === 'end') {
  129 + this.isHideLoading = true
  130 + this.isWait = StringUtils.isNotEmpty(this.playUrl)
  131 + }
  132 +
126 133
127 // 文字直播 running 状态 134 // 文字直播 running 状态
128 if (this.contentDetailData?.liveInfo?.liveWay === 1 && this.contentDetailData?.liveInfo?.liveState === 'running') { 135 if (this.contentDetailData?.liveInfo?.liveWay === 1 && this.contentDetailData?.liveInfo?.liveState === 'running') {
129 this.isWait = true 136 this.isWait = true
130 - this.isLoading = true 137 + this.isHideLoading = true
131 if (this.contentDetailData.fullColumnImgUrls && this.contentDetailData.fullColumnImgUrls.length > 0) { 138 if (this.contentDetailData.fullColumnImgUrls && this.contentDetailData.fullColumnImgUrls.length > 0) {
132 this.previewUrl = this.contentDetailData.fullColumnImgUrls[0].url 139 this.previewUrl = this.contentDetailData.fullColumnImgUrls[0].url
133 } else { 140 } else {
134 this.previewUrl = '' 141 this.previewUrl = ''
135 } 142 }
136 } 143 }
137 - 144 + //Logger.debug(TAG, `---0------>` + this.isWait + ' ->' + this.isHideLoading + ' ->' + this.isEnd+' -->'+this.isVideoSource)
138 } 145 }
139 146
140 tryToPlay() { 147 tryToPlay() {
141 - Logger.debug(TAG, `---1------>`) 148 +
142 if (!this.xComponentIsLoaded) { 149 if (!this.xComponentIsLoaded) {
143 Logger.debug(TAG, "需要xComponent加载完成") 150 Logger.debug(TAG, "需要xComponent加载完成")
144 return 151 return
@@ -161,11 +168,13 @@ export struct TopPlayComponent { @@ -161,11 +168,13 @@ export struct TopPlayComponent {
161 WDPlayerRenderLiveView({ 168 WDPlayerRenderLiveView({
162 playerController: this.playerController, 169 playerController: this.playerController,
163 onLoad: async () => { 170 onLoad: async () => {
164 - this.isLoading = false  
165 - this.isError = false  
166 - this.xComponentIsLoaded = true  
167 - Logger.debug(TAG, `---onLoad------>`)  
168 - this.tryToPlay() 171 + if (StringUtils.isNotEmpty(this.playUrl)) {
  172 + this.isHideLoading = false
  173 + this.isError = false
  174 + this.xComponentIsLoaded = true
  175 + Logger.debug(TAG, `---onLoad------>`)
  176 + this.tryToPlay()
  177 + }
169 } 178 }
170 }) 179 })
171 .height('100%') 180 .height('100%')
@@ -180,12 +189,13 @@ export struct TopPlayComponent { @@ -180,12 +189,13 @@ export struct TopPlayComponent {
180 .objectFit(ImageFit.Cover) 189 .objectFit(ImageFit.Cover)
181 .alt($r('app.media.live_room_image_fail')) 190 .alt($r('app.media.live_room_image_fail'))
182 .visibility(this.isWait || this.isEnd ? Visibility.Visible : Visibility.None) 191 .visibility(this.isWait || this.isEnd ? Visibility.Visible : Visibility.None)
183 - .contrast(this.isEnd ? 0.2 : 1) 192 + // .contrast(this.isEnd ? 0.4 : 1)
  193 + .blur(this.isEnd ? 20 : 0)
184 .width('100%') 194 .width('100%')
185 } 195 }
186 196
187 // loading 197 // loading
188 - PictureLoading().visibility(this.isLoading ? Visibility.None : Visibility.Visible) 198 + PictureLoading().visibility(this.isHideLoading ? Visibility.None : Visibility.Visible)
189 199
190 // 视频播放器上的控制面板和信息 200 // 视频播放器上的控制面板和信息
191 PlayUIComponent({ playerController: this.playerController, isShowBottom: this.isCanPlay, liveUrl: this.playUrl }) 201 PlayUIComponent({ playerController: this.playerController, isShowBottom: this.isCanPlay, liveUrl: this.playUrl })
@@ -221,7 +231,7 @@ export struct TopPlayComponent { @@ -221,7 +231,7 @@ export struct TopPlayComponent {
221 .margin({ top: 16 }) 231 .margin({ top: 16 })
222 .padding(0) 232 .padding(0)
223 .onClick(() => { 233 .onClick(() => {
224 - this.isLoading = false 234 + this.isHideLoading = false
225 this.isError = false 235 this.isError = false
226 this.xComponentIsLoaded = true 236 this.xComponentIsLoaded = true
227 this.tryToPlay() 237 this.tryToPlay()