wangliang_wd

feat:优化视频详情页转屏逻辑

@@ -52,5 +52,10 @@ export enum EmitterEventId { @@ -52,5 +52,10 @@ export enum EmitterEventId {
52 // 图文详情页点赞状态 52 // 图文详情页点赞状态
53 LIKE_CHANGE_STATUS = 15, 53 LIKE_CHANGE_STATUS = 15,
54 54
  55 + // 直播,回看全屏
  56 + live_FULL_SCREEN = 16,
  57 +
  58 + // 直播,回看半屏
  59 + live_half_SCREEN = 17,
55 } 60 }
56 61
@@ -4,7 +4,7 @@ import { TabComponent } from '../widgets/details/TabComponent'; @@ -4,7 +4,7 @@ import { TabComponent } from '../widgets/details/TabComponent';
4 import { TopPlayComponent } from '../widgets/details/video/TopPlayComponet'; 4 import { TopPlayComponent } from '../widgets/details/video/TopPlayComponet';
5 import { DisplayDirection } from 'wdConstant/Index'; 5 import { DisplayDirection } from 'wdConstant/Index';
6 import mediaquery from '@ohos.mediaquery'; 6 import mediaquery from '@ohos.mediaquery';
7 -import { CustomToast, Logger, WindowModel } from 'wdKit/Index'; 7 +import { CustomToast, EmitterEventId, EmitterUtils, Logger, WindowModel } from 'wdKit/Index';
8 import { display, router, window } from '@kit.ArkUI'; 8 import { display, router, window } from '@kit.ArkUI';
9 import { WDAliPlayerController } from 'wdPlayer/Index'; 9 import { WDAliPlayerController } from 'wdPlayer/Index';
10 import { LiveOperRowListView } from 'wdComponent'; 10 import { LiveOperRowListView } from 'wdComponent';
@@ -51,6 +51,8 @@ export struct DetailPlayLivePage { @@ -51,6 +51,8 @@ export struct DetailPlayLivePage {
51 @Consume liveDetailPageLogic: LiveDetailPageLogic 51 @Consume liveDetailPageLogic: LiveDetailPageLogic
52 @State topPlayHeight:number = this.getTopPlayHeight() 52 @State topPlayHeight:number = this.getTopPlayHeight()
53 @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm'; 53 @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm';
  54 + @State isPORTRAIT: boolean = true
  55 + @State half_SCREEN: boolean = true
54 56
55 async aboutToAppear(): Promise<void> { 57 async aboutToAppear(): Promise<void> {
56 Logger.info(TAG, `wyj-aboutToAppear`) 58 Logger.info(TAG, `wyj-aboutToAppear`)
@@ -64,6 +66,18 @@ export struct DetailPlayLivePage { @@ -64,6 +66,18 @@ export struct DetailPlayLivePage {
64 } 66 }
65 // WindowModel.shared.setMainWindowFullScreen(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL) 67 // WindowModel.shared.setMainWindowFullScreen(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL)
66 }) 68 })
  69 +
  70 + EmitterUtils.receiveEvent(EmitterEventId.live_FULL_SCREEN, (str?: string) => {
  71 + Logger.debug(TAG, 'receiveEvent FULL_SCREEN: ' + str)
  72 + // 跳转指定频道场景,传参底导id、频道id
  73 + this.isPORTRAIT = str == '1' ? false : true
  74 + })
  75 +
  76 + EmitterUtils.receiveEvent(EmitterEventId.live_half_SCREEN, (str?: string) => {
  77 + Logger.debug(TAG, 'receiveEvent FULL_SCREEN: ' + str)
  78 + // 跳转指定频道场景,传参底导id、频道id
  79 + this.half_SCREEN = str == '1' ? false : true
  80 + })
