Showing
5 changed files
with
87 additions
and
40 deletions
| @@ -295,15 +295,15 @@ export struct ENewspaperPageComponent { | @@ -295,15 +295,15 @@ export struct ENewspaperPageComponent { | ||
| 295 | .backgroundColor($r('app.color.color_80000000')) | 295 | .backgroundColor($r('app.color.color_80000000')) |
| 296 | .id('e_newspaper_container') | 296 | .id('e_newspaper_container') |
| 297 | 297 | ||
| 298 | - ENewspaperListDialog({ | ||
| 299 | - newspaperListBean: this.newspaperListBean, | ||
| 300 | - closeDialog: () => { | ||
| 301 | - this.isOpenListDialog = false | ||
| 302 | - } | ||
| 303 | - }) | ||
| 304 | - .visibility(this.isOpenListDialog ? Visibility.Visible : Visibility.None) | 298 | + if (this.isOpenListDialog) { |
| 299 | + ENewspaperListDialog({ | ||
| 300 | + newspaperListBean: this.newspaperListBean, | ||
| 301 | + closeDialog: () => { | ||
| 302 | + this.isOpenListDialog = false | ||
| 303 | + } | ||
| 304 | + }) | ||
| 305 | + } | ||
| 305 | } | 306 | } |
| 306 | - | ||
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | private async getNewspaperTime() { | 309 | private async getNewspaperTime() { |
| @@ -15,11 +15,15 @@ export struct ENewspaperListDialog { | @@ -15,11 +15,15 @@ export struct ENewspaperListDialog { | ||
| 15 | @Prop @Watch('updateRecordsData') newspaperListBean: NewspaperListBean = {} as NewspaperListBean | 15 | @Prop @Watch('updateRecordsData') newspaperListBean: NewspaperListBean = {} as NewspaperListBean |
| 16 | private listScroller: Scroller = new Scroller() | 16 | private listScroller: Scroller = new Scroller() |
| 17 | @State scrollOffset: number = 0 | 17 | @State scrollOffset: number = 0 |
| 18 | + @State isCurrentViewOpen: boolean = false | ||
| 18 | //文字版选择弹框 | 19 | //文字版选择弹框 |
| 19 | pageListDialogController: CustomDialogController = new CustomDialogController({ | 20 | pageListDialogController: CustomDialogController = new CustomDialogController({ |
| 20 | builder: ENewspaperPageDialog({ | 21 | builder: ENewspaperPageDialog({ |
| 21 | dialogType: 1, | 22 | dialogType: 1, |
| 22 | newspaperListBean: this.newspaperListBean, | 23 | newspaperListBean: this.newspaperListBean, |
| 24 | + dialogVisibility: (visibility: boolean) => { | ||
| 25 | + this.isCurrentViewOpen = !visibility | ||
| 26 | + } | ||
| 23 | }), | 27 | }), |
| 24 | alignment: DialogAlignment.TopStart, | 28 | alignment: DialogAlignment.TopStart, |
| 25 | offset: { dx: 0, dy: 224 }, | 29 | offset: { dx: 0, dy: 224 }, |
| @@ -37,10 +41,13 @@ export struct ENewspaperListDialog { | @@ -37,10 +41,13 @@ export struct ENewspaperListDialog { | ||
| 37 | let _scrollIndex = Number.parseInt(this.currentPageNum) | 41 | let _scrollIndex = Number.parseInt(this.currentPageNum) |
| 38 | console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "_scrollIndex:", _scrollIndex) | 42 | console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "_scrollIndex:", _scrollIndex) |
| 39 | let scrollIndexEnd = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex | 43 | let scrollIndexEnd = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex |
| 40 | - this.listScroller.scrollToIndex(scrollIndexEnd) | 44 | + if (!this.isCurrentViewOpen) { |
| 45 | + this.listScroller.scrollToIndex(scrollIndexEnd) | ||
| 46 | + } | ||
| 41 | } | 47 | } |
| 42 | 48 | ||
| 43 | aboutToAppear(): void { | 49 | aboutToAppear(): void { |
| 50 | + this.isCurrentViewOpen = true | ||
| 44 | console.log("ENewspaperListDialog-aboutToAppear", "currentPageNum:", this.currentPageNum) | 51 | console.log("ENewspaperListDialog-aboutToAppear", "currentPageNum:", this.currentPageNum) |
| 45 | let _scrollIndex = Number.parseInt(this.currentPageNum) | 52 | let _scrollIndex = Number.parseInt(this.currentPageNum) |
| 46 | console.log("ENewspaperListDialog-aboutToAppear", "_scrollIndex:", _scrollIndex) | 53 | console.log("ENewspaperListDialog-aboutToAppear", "_scrollIndex:", _scrollIndex) |
| @@ -52,6 +59,7 @@ export struct ENewspaperListDialog { | @@ -52,6 +59,7 @@ export struct ENewspaperListDialog { | ||
| 52 | // if (this.pageListDialogController) { | 59 | // if (this.pageListDialogController) { |
| 53 | // this.pageListDialogController = null | 60 | // this.pageListDialogController = null |
| 54 | // } | 61 | // } |
| 62 | + this.isCurrentViewOpen = false | ||
| 55 | } | 63 | } |
| 56 | 64 | ||
| 57 | build() { | 65 | build() { |
| @@ -228,19 +236,19 @@ export struct ENewspaperListDialog { | @@ -228,19 +236,19 @@ export struct ENewspaperListDialog { | ||
| 228 | bottom: 85 | 236 | bottom: 85 |
| 229 | }) | 237 | }) |
| 230 | .scrollBar(BarState.Off) | 238 | .scrollBar(BarState.Off) |
| 231 | - | 239 | + .edgeEffect(EdgeEffect.None) |
| 232 | .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { | 240 | .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => { |
| 233 | - // console.info('ENewspaperListDialog::first' + firstIndex) | ||
| 234 | - // console.info('ENewspaperListDialog::last' + lastIndex) | ||
| 235 | - // console.info('ENewspaperListDialog::center' + centerIndex) | 241 | + console.info('ENewspaperListDialog::first' + firstIndex) |
| 242 | + console.info('ENewspaperListDialog::last' + lastIndex) | ||
| 243 | + console.info('ENewspaperListDialog::center' + centerIndex) | ||
| 236 | // this.updateCurrentPageNum(firstIndex) | 244 | // this.updateCurrentPageNum(firstIndex) |
| 237 | // const tempIndex = this.findClassIndex(firstIndex) | 245 | // const tempIndex = this.findClassIndex(firstIndex) |
| 238 | - if (firstIndex !== centerIndex) { | ||
| 239 | - return | ||
| 240 | - } | 246 | + // if (firstIndex !== centerIndex) { |
| 247 | + // return | ||
| 248 | + // } | ||
| 241 | // console.info(`this.scrollOffset:` + this.scrollOffset) | 249 | // console.info(`this.scrollOffset:` + this.scrollOffset) |
| 242 | // if (this.scrollOffset == 0) { | 250 | // if (this.scrollOffset == 0) { |
| 243 | - this.currentPageNum = `${centerIndex < 9 ? '0' + (centerIndex + 1) : centerIndex + 1}` | 251 | + this.currentPageNum = `${firstIndex < 9 ? '0' + (firstIndex + 1) : firstIndex + 1}` |
| 244 | // } | 252 | // } |
| 245 | }) | 253 | }) |
| 246 | .onScroll((scrollOffset: number, scrollState: ScrollState) => { | 254 | .onScroll((scrollOffset: number, scrollState: ScrollState) => { |
| @@ -9,11 +9,24 @@ export struct ENewspaperPageDialog { | @@ -9,11 +9,24 @@ export struct ENewspaperPageDialog { | ||
| 9 | pageDialogController?: CustomDialogController | 9 | pageDialogController?: CustomDialogController |
| 10 | @Consume @Watch('onCurrentPageNumUpdated') currentPageNum: string | 10 | @Consume @Watch('onCurrentPageNumUpdated') currentPageNum: string |
| 11 | @Prop newspaperListBean: NewspaperListBean = {} as NewspaperListBean | 11 | @Prop newspaperListBean: NewspaperListBean = {} as NewspaperListBean |
| 12 | + public dialogVisibility?: (visibility: boolean) => void | ||
| 12 | 13 | ||
| 13 | onCurrentPageNumUpdated(): void { | 14 | onCurrentPageNumUpdated(): void { |
| 14 | console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum) | 15 | console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum) |
| 15 | } | 16 | } |
| 16 | 17 | ||
| 18 | + aboutToAppear(): void { | ||
| 19 | + if (this.dialogType == 1 && this.dialogVisibility) { | ||
| 20 | + this.dialogVisibility(true) | ||
| 21 | + } | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + aboutToDisappear(): void { | ||
| 25 | + if (this.dialogType == 1 && this.dialogVisibility) { | ||
| 26 | + this.dialogVisibility(false) | ||
| 27 | + } | ||
| 28 | + } | ||
| 29 | + | ||
| 17 | build() { | 30 | build() { |
| 18 | Column() { | 31 | Column() { |
| 19 | if (this.dialogType == 1) { | 32 | if (this.dialogType == 1) { |
| 1 | import { window } from '@kit.ArkUI' | 1 | import { window } from '@kit.ArkUI' |
| 2 | -import { NumberFormatterUtils, WindowModel } from 'wdKit/Index' | 2 | +import { NumberFormatterUtils, StringUtils, WindowModel } from 'wdKit/Index' |
| 3 | import { DateFormatUtil, WDPlayerController } from 'wdPlayer/Index' | 3 | import { DateFormatUtil, WDPlayerController } from 'wdPlayer/Index' |
| 4 | import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index' | 4 | import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index' |
| 5 | import { DisplayDirection } from 'wdConstant/Index' | 5 | import { DisplayDirection } from 'wdConstant/Index' |
| @@ -20,7 +20,8 @@ export struct PlayUIComponent { | @@ -20,7 +20,8 @@ export struct PlayUIComponent { | ||
| 20 | @Consume displayDirection: DisplayDirection | 20 | @Consume displayDirection: DisplayDirection |
| 21 | 21 | ||
| 22 | onChangeMenuVisible() { | 22 | onChangeMenuVisible() { |
| 23 | - if (!this.liveDetailsBean || !this.liveDetailsBean.liveInfo || this.liveDetailsBean?.liveInfo?.liveState === 'wait') { | 23 | + if (!this.liveDetailsBean || !this.liveDetailsBean.liveInfo || |
| 24 | + this.liveDetailsBean?.liveInfo?.liveState === 'wait') { | ||
| 24 | return | 25 | return |
| 25 | } | 26 | } |
| 26 | let time: number = 0 | 27 | let time: number = 0 |
| @@ -216,30 +217,38 @@ export struct PlayUIComponent { | @@ -216,30 +217,38 @@ export struct PlayUIComponent { | ||
| 216 | this.playOrPauseBtn() | 217 | this.playOrPauseBtn() |
| 217 | Blank() | 218 | Blank() |
| 218 | } else if (this.liveDetailsBean?.liveInfo?.liveState == 'end') { | 219 | } else if (this.liveDetailsBean?.liveInfo?.liveState == 'end') { |
| 219 | - this.playOrPauseBtn() | ||
| 220 | - Text(this.currentTime) | ||
| 221 | - .fontColor(Color.White) | ||
| 222 | - .fontWeight(600) | ||
| 223 | - .fontSize('12fp') | ||
| 224 | - .margin({ | ||
| 225 | - left: 16 | ||
| 226 | - }) | ||
| 227 | - this.playProgressView() | ||
| 228 | - Text(this.totalTime) | ||
| 229 | - .fontColor(Color.White) | ||
| 230 | - .fontWeight(600) | ||
| 231 | - .fontSize('12fp') | ||
| 232 | - .margin({ | ||
| 233 | - right: 16 | ||
| 234 | - }) | 220 | + if (StringUtils.isEmpty(this.liveDetailsBean?.liveInfo?.vlive[0]?.replayUri)) { |
| 221 | + Blank() | ||
| 222 | + } else { | ||
| 223 | + this.playOrPauseBtn() | ||
| 224 | + Text(this.currentTime) | ||
| 225 | + .fontColor(Color.White) | ||
| 226 | + .fontWeight(600) | ||
| 227 | + .fontSize('12fp') | ||
| 228 | + .margin({ | ||
| 229 | + left: 16 | ||
| 230 | + }) | ||
| 231 | + this.playProgressView() | ||
| 232 | + Text(this.totalTime) | ||
| 233 | + .fontColor(Color.White) | ||
| 234 | + .fontWeight(600) | ||
| 235 | + .fontSize('12fp') | ||
| 236 | + .margin({ | ||
| 237 | + right: 16 | ||
| 238 | + }) | ||
| 239 | + } | ||
| 235 | } | 240 | } |
| 236 | if (this.liveDetailsBean?.liveInfo?.liveState == 'running' | 241 | if (this.liveDetailsBean?.liveInfo?.liveState == 'running' |
| 237 | - || this.liveDetailsBean?.liveInfo?.liveState == 'end') { | 242 | + || (this.liveDetailsBean?.liveInfo?.liveState == 'end' && |
| 243 | + StringUtils.isNotEmpty(this.liveDetailsBean?.liveInfo?.vlive[0]?.replayUri)) | ||
| 244 | + ) { | ||
| 238 | Image($r('app.media.icon_live_player_full_screen')) | 245 | Image($r('app.media.icon_live_player_full_screen')) |
| 239 | .width(24) | 246 | .width(24) |
| 240 | .height(24) | 247 | .height(24) |
| 241 | .onClick(() => { | 248 | .onClick(() => { |
| 242 | - this.displayDirection = this.displayDirection == DisplayDirection.VERTICAL ? DisplayDirection.VIDEO_HORIZONTAL : DisplayDirection.VERTICAL | 249 | + this.displayDirection = |
| 250 | + this.displayDirection == DisplayDirection.VERTICAL ? DisplayDirection.VIDEO_HORIZONTAL : | ||
| 251 | + DisplayDirection.VERTICAL | ||
| 243 | WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ? | 252 | WindowModel.shared.setPreferredOrientation(this.displayDirection == DisplayDirection.VERTICAL ? |
| 244 | window.Orientation.PORTRAIT : | 253 | window.Orientation.PORTRAIT : |
| 245 | window.Orientation.LANDSCAPE_INVERTED) | 254 | window.Orientation.LANDSCAPE_INVERTED) |
| 1 | import { LiveDetailsBean } from 'wdBean/Index'; | 1 | import { LiveDetailsBean } from 'wdBean/Index'; |
| 2 | +import { StringUtils } 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 | ||
| @@ -8,7 +9,10 @@ export struct TopPlayComponent { | @@ -8,7 +9,10 @@ export struct TopPlayComponent { | ||
| 8 | @Consume @Watch('updateData') liveDetailsBean: LiveDetailsBean | 9 | @Consume @Watch('updateData') liveDetailsBean: LiveDetailsBean |
| 9 | playerController?: WDPlayerController | 10 | playerController?: WDPlayerController |
| 10 | @State imgUrl: string = '' | 11 | @State imgUrl: string = '' |
| 12 | + //未开始 | ||
| 11 | @State isWait: boolean = false | 13 | @State isWait: boolean = false |
| 14 | + //已结束直播 | ||
| 15 | + @State isEnd: boolean = false | ||
| 12 | 16 | ||
| 13 | aboutToAppear(): void { | 17 | aboutToAppear(): void { |
| 14 | if (this.playerController) { | 18 | if (this.playerController) { |
| @@ -24,6 +28,8 @@ export struct TopPlayComponent { | @@ -24,6 +28,8 @@ export struct TopPlayComponent { | ||
| 24 | this.imgUrl = this.liveDetailsBean.fullColumnImgUrls[0].url | 28 | this.imgUrl = this.liveDetailsBean.fullColumnImgUrls[0].url |
| 25 | } | 29 | } |
| 26 | this.isWait = this.liveDetailsBean?.liveInfo?.liveState == 'wait' | 30 | this.isWait = this.liveDetailsBean?.liveInfo?.liveState == 'wait' |
| 31 | + this.isEnd = this.liveDetailsBean?.liveInfo?.liveState === 'end' && | ||
| 32 | + StringUtils.isEmpty(this.liveDetailsBean?.liveInfo?.vlive[0]?.replayUri) | ||
| 27 | if (!this.isWait && this.liveDetailsBean.liveInfo && this.liveDetailsBean.liveInfo.vlive.length > 0) { | 33 | if (!this.isWait && this.liveDetailsBean.liveInfo && this.liveDetailsBean.liveInfo.vlive.length > 0) { |
| 28 | let playUrl = '' | 34 | let playUrl = '' |
| 29 | if (this.liveDetailsBean.liveInfo.liveState == 'running') { | 35 | if (this.liveDetailsBean.liveInfo.liveState == 'running') { |
| @@ -31,8 +37,10 @@ export struct TopPlayComponent { | @@ -31,8 +37,10 @@ export struct TopPlayComponent { | ||
| 31 | } else if (this.liveDetailsBean.liveInfo.liveState == 'end') { | 37 | } else if (this.liveDetailsBean.liveInfo.liveState == 'end') { |
| 32 | playUrl = this.liveDetailsBean.liveInfo.vlive[0].replayUri | 38 | playUrl = this.liveDetailsBean.liveInfo.vlive[0].replayUri |
| 33 | } | 39 | } |
| 34 | - this.playerController?.firstPlay(playUrl); | ||
| 35 | // this.playerController?.firstPlay('https://rmrbcmsonline.peopleapp.com/upload/rmh/video/mp4/202404/1713752415708fb81d0b8f137b.mp4'); | 40 | // this.playerController?.firstPlay('https://rmrbcmsonline.peopleapp.com/upload/rmh/video/mp4/202404/1713752415708fb81d0b8f137b.mp4'); |
| 41 | + if (StringUtils.isNotEmpty(playUrl)) { | ||
| 42 | + this.playerController?.firstPlay(playUrl); | ||
| 43 | + } | ||
| 36 | } | 44 | } |
| 37 | } | 45 | } |
| 38 | 46 | ||
| @@ -46,12 +54,21 @@ export struct TopPlayComponent { | @@ -46,12 +54,21 @@ export struct TopPlayComponent { | ||
| 46 | .height('100%') | 54 | .height('100%') |
| 47 | .width('100%') | 55 | .width('100%') |
| 48 | .visibility(this.isWait ? Visibility.None : Visibility.Visible) | 56 | .visibility(this.isWait ? Visibility.None : Visibility.Visible) |
| 49 | - Image(this.imgUrl) | 57 | + Image('') |
| 58 | + .backgroundImage(this.imgUrl) | ||
| 50 | .objectFit(ImageFit.Contain) | 59 | .objectFit(ImageFit.Contain) |
| 51 | - .visibility(this.isWait ? Visibility.Visible : Visibility.None) | 60 | + .visibility(this.isWait || this.isEnd ? Visibility.Visible : Visibility.None) |
| 61 | + .backdropBlur(this.isEnd ? 3 : 0) | ||
| 52 | PlayUIComponent({ playerController: this.playerController }) | 62 | PlayUIComponent({ playerController: this.playerController }) |
| 63 | + Text('直播已结束') | ||
| 64 | + .fontSize('20fp') | ||
| 65 | + .fontWeight(500) | ||
| 66 | + .fontColor(Color.White) | ||
| 67 | + .visibility(this.isEnd ? Visibility.Visible : | ||
| 68 | + Visibility.None) | ||
| 53 | } | 69 | } |
| 54 | .width('100%') | 70 | .width('100%') |
| 71 | + .alignSelf(ItemAlign.Center) | ||
| 55 | } | 72 | } |
| 56 | 73 | ||
| 57 | aboutToDisappear(): void { | 74 | aboutToDisappear(): void { |
-
Please register or login to post a comment