Showing
6 changed files
with
60 additions
and
25 deletions
| @@ -171,7 +171,7 @@ export struct EmptyComponent { | @@ -171,7 +171,7 @@ export struct EmptyComponent { | ||
| 171 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVideo) { | 171 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVideo) { |
| 172 | imageString = $r('app.media.icon_no_content') | 172 | imageString = $r('app.media.icon_no_content') |
| 173 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent1) { | 173 | } else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent1) { |
| 174 | - imageString = $r('app.media.icon_no_appointmentMade') | 174 | + imageString = $r('app.media.icon_no_appointmentMade1') |
| 175 | } | 175 | } |
| 176 | return imageString | 176 | return imageString |
| 177 | } | 177 | } |
| @@ -9,12 +9,14 @@ import { Logger, WindowModel } from 'wdKit/Index'; | @@ -9,12 +9,14 @@ import { Logger, WindowModel } from 'wdKit/Index'; | ||
| 9 | import { window } from '@kit.ArkUI'; | 9 | import { window } from '@kit.ArkUI'; |
| 10 | import { devicePLSensorManager } from 'wdDetailPlayApi/Index'; | 10 | import { devicePLSensorManager } from 'wdDetailPlayApi/Index'; |
| 11 | import { LiveCommentComponent } from 'wdComponent/Index'; | 11 | import { LiveCommentComponent } from 'wdComponent/Index'; |
| 12 | +import { WDPlayerController } from 'wdPlayer/Index'; | ||
| 12 | 13 | ||
| 13 | @Entry | 14 | @Entry |
| 14 | @Component | 15 | @Component |
| 15 | export struct DetailPlayLivePage { | 16 | export struct DetailPlayLivePage { |
| 16 | //横竖屏,默认竖屏 | 17 | //横竖屏,默认竖屏 |
| 17 | @Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL | 18 | @Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL |
| 19 | + playerController: WDPlayerController = new WDPlayerController(); | ||
| 18 | TAG: string = 'DetailPlayLivePage'; | 20 | TAG: string = 'DetailPlayLivePage'; |
| 19 | liveViewModel: LiveViewModel = new LiveViewModel() | 21 | liveViewModel: LiveViewModel = new LiveViewModel() |
| 20 | @State relId: string = '' | 22 | @State relId: string = '' |
| @@ -23,18 +25,19 @@ export struct DetailPlayLivePage { | @@ -23,18 +25,19 @@ export struct DetailPlayLivePage { | ||
| 23 | @Provide liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean | 25 | @Provide liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean |
| 24 | @Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean | 26 | @Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean |
| 25 | @State tabs: string[] = [] | 27 | @State tabs: string[] = [] |
| 28 | + //监听屏幕横竖屏变化 | ||
| 29 | + listener = mediaquery.matchMediaSync('(orientation: landscape)'); | ||
| 26 | 30 | ||
| 27 | aboutToAppear(): void { | 31 | aboutToAppear(): void { |
| 28 | - //监听屏幕横竖屏变化 | ||
| 29 | - let listener = mediaquery.matchMediaSync('(orientation: landscape)'); | ||
| 30 | - listener.on("change", (mediaQueryResult) => { | 32 | + Logger.info(this.TAG, `wyj-aboutToAppear`) |
| 33 | + this.listener?.on("change", (mediaQueryResult) => { | ||
| 31 | Logger.info(this.TAG, `change;${mediaQueryResult.matches}`) | 34 | Logger.info(this.TAG, `change;${mediaQueryResult.matches}`) |
| 32 | - if (mediaQueryResult.matches) { | 35 | + if (mediaQueryResult?.matches) { |
| 33 | this.displayDirection = DisplayDirection.VIDEO_HORIZONTAL | 36 | this.displayDirection = DisplayDirection.VIDEO_HORIZONTAL |
| 34 | } else { | 37 | } else { |
| 35 | this.displayDirection = DisplayDirection.VERTICAL | 38 | this.displayDirection = DisplayDirection.VERTICAL |
| 36 | } | 39 | } |
| 37 | - // WindowModel.shared.setMainWindowFullScreen(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL) | 40 | + WindowModel.shared.setMainWindowFullScreen(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL) |
| 38 | }) | 41 | }) |
| 39 | let par: Action = router.getParams() as Action; | 42 | let par: Action = router.getParams() as Action; |
| 40 | let params = par?.params; | 43 | let params = par?.params; |
| @@ -47,7 +50,7 @@ export struct DetailPlayLivePage { | @@ -47,7 +50,7 @@ export struct DetailPlayLivePage { | ||
| 47 | 50 | ||
| 48 | build() { | 51 | build() { |
| 49 | Column() { | 52 | Column() { |
| 50 | - TopPlayComponent() | 53 | + TopPlayComponent({ playerController: this.playerController }) |
| 51 | .layoutWeight(211) | 54 | .layoutWeight(211) |
| 52 | TabComponent({ tabs: this.tabs }) | 55 | TabComponent({ tabs: this.tabs }) |
| 53 | .layoutWeight(503) | 56 | .layoutWeight(503) |
| @@ -60,12 +63,15 @@ export struct DetailPlayLivePage { | @@ -60,12 +63,15 @@ export struct DetailPlayLivePage { | ||
| 60 | } | 63 | } |
| 61 | 64 | ||
| 62 | onPageShow(): void { | 65 | onPageShow(): void { |
| 63 | - WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); | 66 | + Logger.info(this.TAG, `wyj-onPageShow`) |
| 67 | + // WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); | ||
| 64 | } | 68 | } |
| 65 | 69 | ||
| 66 | onPageHide(): void { | 70 | onPageHide(): void { |
| 71 | + Logger.info(this.TAG, `wyj-onPageHide`) | ||
| 67 | devicePLSensorManager.devicePLSensorOff(); | 72 | devicePLSensorManager.devicePLSensorOff(); |
| 68 | - WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); | 73 | + // WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); |
| 74 | + this.playerController?.pause() | ||
| 69 | } | 75 | } |
| 70 | 76 | ||
| 71 | getLiveDetails() { | 77 | getLiveDetails() { |
| @@ -98,7 +104,7 @@ export struct DetailPlayLivePage { | @@ -98,7 +104,7 @@ export struct DetailPlayLivePage { | ||
| 98 | } | 104 | } |
| 99 | 105 | ||
| 100 | aboutToDisappear(): void { | 106 | aboutToDisappear(): void { |
| 101 | - | 107 | + Logger.info(this.TAG, `wyj-aboutToDisappear`) |
| 102 | } | 108 | } |
| 103 | 109 | ||
| 104 | onBackPress(): boolean | void { | 110 | onBackPress(): boolean | void { |
| @@ -8,6 +8,7 @@ import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel' | @@ -8,6 +8,7 @@ import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel' | ||
| 8 | import { ViewType } from 'wdConstant/Index' | 8 | import { ViewType } from 'wdConstant/Index' |
| 9 | import LoadMoreLayout from 'wdComponent/src/main/ets/components/page/LoadMoreLayout' | 9 | import LoadMoreLayout from 'wdComponent/src/main/ets/components/page/LoadMoreLayout' |
| 10 | import RefreshLayout from 'wdComponent/src/main/ets/components/page/RefreshLayout' | 10 | import RefreshLayout from 'wdComponent/src/main/ets/components/page/RefreshLayout' |
| 11 | +import { StringUtils } from 'wdKit/Index' | ||
| 11 | 12 | ||
| 12 | @Component | 13 | @Component |
| 13 | export struct TabLiveComponent { | 14 | export struct TabLiveComponent { |
| @@ -94,15 +95,6 @@ export struct TabLiveComponent { | @@ -94,15 +95,6 @@ export struct TabLiveComponent { | ||
| 94 | 2.名称固定:人民日报主持人 | 95 | 2.名称固定:人民日报主持人 |
| 95 | 3.内容:详情接口的简介,newIntroduction | 96 | 3.内容:详情接口的简介,newIntroduction |
| 96 | */ | 97 | */ |
| 97 | - // if (StringUtils.isNotEmpty(this.liveDetailsBean.oldNewsId) | ||
| 98 | - // && this.liveDetailsBean | ||
| 99 | - // && this.liveDetailsBean.liveInfo.liveState != 'wait' | ||
| 100 | - // && this.pageModel.currentPage == 1) { | ||
| 101 | - // let liveRoomItemBeanTemp: LiveRoomItemBean = {} as LiveRoomItemBean | ||
| 102 | - // liveRoomItemBeanTemp.text = this.liveDetailsBean.newIntroduction | ||
| 103 | - // liveRoomItemBeanTemp.senderUserName = '人民日报主持人' | ||
| 104 | - // data.barrageResponses.push(liveRoomItemBeanTemp) | ||
| 105 | - // } | ||
| 106 | this.pageModel.viewType = ViewType.LOADED; | 98 | this.pageModel.viewType = ViewType.LOADED; |
| 107 | this.liveList.push(...data.barrageResponses) | 99 | this.liveList.push(...data.barrageResponses) |
| 108 | if (data.barrageResponses.length === this.pageModel.pageSize) { | 100 | if (data.barrageResponses.length === this.pageModel.pageSize) { |
| @@ -110,6 +102,14 @@ export struct TabLiveComponent { | @@ -110,6 +102,14 @@ export struct TabLiveComponent { | ||
| 110 | this.pageModel.hasMore = true; | 102 | this.pageModel.hasMore = true; |
| 111 | } else { | 103 | } else { |
| 112 | this.pageModel.hasMore = false; | 104 | this.pageModel.hasMore = false; |
| 105 | + if (StringUtils.isNotEmpty(this.liveDetailsBean.oldNewsId) | ||
| 106 | + && this.liveDetailsBean | ||
| 107 | + && this.liveDetailsBean.liveInfo.liveState != 'wait') { | ||
| 108 | + let liveRoomItemBeanTemp: LiveRoomItemBean = {} as LiveRoomItemBean | ||
| 109 | + liveRoomItemBeanTemp.text = this.liveDetailsBean.newIntroduction | ||
| 110 | + liveRoomItemBeanTemp.senderUserName = '人民日报主持人' | ||
| 111 | + this.liveList.push(liveRoomItemBeanTemp) | ||
| 112 | + } | ||
| 113 | } | 113 | } |
| 114 | } else { | 114 | } else { |
| 115 | this.pageModel.viewType = ViewType.EMPTY; | 115 | this.pageModel.viewType = ViewType.EMPTY; |
| @@ -91,6 +91,7 @@ export struct TabLiveItemComponent { | @@ -91,6 +91,7 @@ export struct TabLiveItemComponent { | ||
| 91 | .objectFit(ImageFit.Auto) | 91 | .objectFit(ImageFit.Auto) |
| 92 | .borderRadius(4) | 92 | .borderRadius(4) |
| 93 | }.onClick(() => { | 93 | }.onClick(() => { |
| 94 | + this.photoList=[] | ||
| 94 | for (let item of this.item.pictureUrls) { | 95 | for (let item of this.item.pictureUrls) { |
| 95 | this.photoList.push({ | 96 | this.photoList.push({ |
| 96 | width: 0, | 97 | width: 0, |
| @@ -9,7 +9,7 @@ import { DisplayDirection } from 'wdConstant/Index' | @@ -9,7 +9,7 @@ import { DisplayDirection } from 'wdConstant/Index' | ||
| 9 | export struct PlayUIComponent { | 9 | export struct PlayUIComponent { |
| 10 | playerController: WDPlayerController = new WDPlayerController(); | 10 | playerController: WDPlayerController = new WDPlayerController(); |
| 11 | //菜单键是否可见 | 11 | //菜单键是否可见 |
| 12 | - @State isMenuVisible: boolean = true | 12 | + @State @Watch('onChangeMenuVisible') isMenuVisible: boolean = true |
| 13 | @Consume liveDetailsBean: LiveDetailsBean | 13 | @Consume liveDetailsBean: LiveDetailsBean |
| 14 | @Consume liveRoomDataBean: LiveRoomDataBean | 14 | @Consume liveRoomDataBean: LiveRoomDataBean |
| 15 | @State currentTime: string = '' | 15 | @State currentTime: string = '' |
| @@ -19,13 +19,26 @@ export struct PlayUIComponent { | @@ -19,13 +19,26 @@ export struct PlayUIComponent { | ||
| 19 | @State isPlayStatus: boolean = true | 19 | @State isPlayStatus: boolean = true |
| 20 | @Consume displayDirection: DisplayDirection | 20 | @Consume displayDirection: DisplayDirection |
| 21 | 21 | ||
| 22 | + onChangeMenuVisible() { | ||
| 23 | + let time: number = 0 | ||
| 24 | + if (this.isMenuVisible) { | ||
| 25 | + setTimeout(() => { | ||
| 26 | + this.isMenuVisible = false | ||
| 27 | + }, 5 * 1000) | ||
| 28 | + } else { | ||
| 29 | + clearTimeout(time) | ||
| 30 | + } | ||
| 31 | + } | ||
| 32 | + | ||
| 22 | aboutToAppear(): void { | 33 | aboutToAppear(): void { |
| 34 | + this.onChangeMenuVisible() | ||
| 23 | //播放进度监听 | 35 | //播放进度监听 |
| 24 | this.playerController.onTimeUpdate = (position: number, duration: number) => { | 36 | this.playerController.onTimeUpdate = (position: number, duration: number) => { |
| 25 | this.currentTime = DateFormatUtil.secondToTime(Math.floor(position / 1000)); | 37 | this.currentTime = DateFormatUtil.secondToTime(Math.floor(position / 1000)); |
| 26 | this.totalTime = DateFormatUtil.secondToTime(Math.floor(duration / 1000)); | 38 | this.totalTime = DateFormatUtil.secondToTime(Math.floor(duration / 1000)); |
| 27 | this.progressVal = Math.floor(position * 100 / duration); | 39 | this.progressVal = Math.floor(position * 100 / duration); |
| 28 | } | 40 | } |
| 41 | + | ||
| 29 | } | 42 | } |
| 30 | 43 | ||
| 31 | build() { | 44 | build() { |
| @@ -178,7 +191,12 @@ export struct PlayUIComponent { | @@ -178,7 +191,12 @@ export struct PlayUIComponent { | ||
| 178 | @Builder | 191 | @Builder |
| 179 | getBottomUIComponent() { | 192 | getBottomUIComponent() { |
| 180 | Row() { | 193 | Row() { |
| 181 | - if (this.liveDetailsBean?.liveInfo?.liveState == 'end') { | 194 | + if (this.liveDetailsBean?.liveInfo?.liveState == 'wait') { |
| 195 | + Blank() | ||
| 196 | + } else if (this.liveDetailsBean?.liveInfo?.liveState == 'running') { | ||
| 197 | + this.playOrPauseBtn() | ||
| 198 | + Blank() | ||
| 199 | + } else if (this.liveDetailsBean?.liveInfo?.liveState == 'end') { | ||
| 182 | this.playOrPauseBtn() | 200 | this.playOrPauseBtn() |
| 183 | Text(this.currentTime) | 201 | Text(this.currentTime) |
| 184 | .fontColor(Color.White) | 202 | .fontColor(Color.White) |
| @@ -187,9 +205,7 @@ export struct PlayUIComponent { | @@ -187,9 +205,7 @@ export struct PlayUIComponent { | ||
| 187 | .margin({ | 205 | .margin({ |
| 188 | left: 16 | 206 | left: 16 |
| 189 | }) | 207 | }) |
| 190 | - | ||
| 191 | this.playProgressView() | 208 | this.playProgressView() |
| 192 | - | ||
| 193 | Text(this.totalTime) | 209 | Text(this.totalTime) |
| 194 | .fontColor(Color.White) | 210 | .fontColor(Color.White) |
| 195 | .fontWeight(600) | 211 | .fontWeight(600) |
| @@ -197,8 +213,6 @@ export struct PlayUIComponent { | @@ -197,8 +213,6 @@ export struct PlayUIComponent { | ||
| 197 | .margin({ | 213 | .margin({ |
| 198 | right: 16 | 214 | right: 16 |
| 199 | }) | 215 | }) |
| 200 | - } else { | ||
| 201 | - Blank() | ||
| 202 | } | 216 | } |
| 203 | if (this.liveDetailsBean?.liveInfo?.liveState == 'running' | 217 | if (this.liveDetailsBean?.liveInfo?.liveState == 'running' |
| 204 | || this.liveDetailsBean?.liveInfo?.liveState == 'end') { | 218 | || this.liveDetailsBean?.liveInfo?.liveState == 'end') { |
| 1 | import { LiveDetailsBean } from 'wdBean/Index'; | 1 | import { LiveDetailsBean } from 'wdBean/Index'; |
| 2 | +import { Logger } from 'wdKit/Index'; | ||
| 2 | import { WDPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index'; | 3 | import { WDPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index'; |
| 3 | import { PlayUIComponent } from './PlayUIComponent'; | 4 | import { PlayUIComponent } from './PlayUIComponent'; |
| 4 | 5 | ||
| 5 | @Component | 6 | @Component |
| 6 | export struct TopPlayComponent { | 7 | export struct TopPlayComponent { |
| 8 | + TAG: string = 'TopPlayComponent' | ||
| 7 | @Consume @Watch('updateData') liveDetailsBean: LiveDetailsBean | 9 | @Consume @Watch('updateData') liveDetailsBean: LiveDetailsBean |
| 8 | playerController: WDPlayerController = new WDPlayerController(); | 10 | playerController: WDPlayerController = new WDPlayerController(); |
| 9 | @State imgUrl: string = '' | 11 | @State imgUrl: string = '' |
| @@ -42,6 +44,18 @@ export struct TopPlayComponent { | @@ -42,6 +44,18 @@ export struct TopPlayComponent { | ||
| 42 | .height('100%') | 44 | .height('100%') |
| 43 | .width('100%') | 45 | .width('100%') |
| 44 | .visibility(this.isWait ? Visibility.None : Visibility.Visible) | 46 | .visibility(this.isWait ? Visibility.None : Visibility.Visible) |
| 47 | + .onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => { | ||
| 48 | + Logger.debug(this.TAG, `当前屏幕可见区域大小: currentRatio:' +${currentRatio}`) | ||
| 49 | + if (isVisible && currentRatio >= 1.0) { | ||
| 50 | + Logger.debug(this.TAG, `播放器-暂停. currentRatio:' +${currentRatio}`) | ||
| 51 | + this.playerController.play() | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + if (!isVisible && currentRatio <= 0.0) { | ||
| 55 | + Logger.debug(this.TAG, `播放器-播放. currentRatio:' +${currentRatio}`) | ||
| 56 | + this.playerController.pause() | ||
| 57 | + } | ||
| 58 | + }) | ||
| 45 | Image(this.imgUrl) | 59 | Image(this.imgUrl) |
| 46 | .objectFit(ImageFit.Contain) | 60 | .objectFit(ImageFit.Contain) |
| 47 | .visibility(this.isWait ? Visibility.Visible : Visibility.None) | 61 | .visibility(this.isWait ? Visibility.Visible : Visibility.None) |
-
Please register or login to post a comment