wangliang_wd

feat:优化文章详情页视频播放

@@ -126,7 +126,19 @@ export struct WdWebLocalComponent { @@ -126,7 +126,19 @@ export struct WdWebLocalComponent {
126 126
127 if (this.videoUrl) { 127 if (this.videoUrl) {
128 Stack({ alignContent: Alignment.Bottom }) { 128 Stack({ alignContent: Alignment.Bottom }) {
129 - this.videoComp() 129 + ForEach([this.videoUrl], (compIndex: number) => {
  130 + ///解决播放器复用问题,后期优化(第二段视频播放器会先闪现第一段视频的画面)
  131 + ListItem() {
  132 + this.videoComp()
  133 + }
  134 + .onClick(() => {
  135 + if (this.progressOpacity <= 0) {
  136 + this.progressOpacity = 1
  137 + } else {
  138 + this.progressOpacity = 0
  139 + }
  140 + })
  141 + })
130 } 142 }
131 .width(this.positionWidth) 143 .width(this.positionWidth)
132 .height(this.positionHeight) 144 .height(this.positionHeight)
@@ -281,15 +293,6 @@ export struct WdWebLocalComponent { @@ -281,15 +293,6 @@ export struct WdWebLocalComponent {
281 WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT) 293 WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT)
282 } 294 }
283 }) 295 })
284 - .onClick(() => {  
285 - // animateTo({duration: 1000}, () => {  
286 - if (this.progressOpacity <= 0) {  
287 - this.progressOpacity = 1  
288 - } else {  
289 - this.progressOpacity = 0  
290 - }  
291 - // })  
292 - })  
293 296
294 if (this.isEndPlay){ 297 if (this.isEndPlay){
295 Column(){ 298 Column(){
@@ -307,74 +310,80 @@ export struct WdWebLocalComponent { @@ -307,74 +310,80 @@ export struct WdWebLocalComponent {
307 .width(this.positionWidth) 310 .width(this.positionWidth)
308 .height(this.positionHeight) 311 .height(this.positionHeight)
309 }else { 312 }else {
310 - Row() {  
311 - Image(this.isPause ? $r('app.media.icon_play') : $r('app.media.icon_pause'))  
312 - .interpolation(ImageInterpolation.Medium)  
313 - .width(24)  
314 - .height(24)  
315 - .onClick(() => {  
316 - if (this.isPause) {  
317 - this.startPlay()  
318 - } else {  
319 - this.controller.pause()  
320 - this.cancelProgressTimer()  
321 - }  
322 - }).margin({right:16})  
323 - 313 + Column(){
324 Row() { 314 Row() {
325 - Text(DateTimeUtils.getFormattedDuration(this.currentTime * 1000))  
326 - .fontSize(12)  
327 - .fontColor(Color.White)  
328 - .fontWeight(600)  
329 -  
330 - Slider({  
331 - value: this.currentTime,  
332 - min: 0,  
333 - max: this.durationTime  
334 - })  
335 - .width("50%")  
336 - .selectedColor('#ED2800')  
337 - .trackColor("#1AFFFFFF")  
338 - .trackThickness(2)  
339 - .margin({ left: 4, right: 4 })  
340 - .blockStyle({  
341 - type: SliderBlockType.IMAGE,  
342 - image: $r('app.media.slider_block')  
343 - })  
344 - .blockSize({ width: 14, height: 10 })  
345 - .onChange((value: number, mode: SliderChangeMode) => {  
346 - this.controller.setCurrentTime(value);  
347 - if (mode == SliderChangeMode.End) {  
348 - if (this.isPause) {  
349 - this.startPlay()  
350 - } else {  
351 - this.startProgressTimer()  
352 - } 315 + Image(this.isPause ? $r('app.media.icon_play') : $r('app.media.icon_pause'))
  316 + .interpolation(ImageInterpolation.Medium)
  317 + .width(24)
  318 + .height(24)
  319 + .onClick(() => {
  320 + if (this.isPause) {
  321 + this.startPlay()
  322 + } else {
  323 + this.controller.pause()
  324 + this.cancelProgressTimer()
353 } 325 }
  326 + }).margin({right:16})
  327 +
  328 + Row() {
  329 + Text(DateTimeUtils.getFormattedDuration(this.currentTime * 1000))
  330 + .fontSize(12)
  331 + .fontColor(Color.White)
  332 + .fontWeight(600)
  333 +
  334 + Slider({
  335 + value: this.currentTime,
  336 + min: 0,
  337 + max: this.durationTime
354 }) 338 })
355 - Text(DateTimeUtils.getFormattedDuration(this.durationTime * 1000))  
356 - .fontSize(12)  
357 - .fontColor(Color.White)  
358 - .fontWeight(600)  
359 - }.alignItems(VerticalAlign.Center) 339 + .width("50%")
  340 + .selectedColor('#ED2800')
  341 + .trackColor("#1AFFFFFF")
  342 + .trackThickness(2)
  343 + .margin({ left: 4, right: 4 })
  344 + .blockStyle({
  345 + type: SliderBlockType.IMAGE,
  346 + image: $r('app.media.slider_block')
  347 + })
  348 + .blockSize({ width: 14, height: 10 })
  349 + .onChange((value: number, mode: SliderChangeMode) => {
  350 + this.controller.setCurrentTime(value);
  351 + if (mode == SliderChangeMode.End) {
  352 + if (this.isPause) {
  353 + this.progressTimerNumber = 0
  354 + this.startPlay()
  355 + } else {
  356 + this.startProgressTimer()
  357 + }
  358 + }
  359 + })
  360 + Text(DateTimeUtils.getFormattedDuration(this.durationTime * 1000))
  361 + .fontSize(12)
  362 + .fontColor(Color.White)
  363 + .fontWeight(600)
  364 + }.alignItems(VerticalAlign.Center)
  365 + .height(48)
  366 +
  367 + // Image($r('app.media.icon_full_screen'))
  368 + // .width(24)
  369 + // .height(24)
  370 + // .onClick(() => {
  371 + // this.controller.requestFullscreen(true)
  372 + // })
  373 + }
  374 + .opacity(this.progressOpacity)
  375 + .linearGradient({
  376 + direction: GradientDirection.Top, // 渐变方向
  377 + colors: [[0x20000000, 0.0], [Color.Transparent, 1.0]] // [0x80000000, 0.5],
  378 + })
  379 + .width("100%")
360 .height(48) 380 .height(48)
361 -  
362 - // Image($r('app.media.icon_full_screen'))  
363 - // .width(24)  
364 - // .height(24)  
365 - // .onClick(() => {  
366 - // this.controller.requestFullscreen(true)  
367 - // }) 381 + .padding({left:16})
  382 + .alignItems(VerticalAlign.Center)
368 } 383 }
369 - .opacity(this.progressOpacity)  
370 - .linearGradient({  
371 - direction: GradientDirection.Top, // 渐变方向  
372 - colors: [[0x20000000, 0.0], [Color.Transparent, 1.0]] // [0x80000000, 0.5],  
373 - })  
374 - .width("100%")  
375 - .height(48)  
376 - .padding({left:16})  
377 - .alignItems(VerticalAlign.Center) 384 + .justifyContent(FlexAlign.End)
  385 + .width(this.positionWidth)
  386 + .height(this.positionHeight)
378 } 387 }
379 } 388 }
380 389