67 this.getLiveDetails() 81 this.getLiveDetails()
68 this.getLiveRoomData() 82 this.getLiveRoomData()
69 this.configChatRoom() 83 this.configChatRoom()
@@ -140,9 +154,9 @@ export struct DetailPlayLivePage { @@ -140,9 +154,9 @@ export struct DetailPlayLivePage {
140 build() { 154 build() {
141 Column() { 155 Column() {
142 TopPlayComponent({ playerController: this.playerController, isEnd: this.isEnd, lastLiveControl: this.lastLiveControl }) 156 TopPlayComponent({ playerController: this.playerController, isEnd: this.isEnd, lastLiveControl: this.lastLiveControl })
143 - .height(this.displayDirection == DisplayDirection.VERTICAL ? this.topPlayHeight : '100%') 157 + .height(this.isPORTRAIT ? this.topPlayHeight : '100%')
144 .margin({ 158 .margin({
145 - top: this.displayDirection == DisplayDirection.VERTICAL ? px2vp(this.topSafeHeight) : 0 159 + top: this.half_SCREEN ? px2vp(this.topSafeHeight) : 0
146 }) 160 })
147 161
148 TabComponent({ 162 TabComponent({
1 import { window } from '@kit.ArkUI'; 1 import { window } from '@kit.ArkUI';
2 import lottie from '@ohos/lottie'; 2 import lottie from '@ohos/lottie';
3 3
4 -import { NumberFormatterUtils, StringUtils, WindowModel } from 'wdKit/Index'; 4 +import { EmitterEventId, EmitterUtils, NumberFormatterUtils, StringUtils, WindowModel } from 'wdKit/Index';
5 import { DateFormatUtil, PlayerConstants, WDAliPlayerController } from 'wdPlayer/Index'; 5 import { DateFormatUtil, PlayerConstants, WDAliPlayerController } from 'wdPlayer/Index';
6 import { ContentDetailDTO, LiveRoomDataBean } from 'wdBean/Index'; 6 import { ContentDetailDTO, LiveRoomDataBean } from 'wdBean/Index';
7 import { DisplayDirection } from 'wdConstant/Index'; 7 import { DisplayDirection } from 'wdConstant/Index';
@@ -345,20 +345,21 @@ export struct PlayUIComponent { @@ -345,20 +345,21 @@ export struct PlayUIComponent {
345 .width(24) 345 .width(24)
346 .height(24) 346 .height(24)
347 .onClick(() => { 347 .onClick(() => {
348 - clearTimeout(this.time)  
349 - WindowModel.shared.setSpecificSystemBarEnabled(false)  
350 348
  349 + // this.isMenuVisible = false
351 this.displayDirection = 350 this.displayDirection =
352 this.displayDirection == DisplayDirection.VERTICAL ? DisplayDirection.VIDEO_HORIZONTAL : 351 this.displayDirection == DisplayDirection.VERTICAL ? DisplayDirection.VIDEO_HORIZONTAL :
353 DisplayDirection.VERTICAL 352 DisplayDirection.VERTICAL
354 -  
355 WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ? 353 WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ?
356 window.Orientation.PORTRAIT : 354 window.Orientation.PORTRAIT :
357 window.Orientation.LANDSCAPE).then(()=>{ 355 window.Orientation.LANDSCAPE).then(()=>{
358 - this.onChangeMenuVisible() 356 + WindowModel.shared.setSpecificSystemBarEnabled(false)
  357 + EmitterUtils.sendEvent(EmitterEventId.live_half_SCREEN, 1)
359 }) 358 })
360 -  
361 - 359 + let timer = setTimeout(() => {
  360 + EmitterUtils.sendEvent(EmitterEventId.live_FULL_SCREEN, 1)
  361 + clearTimeout(timer)
  362 + }, 200)
362 }) 363 })
363 .visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None) 364 .visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
364 } 365 }
@@ -454,13 +455,17 @@ export struct PlayUIComponent { @@ -454,13 +455,17 @@ export struct PlayUIComponent {
454 } 455 }
455 456
456 quitFullScreen() { 457 quitFullScreen() {
457 - clearTimeout(this.time) 458 + // this.isMenuVisible = false
458 this.displayDirection = DisplayDirection.VERTICAL 459 this.displayDirection = DisplayDirection.VERTICAL
459 WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ? 460 WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ?
460 window.Orientation.PORTRAIT : 461 window.Orientation.PORTRAIT :
461 window.Orientation.LANDSCAPE).then(()=>{ 462 window.Orientation.LANDSCAPE).then(()=>{
462 - this.onChangeMenuVisible() 463 + WindowModel.shared.setSpecificSystemBarEnabled(true)
  464 + EmitterUtils.sendEvent(EmitterEventId.live_FULL_SCREEN, 0)
463 }) 465 })
464 - WindowModel.shared.setSpecificSystemBarEnabled(true) 466 + let timer = setTimeout(() => {
  467 + EmitterUtils.sendEvent(EmitterEventId.live_half_SCREEN, 0)
  468 + clearTimeout(timer)
  469 + }, 200)
465 } 470 }
466 } 471 }
@@ -33,7 +33,7 @@ export struct DetailPlayShortVideoPage { @@ -33,7 +33,7 @@ export struct DetailPlayShortVideoPage {
33 @State playerController: WDPlayerController = new WDPlayerController(); 33 @State playerController: WDPlayerController = new WDPlayerController();
34 @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO 34 @Provide contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
35 @Provide interactData: InteractDataDTO = {} as InteractDataDTO 35 @Provide interactData: InteractDataDTO = {} as InteractDataDTO
36 - @Provide isFullScreen: boolean = false; 36 + @State isFullScreen: boolean = false;
37 @Provide progressVal: number = 0; 37 @Provide progressVal: number = 0;
38 @Provide videoLandScape: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2 38 @Provide videoLandScape: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2
39 @Provide newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult // 点赞、收藏状态 39 @Provide newsStatusOfUser: batchLikeAndCollectResult = {} as batchLikeAndCollectResult // 点赞、收藏状态
@@ -42,7 +42,7 @@ export struct DetailPlayShortVideoPage { @@ -42,7 +42,7 @@ export struct DetailPlayShortVideoPage {
42 @Provide isDragging: boolean = false // 拖动时间进度条 42 @Provide isDragging: boolean = false // 拖动时间进度条
43 @Provide status: number = PlayerConstants.STATUS_START; 43 @Provide status: number = PlayerConstants.STATUS_START;
44 @Consume @Watch("showCommentListChanged") showCommentList: boolean 44 @Consume @Watch("showCommentListChanged") showCommentList: boolean
45 - @Consume displayDirection: DisplayDirection 45 + @Consume @Watch('displayDirectionChange') displayDirection: DisplayDirection
46 @Consume @Watch('videoStatusChange') switchVideoStatus: boolean 46 @Consume @Watch('videoStatusChange') switchVideoStatus: boolean
47 @State isPlay: boolean = true // 视频手动播放暂停 47 @State isPlay: boolean = true // 视频手动播放暂停
48 @Consume @Watch('pageShowChange') pageShow: number 48 @Consume @Watch('pageShowChange') pageShow: number
@@ -75,6 +75,16 @@ export struct DetailPlayShortVideoPage { @@ -75,6 +75,16 @@ export struct DetailPlayShortVideoPage {
75 } 75 }
76 76
77 /** 77 /**
  78 + * 页面转屏参数变化
  79 + */
  80 + displayDirectionChange(){
  81 + let timer = setTimeout(() => {
  82 + this.isFullScreen = this.displayDirection === DisplayDirection.VERTICAL ?false:true
  83 + clearTimeout(timer)
  84 + }, this.displayDirection === DisplayDirection.VERTICAL ?200:0)
  85 + }
  86 +
  87 + /**
78 * 页面显示重查用户关注、点赞等信息 88 * 页面显示重查用户关注、点赞等信息
79 */ 89 */
80 async pageShowChange() { 90 async pageShowChange() {
@@ -368,7 +378,7 @@ export struct DetailPlayShortVideoPage { @@ -368,7 +378,7 @@ export struct DetailPlayShortVideoPage {
368 }) 378 })
369 379
370 // 显示评论且非全屏模式(视频频道无评论showComment=false) 380 // 显示评论且非全屏模式(视频频道无评论showComment=false)
371 - if (this.showComment && this.displayDirection === DisplayDirection.VERTICAL) { 381 + if (this.showComment && !this.isFullScreen) {
372 OperRowListView({ 382 OperRowListView({
373 pageComponentType: 1, 383 pageComponentType: 1,
374 styleType: 3, 384 styleType: 3,
@@ -392,8 +402,12 @@ export struct DetailPlayShortVideoPage { @@ -392,8 +402,12 @@ export struct DetailPlayShortVideoPage {
392 .id('video-container') 402 .id('video-container')
393 .height('100%') 403 .height('100%')
394 .width('100%') 404 .width('100%')
395 - .onAreaChange(() => this.calculatePlayerRect())  
396 - 405 + .onAreaChange(() => {
  406 + let timer = setTimeout(() => {
  407 + this.calculatePlayerRect()
  408 + clearTimeout(timer)
  409 + }, this.displayDirection === DisplayDirection.VERTICAL ?200:0)
  410 + })
397 } 411 }
398 412
399 @Builder 413 @Builder
@@ -549,7 +563,6 @@ export struct DetailPlayShortVideoPage { @@ -549,7 +563,6 @@ export struct DetailPlayShortVideoPage {
549 } else { 563 } else {
550 EmitterUtils.sendEvent(EmitterEventId.FULL_SCREEN, 1) 564 EmitterUtils.sendEvent(EmitterEventId.FULL_SCREEN, 1)
551 } 565 }
552 -  
553 }) 566 })
554 567
555 } 568 }
@@ -254,6 +254,7 @@ export struct PlayerFullScreenView { @@ -254,6 +254,7 @@ export struct PlayerFullScreenView {
254 WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ? 254 WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ?
255 window.Orientation.PORTRAIT : 255 window.Orientation.PORTRAIT :
256 window.Orientation.LANDSCAPE) 256 window.Orientation.LANDSCAPE)
  257 +
257 EmitterUtils.sendEvent(EmitterEventId.FULL_SCREEN, 0) 258 EmitterUtils.sendEvent(EmitterEventId.FULL_SCREEN, 0)
258 }) 259 })
259 Text(this.getTitle()) 260 Text(this.getTitle())