fix |> 4g网络环境,进入直播间, “正在使用非Wi-Fi网络,播放将产生流量费用” 蒙层未显示,看图
http://192.168.1.3:8080/zentao/bug-view-17108.html Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
Showing
4 changed files
with
129 additions
and
32 deletions
| @@ -49,28 +49,8 @@ export struct DetailPlayLivePage { | @@ -49,28 +49,8 @@ export struct DetailPlayLivePage { | ||
| 49 | @Provide banComment: boolean = true | 49 | @Provide banComment: boolean = true |
| 50 | @State isEnd: boolean = false | 50 | @State isEnd: boolean = false |
| 51 | @Consume liveDetailPageLogic: LiveDetailPageLogic | 51 | @Consume liveDetailPageLogic: LiveDetailPageLogic |
| 52 | - @State toastText: ResourceStr = "这是一个非Wi-Fi环境。请注意流量消耗" | ||
| 53 | @State topPlayHeight:number = this.getTopPlayHeight() | 52 | @State topPlayHeight:number = this.getTopPlayHeight() |
| 54 | @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm'; | 53 | @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm'; |
| 55 | - dialogToast: CustomDialogController = new CustomDialogController({ | ||
| 56 | - builder: CustomToast({ | ||
| 57 | - bgColor: 0xB3000000, | ||
| 58 | - opacityValue: 1, | ||
| 59 | - fontSizeValue: "25lpx", | ||
| 60 | - lineHeightValue: "36lpx", | ||
| 61 | - msg: this.toastText, | ||
| 62 | - marginTop:211/2+px2vp(this.topSafeHeight)-px2vp(84/2) | ||
| 63 | - }), | ||
| 64 | - autoCancel: false, | ||
| 65 | - alignment: DialogAlignment.Top, | ||
| 66 | - customStyle: true, | ||
| 67 | - maskColor: "#00000000" | ||
| 68 | - }) | ||
| 69 | - | ||
| 70 | - showToastTip(msg: ResourceStr) { | ||
| 71 | - this.toastText = msg | ||
| 72 | - this.dialogToast.open() | ||
| 73 | - } | ||
| 74 | 54 | ||
| 75 | async aboutToAppear(): Promise<void> { | 55 | async aboutToAppear(): Promise<void> { |
| 76 | Logger.info(TAG, `wyj-aboutToAppear`) | 56 | Logger.info(TAG, `wyj-aboutToAppear`) |
| @@ -86,13 +66,6 @@ export struct DetailPlayLivePage { | @@ -86,13 +66,6 @@ export struct DetailPlayLivePage { | ||
| 86 | }) | 66 | }) |
| 87 | this.getLiveDetails() | 67 | this.getLiveDetails() |
| 88 | this.getLiveRoomData() | 68 | this.getLiveRoomData() |
| 89 | - | ||
| 90 | - if (this.liveDetailPageLogic.dealOrShowToast()) { | ||
| 91 | - if(!await onlyWifiLoadVideo()){ | ||
| 92 | - this.showToastTip(this.toastText) | ||
| 93 | - } | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | this.configChatRoom() | 69 | this.configChatRoom() |
| 97 | } | 70 | } |
| 98 | 71 |
| @@ -94,15 +94,24 @@ export class LiveDetailPageLogic { | @@ -94,15 +94,24 @@ export class LiveDetailPageLogic { | ||
| 94 | return '' | 94 | return '' |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | - dealOrShowToast(): boolean { | 97 | + livingNeedShowNoWifiTip(): boolean { |
| 98 | + if (this.liveState == 'running') { | ||
| 99 | + if (this.contentDetailData.liveInfo.liveWay == 0) { ///直播视频 | ||
| 100 | + return true | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + return false | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + noLivingNeedShowNoWifiTip(): boolean { | ||
| 98 | if (this.liveState == 'wait') { | 107 | if (this.liveState == 'wait') { |
| 99 | if (this.contentDetailData.liveInfo | 108 | if (this.contentDetailData.liveInfo |
| 100 | && this.contentDetailData.liveInfo.previewUrl.length > 0 | 109 | && this.contentDetailData.liveInfo.previewUrl.length > 0 |
| 101 | && this.contentDetailData.liveInfo.previewType == 1) { ///预告视频 | 110 | && this.contentDetailData.liveInfo.previewType == 1) { ///预告视频 |
| 102 | - return true | 111 | + return true |
| 103 | } | 112 | } |
| 104 | } | 113 | } |
| 105 | - if (this.liveState == 'running') { | 114 | + if (this.liveState == 'end') { |
| 106 | if (this.contentDetailData.liveInfo.liveWay == 0) { ///直播视频 | 115 | if (this.contentDetailData.liveInfo.liveWay == 0) { ///直播视频 |
| 107 | return true | 116 | return true |
| 108 | } | 117 | } |
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/common/NoWifiTipComponent.ets
0 → 100644
| 1 | + | ||
| 2 | +@Component | ||
| 3 | +export struct NoWifiTipComponent { | ||
| 4 | + @State toastText: ResourceStr = "正在使用非Wi-Fi网络,播放将产生流量费用" | ||
| 5 | + | ||
| 6 | + onContinue?: () => void | ||
| 7 | + | ||
| 8 | + aboutToAppear(): void { | ||
| 9 | + | ||
| 10 | + } | ||
| 11 | + aboutToDisappear(): void { | ||
| 12 | + | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + build() { | ||
| 16 | + Row() { | ||
| 17 | + Column() { | ||
| 18 | + Column() { | ||
| 19 | + Text(this.toastText) | ||
| 20 | + .fontFamily('PingFang SC-Regular') | ||
| 21 | + .fontWeight(FontWeight.Regular) | ||
| 22 | + .fontColor('#FFFFFF') | ||
| 23 | + .fontSize(16) | ||
| 24 | + .lineHeight(24) | ||
| 25 | + .textAlign(TextAlign.Center) | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + Column() { | ||
| 29 | + Text("使用流量播放") | ||
| 30 | + .fontFamily('PingFang SC-Regular') | ||
| 31 | + .fontWeight(FontWeight.Regular) | ||
| 32 | + .fontColor(Color.White) | ||
| 33 | + .fontSize(14) | ||
| 34 | + .lineHeight(20) | ||
| 35 | + .textAlign(TextAlign.Center) | ||
| 36 | + .margin({ | ||
| 37 | + top: 5, | ||
| 38 | + bottom: 5, | ||
| 39 | + left: 8, | ||
| 40 | + right: 8 | ||
| 41 | + }) | ||
| 42 | + } | ||
| 43 | + .border({ width: 1, color: '#4DFFFFFF', radius: 4 }) | ||
| 44 | + .height(30) | ||
| 45 | + .alignItems(HorizontalAlign.Center) | ||
| 46 | + .justifyContent(FlexAlign.Center) | ||
| 47 | + .margin({ | ||
| 48 | + top: 16 | ||
| 49 | + }) | ||
| 50 | + .onClick(() => { | ||
| 51 | + if (this.onContinue) { | ||
| 52 | + this.onContinue() | ||
| 53 | + } | ||
| 54 | + }) | ||
| 55 | + } | ||
| 56 | + .width('100%') | ||
| 57 | + .height(64) | ||
| 58 | + } | ||
| 59 | + .width('100%') | ||
| 60 | + .height('100%') | ||
| 61 | + .alignItems(VerticalAlign.Center) | ||
| 62 | + .justifyContent(FlexAlign.Center) | ||
| 63 | + .backgroundColor('#222222') | ||
| 64 | + .opacity(0.7) | ||
| 65 | + } | ||
| 66 | +} |
| 1 | import { ContentDetailDTO, LiveRoomItemBean } from 'wdBean/Index'; | 1 | import { ContentDetailDTO, LiveRoomItemBean } from 'wdBean/Index'; |
| 2 | -import { Logger, StringUtils, WindowModel } from 'wdKit/Index'; | 2 | +import { CustomToast, Logger, StringUtils, WindowModel } 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'; |
| @@ -8,6 +8,8 @@ import { LiveDetailPageLogic } from '../../../viewModel/LiveDetailPageLogic'; | @@ -8,6 +8,8 @@ import { LiveDetailPageLogic } from '../../../viewModel/LiveDetailPageLogic'; | ||
| 8 | import { LiveEmptyComponent, WDLiveViewDefaultType } from 'wdComponent/Index'; | 8 | import { LiveEmptyComponent, WDLiveViewDefaultType } from 'wdComponent/Index'; |
| 9 | import { LiveMessageOptType } from 'wdBean/src/main/ets/bean/live/LiveRoomBean'; | 9 | import { LiveMessageOptType } from 'wdBean/src/main/ets/bean/live/LiveRoomBean'; |
| 10 | import { window } from '@kit.ArkUI'; | 10 | import { window } from '@kit.ArkUI'; |
| 11 | +import { onlyWifiLoadVideo } from 'wdComponent/src/main/ets/utils/lazyloadImg'; | ||
| 12 | +import { NoWifiTipComponent } from '../../common/NoWifiTipComponent'; | ||
| 11 | 13 | ||
| 12 | const TAG: string = 'TopPlayComponent' | 14 | const TAG: string = 'TopPlayComponent' |
| 13 | 15 | ||
| @@ -39,6 +41,7 @@ export struct TopPlayComponent { | @@ -39,6 +41,7 @@ export struct TopPlayComponent { | ||
| 39 | @Consume liveDetailPageLogic: LiveDetailPageLogic | 41 | @Consume liveDetailPageLogic: LiveDetailPageLogic |
| 40 | @Consume @Watch('pageShowChange') pageShow: number | 42 | @Consume @Watch('pageShowChange') pageShow: number |
| 41 | @Consume @Watch('pageHideChange') pageHide: number | 43 | @Consume @Watch('pageHideChange') pageHide: number |
| 44 | + @Consume topSafeHeight: number | ||
| 42 | init: boolean = false | 45 | init: boolean = false |
| 43 | @Prop @Watch("liveIMControlMessageChange") lastLiveControl: LiveRoomItemBean = {} as LiveRoomItemBean // IM 控制消息 | 46 | @Prop @Watch("liveIMControlMessageChange") lastLiveControl: LiveRoomItemBean = {} as LiveRoomItemBean // IM 控制消息 |
| 44 | ///是否是手动点击暂停,手动暂停的,页面重新出现时,不自动恢复播放 | 47 | ///是否是手动点击暂停,手动暂停的,页面重新出现时,不自动恢复播放 |
| @@ -48,6 +51,9 @@ export struct TopPlayComponent { | @@ -48,6 +51,9 @@ export struct TopPlayComponent { | ||
| 48 | @State isZDP: boolean = false // 是否折叠屏 默认false | 51 | @State isZDP: boolean = false // 是否折叠屏 默认false |
| 49 | @State windowWidth: number = AppStorage.get<number>('windowWidth') || 0 | 52 | @State windowWidth: number = AppStorage.get<number>('windowWidth') || 0 |
| 50 | 53 | ||
| 54 | + @State showNoWifiTip: boolean = false // 直播预告和直播回放 | ||
| 55 | + livingDialogToast?: CustomDialogController // 直播中 | ||
| 56 | + | ||
| 51 | pageShowChange() { | 57 | pageShowChange() { |
| 52 | if (this.manualClickPauseOrPlay) { | 58 | if (this.manualClickPauseOrPlay) { |
| 53 | return | 59 | return |
| @@ -60,7 +66,7 @@ export struct TopPlayComponent { | @@ -60,7 +66,7 @@ export struct TopPlayComponent { | ||
| 60 | this.playerController?.pause() | 66 | this.playerController?.pause() |
| 61 | } | 67 | } |
| 62 | 68 | ||
| 63 | - aboutToAppear(): void { | 69 | + aboutToAppear() { |
| 64 | if (this.playerController) { | 70 | if (this.playerController) { |
| 65 | 71 | ||
| 66 | this.playerController.onCanplay = () => { | 72 | this.playerController.onCanplay = () => { |
| @@ -85,6 +91,12 @@ export struct TopPlayComponent { | @@ -85,6 +91,12 @@ export struct TopPlayComponent { | ||
| 85 | } | 91 | } |
| 86 | 92 | ||
| 87 | } | 93 | } |
| 94 | + | ||
| 95 | + this.playerController.onFirstFrameDisplay = () => { | ||
| 96 | + if (this.showNoWifiTip) { | ||
| 97 | + this.playerController?.pause() | ||
| 98 | + } | ||
| 99 | + } | ||
| 88 | } | 100 | } |
| 89 | this.updateData() | 101 | this.updateData() |
| 90 | 102 | ||
| @@ -94,6 +106,33 @@ export struct TopPlayComponent { | @@ -94,6 +106,33 @@ export struct TopPlayComponent { | ||
| 94 | // 2000折叠屏 TODO DeviceUtil 方法完善了换判断条件 | 106 | // 2000折叠屏 TODO DeviceUtil 方法完善了换判断条件 |
| 95 | this.isZDP = this.screenWidth > 2000 ? true : false | 107 | this.isZDP = this.screenWidth > 2000 ? true : false |
| 96 | this.resizeWindow() | 108 | this.resizeWindow() |
| 109 | + | ||
| 110 | + if (this.liveDetailPageLogic.livingNeedShowNoWifiTip()) { | ||
| 111 | + this.livingDialogToast = new CustomDialogController({ | ||
| 112 | + builder: CustomToast({ | ||
| 113 | + bgColor: 0xB3000000, | ||
| 114 | + opacityValue: 1, | ||
| 115 | + fontSizeValue: "25lpx", | ||
| 116 | + lineHeightValue: "36lpx", | ||
| 117 | + msg: "正在使用非Wi-Fi网络,播放将产生流量费用", | ||
| 118 | + marginTop:211/2+px2vp(this.topSafeHeight)-px2vp(84/2) | ||
| 119 | + }), | ||
| 120 | + autoCancel: false, | ||
| 121 | + alignment: DialogAlignment.Top, | ||
| 122 | + customStyle: true, | ||
| 123 | + maskColor: "#00000000" | ||
| 124 | + }) | ||
| 125 | + this.livingDialogToast.open() | ||
| 126 | + } else if (this.liveDetailPageLogic.noLivingNeedShowNoWifiTip()) { | ||
| 127 | + onlyWifiLoadVideo().then((onlyWifiLoadVideo) => { | ||
| 128 | + if (!onlyWifiLoadVideo) { | ||
| 129 | + this.showNoWifiTip = true | ||
| 130 | + if (this.playerController?.getStatus() == PlayerConstants.STATUS_START) { | ||
| 131 | + this.playerController?.pause() | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + }) | ||
| 135 | + } | ||
| 97 | } | 136 | } |
| 98 | 137 | ||
| 99 | resizeWindow() { | 138 | resizeWindow() { |
| @@ -344,6 +383,16 @@ export struct TopPlayComponent { | @@ -344,6 +383,16 @@ export struct TopPlayComponent { | ||
| 344 | Visibility.None) | 383 | Visibility.None) |
| 345 | .margin({top:40}) | 384 | .margin({top:40}) |
| 346 | 385 | ||
| 386 | + if (this.showNoWifiTip) { | ||
| 387 | + NoWifiTipComponent({ | ||
| 388 | + onContinue: () => { | ||
| 389 | + this.showNoWifiTip = false | ||
| 390 | + if (this.playerController?.getStatus() == PlayerConstants.STATUS_PAUSE) { | ||
| 391 | + this.playerController?.play() | ||
| 392 | + } | ||
| 393 | + } | ||
| 394 | + }) | ||
| 395 | + } | ||
| 347 | } | 396 | } |
| 348 | .width('100%') | 397 | .width('100%') |
| 349 | .alignSelf(ItemAlign.Center) | 398 | .alignSelf(ItemAlign.Center) |
-
Please register or login to post a comment