Showing
10 changed files
with
152 additions
and
40 deletions
| @@ -441,7 +441,7 @@ export struct PaperSingleColumn999CardView { | @@ -441,7 +441,7 @@ export struct PaperSingleColumn999CardView { | ||
| 441 | Stack({ alignContent: Alignment.BottomEnd }) { | 441 | Stack({ alignContent: Alignment.BottomEnd }) { |
| 442 | Image(this.item?.coverUrl) | 442 | Image(this.item?.coverUrl) |
| 443 | .borderRadius(5) | 443 | .borderRadius(5) |
| 444 | - .objectFit(ImageFit.Fill) | 444 | + .objectFit(ImageFit.Cover) |
| 445 | .aspectRatio(16 / 10) ///图片设计比例 | 445 | .aspectRatio(16 / 10) ///图片设计比例 |
| 446 | .padding({ top: 10 }) | 446 | .padding({ top: 10 }) |
| 447 | //视频 | 447 | //视频 |
| @@ -14,9 +14,6 @@ export class AudioSuspensionModel { | @@ -14,9 +14,6 @@ export class AudioSuspensionModel { | ||
| 14 | public floatWindowClass: SubscribedAbstractProperty<window.Window> = AppStorage.link<window.Window>('floatWindowClass') | 14 | public floatWindowClass: SubscribedAbstractProperty<window.Window> = AppStorage.link<window.Window>('floatWindowClass') |
| 15 | public srcTitle: string = '' | 15 | public srcTitle: string = '' |
| 16 | private url: string = '' | 16 | private url: string = '' |
| 17 | - private expandWidth: number = vp2px(243) | ||
| 18 | - private expandHeight: number = vp2px(60) | ||
| 19 | - private initMoveX = vp2px(12) | ||
| 20 | // 窗口是否最小化 | 17 | // 窗口是否最小化 |
| 21 | private isMinimize: SubscribedAbstractProperty<boolean> = AppStorage.link<boolean>('isMinimize') | 18 | private isMinimize: SubscribedAbstractProperty<boolean> = AppStorage.link<boolean>('isMinimize') |
| 22 | constructor() { | 19 | constructor() { |
| @@ -51,8 +48,10 @@ export class AudioSuspensionModel { | @@ -51,8 +48,10 @@ export class AudioSuspensionModel { | ||
| 51 | if (this.isMinimize?.get()) { | 48 | if (this.isMinimize?.get()) { |
| 52 | EmitterUtils.sendEvent(EmitterEventId.AUDIO_WINDOW_EXPAND, 1) | 49 | EmitterUtils.sendEvent(EmitterEventId.AUDIO_WINDOW_EXPAND, 1) |
| 53 | AppStorage.setOrCreate('isMinimize', false); | 50 | AppStorage.setOrCreate('isMinimize', false); |
| 51 | + this.playerController.get().resetPlay() | ||
| 52 | + } else { | ||
| 53 | + this.playerController.get().switchPlayOrPause() | ||
| 54 | } | 54 | } |
| 55 | - this.playerController.get().switchPlayOrPause() | ||
| 56 | } else { | 55 | } else { |
| 57 | this.url = url | 56 | this.url = url |
| 58 | this.playerController.get().firstPlay(url) | 57 | this.playerController.get().firstPlay(url) |
| @@ -100,16 +99,6 @@ export class AudioSuspensionModel { | @@ -100,16 +99,6 @@ export class AudioSuspensionModel { | ||
| 100 | console.info(TAG, 'floatWindowClass Succeeded in changing the window size.'); | 99 | console.info(TAG, 'floatWindowClass Succeeded in changing the window size.'); |
| 101 | }); | 100 | }); |
| 102 | } | 101 | } |
| 103 | - public moveWindow(y: number) { | ||
| 104 | - this.floatWindowClass.get().moveWindowTo(this.initMoveX, vp2px(y), (err: BusinessError) => { | ||
| 105 | - let errCode: number = err.code; | ||
| 106 | - if (errCode) { | ||
| 107 | - console.error('floatWindowClass Failed to move the window. Cause:' + JSON.stringify(err)); | ||
| 108 | - return; | ||
| 109 | - } | ||
| 110 | - console.info('floatWindowClass Succeeded in moving the window.'); | ||
| 111 | - }); | ||
| 112 | - } | ||
| 113 | 102 | ||
| 114 | // 隐藏悬浮窗 | 103 | // 隐藏悬浮窗 |
| 115 | public minimize() { | 104 | public minimize() { |
| @@ -7,12 +7,15 @@ import { ContentDetailDTO, LiveRoomDataBean } from 'wdBean/Index'; | @@ -7,12 +7,15 @@ import { ContentDetailDTO, LiveRoomDataBean } from 'wdBean/Index'; | ||
| 7 | import { DisplayDirection } from 'wdConstant/Index'; | 7 | import { DisplayDirection } from 'wdConstant/Index'; |
| 8 | import { LiveFollowComponent, LottieView } from 'wdComponent/Index'; | 8 | import { LiveFollowComponent, LottieView } from 'wdComponent/Index'; |
| 9 | import { WDShare } from 'wdShare/Index'; | 9 | import { WDShare } from 'wdShare/Index'; |
| 10 | +import { faceDetector } from '@kit.CoreVisionKit'; | ||
| 11 | + | ||
| 10 | //直播间播放器上层覆盖物 | 12 | //直播间播放器上层覆盖物 |
| 11 | @Component | 13 | @Component |
| 12 | export struct PlayUIComponent { | 14 | export struct PlayUIComponent { |
| 13 | playerController?: WDAliPlayerController; | 15 | playerController?: WDAliPlayerController; |
| 14 | //菜单键是否可见 | 16 | //菜单键是否可见 |
| 15 | @State @Watch('onChangeMenuVisible') isMenuVisible: boolean = true | 17 | @State @Watch('onChangeMenuVisible') isMenuVisible: boolean = true |
| 18 | + private ispause:boolean = false | ||
| 16 | @Consume contentDetailData: ContentDetailDTO | 19 | @Consume contentDetailData: ContentDetailDTO |
| 17 | @Consume liveRoomDataBean: LiveRoomDataBean | 20 | @Consume liveRoomDataBean: LiveRoomDataBean |
| 18 | @State currentTime: string = '' | 21 | @State currentTime: string = '' |
| @@ -35,8 +38,11 @@ export struct PlayUIComponent { | @@ -35,8 +38,11 @@ export struct PlayUIComponent { | ||
| 35 | let time: number = 0 | 38 | let time: number = 0 |
| 36 | if (this.isMenuVisible) { | 39 | if (this.isMenuVisible) { |
| 37 | setTimeout(() => { | 40 | setTimeout(() => { |
| 41 | + if(this.ispause){ | ||
| 42 | + return | ||
| 43 | + } | ||
| 38 | this.isMenuVisible = false | 44 | this.isMenuVisible = false |
| 39 | - }, 5 * 1000) | 45 | + }, 4 * 1000) |
| 40 | } else { | 46 | } else { |
| 41 | clearTimeout(time) | 47 | clearTimeout(time) |
| 42 | } | 48 | } |
| @@ -46,6 +52,16 @@ export struct PlayUIComponent { | @@ -46,6 +52,16 @@ export struct PlayUIComponent { | ||
| 46 | this.onChangeMenuVisible() | 52 | this.onChangeMenuVisible() |
| 47 | 53 | ||
| 48 | this.initPlayerSet() | 54 | this.initPlayerSet() |
| 55 | + if(this.playerController){ | ||
| 56 | + this.playerController.onStatusChangeForPlayUIComponent = (status: number) => { | ||
| 57 | + if(1 == status){ | ||
| 58 | + this.ispause = false | ||
| 59 | + this.isMenuVisible = false | ||
| 60 | + }else if(2 == status){ | ||
| 61 | + this.ispause = true | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + } | ||
| 49 | } | 65 | } |
| 50 | 66 | ||
| 51 | aboutToDisappear(): void { | 67 | aboutToDisappear(): void { |
| @@ -234,7 +250,7 @@ export struct PlayUIComponent { | @@ -234,7 +250,7 @@ export struct PlayUIComponent { | ||
| 234 | //回看 | 250 | //回看 |
| 235 | else if (this.contentDetailData.liveInfo?.liveState == 'end') { | 251 | else if (this.contentDetailData.liveInfo?.liveState == 'end') { |
| 236 | Row() { | 252 | Row() { |
| 237 | - Text('回看') | 253 | + Text(StringUtils.isEmpty(this.liveUrl)?'已结束':'回看') |
| 238 | .fontSize('11vp') | 254 | .fontSize('11vp') |
| 239 | .fontWeight(400) | 255 | .fontWeight(400) |
| 240 | .fontColor(Color.White) | 256 | .fontColor(Color.White) |
| @@ -271,6 +287,9 @@ export struct PlayUIComponent { | @@ -271,6 +287,9 @@ export struct PlayUIComponent { | ||
| 271 | if (this.contentDetailData?.liveInfo?.liveState === 'wait') { | 287 | if (this.contentDetailData?.liveInfo?.liveState === 'wait') { |
| 272 | return | 288 | return |
| 273 | } | 289 | } |
| 290 | + if(this.ispause){ | ||
| 291 | + return | ||
| 292 | + } | ||
| 274 | this.isMenuVisible = !this.isMenuVisible | 293 | this.isMenuVisible = !this.isMenuVisible |
| 275 | }) | 294 | }) |
| 276 | } | 295 | } |
| @@ -10,6 +10,8 @@ import { window } from '@kit.ArkUI'; | @@ -10,6 +10,8 @@ import { window } from '@kit.ArkUI'; | ||
| 10 | import { EmptyComponent } from 'wdComponent/Index'; | 10 | import { EmptyComponent } from 'wdComponent/Index'; |
| 11 | import { DateTimeUtils } from 'wdKit/Index'; | 11 | import { DateTimeUtils } from 'wdKit/Index'; |
| 12 | import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index'; | 12 | import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index'; |
| 13 | +import { AudioSuspensionModel } from 'wdComponent' | ||
| 14 | +import { BusinessError } from '@kit.BasicServicesKit'; | ||
| 13 | 15 | ||
| 14 | const storage = LocalStorage.getShared(); | 16 | const storage = LocalStorage.getShared(); |
| 15 | const TAG = 'DetailVideoListPage' | 17 | const TAG = 'DetailVideoListPage' |
| @@ -42,6 +44,8 @@ export struct DetailVideoListPage { | @@ -42,6 +44,8 @@ export struct DetailVideoListPage { | ||
| 42 | pageHideTime:number = 0; | 44 | pageHideTime:number = 0; |
| 43 | @Provide onlyWifiLoadVideo: boolean = false | 45 | @Provide onlyWifiLoadVideo: boolean = false |
| 44 | @Provide toastTextVisible: boolean = false | 46 | @Provide toastTextVisible: boolean = false |
| 47 | + private AudioSuspension = new AudioSuspensionModel() | ||
| 48 | + @State isShowAudioCom: boolean = false | ||
| 45 | 49 | ||
| 46 | async aboutToAppear(): Promise<void> { | 50 | async aboutToAppear(): Promise<void> { |
| 47 | // 注册监听网络连接 | 51 | // 注册监听网络连接 |
| @@ -80,6 +84,21 @@ export struct DetailVideoListPage { | @@ -80,6 +84,21 @@ export struct DetailVideoListPage { | ||
| 80 | this.openFullScreen() | 84 | this.openFullScreen() |
| 81 | 85 | ||
| 82 | this.pageShowTime = DateTimeUtils.getTimeStamp() | 86 | this.pageShowTime = DateTimeUtils.getTimeStamp() |
| 87 | + | ||
| 88 | + // 判断当前窗口是否已显示,使用callback异步回调。 | ||
| 89 | + this.AudioSuspension.floatWindowClass.get().isShowing((err: BusinessError, data) => { | ||
| 90 | + const errCode: number = err.code; | ||
| 91 | + if (errCode) { | ||
| 92 | + console.error(TAG, 'Failed window is showing Cause:' + JSON.stringify(err)); | ||
| 93 | + return; | ||
| 94 | + } | ||
| 95 | + console.info(TAG, 'window is showing: ' + JSON.stringify(data)); | ||
| 96 | + if(data) { | ||
| 97 | + this.isShowAudioCom = true | ||
| 98 | + this.AudioSuspension.playerController.get()?.pause(); | ||
| 99 | + this.AudioSuspension.minimize() | ||
| 100 | + } | ||
| 101 | + }); | ||
| 83 | } | 102 | } |
| 84 | 103 | ||
| 85 | onPageHide(): void { | 104 | onPageHide(): void { |
| @@ -91,6 +110,13 @@ export struct DetailVideoListPage { | @@ -91,6 +110,13 @@ export struct DetailVideoListPage { | ||
| 91 | let duration = 0 | 110 | let duration = 0 |
| 92 | duration = Math.floor((this.pageHideTime - this.pageShowTime)/1000) | 111 | duration = Math.floor((this.pageHideTime - this.pageShowTime)/1000) |
| 93 | TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Customer_Personal,TrackConstants.PageName.Customer_Personal,duration) | 112 | TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Customer_Personal,TrackConstants.PageName.Customer_Personal,duration) |
| 113 | + | ||
| 114 | + console.info(TAG, 'this.isShowAudioCom: ' + this.isShowAudioCom); | ||
| 115 | + if (this.isShowAudioCom) { | ||
| 116 | + this.AudioSuspension.showWindow() | ||
| 117 | + this.AudioSuspension.playerController.get()?.play(); | ||
| 118 | + this.isShowAudioCom = false | ||
| 119 | + } | ||
| 94 | } | 120 | } |
| 95 | 121 | ||
| 96 | /** | 122 | /** |
| @@ -60,6 +60,7 @@ export class WDAliPlayerController { | @@ -60,6 +60,7 @@ export class WDAliPlayerController { | ||
| 60 | // 准备完成,决定是否播放回调。如果不实现,则自动播放 | 60 | // 准备完成,决定是否播放回调。如果不实现,则自动播放 |
| 61 | public onCanplay?: () => void; | 61 | public onCanplay?: () => void; |
| 62 | public onStatusChange?: (status: number) => void; | 62 | public onStatusChange?: (status: number) => void; |
| 63 | + public onStatusChangeForPlayUIComponent?: (status: number) => void; | ||
| 63 | public onFirstFrameDisplay?: () => void | 64 | public onFirstFrameDisplay?: () => void |
| 64 | // 埋点字段 | 65 | // 埋点字段 |
| 65 | private creatStartTime: number = 0; //开始加载时间 | 66 | private creatStartTime: number = 0; //开始加载时间 |
| @@ -513,6 +514,9 @@ export class WDAliPlayerController { | @@ -513,6 +514,9 @@ export class WDAliPlayerController { | ||
| 513 | if (this.onStatusChange) { | 514 | if (this.onStatusChange) { |
| 514 | this.onStatusChange(this.status) | 515 | this.onStatusChange(this.status) |
| 515 | } | 516 | } |
| 517 | + if(this.onStatusChangeForPlayUIComponent){ | ||
| 518 | + this.onStatusChangeForPlayUIComponent(this.status) | ||
| 519 | + } | ||
| 516 | 520 | ||
| 517 | } | 521 | } |
| 518 | 522 |
| @@ -360,6 +360,12 @@ export class WDPlayerController { | @@ -360,6 +360,12 @@ export class WDPlayerController { | ||
| 360 | // this.progressThis.progressVal = 0; | 360 | // this.progressThis.progressVal = 0; |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | + resetPlay() { | ||
| 364 | + this.duration = 0; | ||
| 365 | + this.url = this.avPlayer?.url || ''; | ||
| 366 | + this.avPlayer?.reset(); | ||
| 367 | + } | ||
| 368 | + | ||
| 363 | onVolumeActionStart(event: GestureEvent) { | 369 | onVolumeActionStart(event: GestureEvent) { |
| 364 | this.positionY = event.offsetY; | 370 | this.positionY = event.offsetY; |
| 365 | } | 371 | } |
| @@ -107,8 +107,18 @@ export default class EntryAbility extends UIAbility { | @@ -107,8 +107,18 @@ export default class EntryAbility extends UIAbility { | ||
| 107 | ; | 107 | ; |
| 108 | }); | 108 | }); |
| 109 | 109 | ||
| 110 | - floatWindowClass.on('windowEvent', (data) => { | ||
| 111 | - EmitterUtils.sendEvent(EmitterEventId.AUDIO_WINDOW_TYPE, data) | 110 | + floatWindowClass.setWindowFocusable(false, (err: BusinessError) => { |
| 111 | + const errCode: number = err.code; | ||
| 112 | + if (errCode) { | ||
| 113 | + console.error(`Failed to set the window to be focusable. Cause code: ${err.code}, message: ${err.message}`); | ||
| 114 | + return; | ||
| 115 | + } | ||
| 116 | + console.info('Succeeded in setting the window to be focusable.'); | ||
| 117 | + }); | ||
| 118 | + | ||
| 119 | + floatWindowClass.on('touchOutside', () => { | ||
| 120 | + console.info('touchOutside'); | ||
| 121 | + EmitterUtils.sendEvent(EmitterEventId.AUDIO_WINDOW_TYPE, 3) | ||
| 112 | }); | 122 | }); |
| 113 | 123 | ||
| 114 | }); | 124 | }); |
| @@ -7,6 +7,11 @@ import { LottieView } from 'wdComponent/Index' | @@ -7,6 +7,11 @@ import { LottieView } from 'wdComponent/Index' | ||
| 7 | 7 | ||
| 8 | const TAG = 'AudioSuspensionModel' | 8 | const TAG = 'AudioSuspensionModel' |
| 9 | 9 | ||
| 10 | +interface Position { | ||
| 11 | + x: number, | ||
| 12 | + y: number | ||
| 13 | +} | ||
| 14 | + | ||
| 10 | @Entry | 15 | @Entry |
| 11 | @Component | 16 | @Component |
| 12 | struct Index { | 17 | struct Index { |
| @@ -17,17 +22,21 @@ struct Index { | @@ -17,17 +22,21 @@ struct Index { | ||
| 17 | @State progressVal: number = 0; | 22 | @State progressVal: number = 0; |
| 18 | @State currentStatus: number | string |undefined = 0; | 23 | @State currentStatus: number | string |undefined = 0; |
| 19 | @State isExpand: boolean = true; | 24 | @State isExpand: boolean = true; |
| 20 | - @State moveY: number = 604; | ||
| 21 | private expandWidth: number = vp2px(243) | 25 | private expandWidth: number = vp2px(243) |
| 22 | private expandHeight: number = vp2px(60) | 26 | private expandHeight: number = vp2px(60) |
| 23 | private foldWidth: number = vp2px(60) | 27 | private foldWidth: number = vp2px(60) |
| 24 | private foldHeight: number = vp2px(60) | 28 | private foldHeight: number = vp2px(60) |
| 25 | - bottomSafeHeight: number = 720 // 悬浮窗底部滑动限制 | ||
| 26 | - topSafeHeight: number = 94 // 悬浮窗顶部滑动限制 | 29 | + bottomSafeHeight: number = vp2px(720) // 悬浮窗底部滑动限制 |
| 30 | + topSafeHeight: number = vp2px(94) // 悬浮窗顶部滑动限制 | ||
| 27 | @State name: string = 'audio_status_wait'; | 31 | @State name: string = 'audio_status_wait'; |
| 32 | + @State @Watch("moveWindow") windowPosition: Position = { x: vp2px(12), y: vp2px(576) }; | ||
| 33 | + private panOption: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.All }); | ||
| 34 | + private subWindow:window.Window | null = null | ||
| 28 | 35 | ||
| 29 | async aboutToAppear() { | 36 | async aboutToAppear() { |
| 30 | - window.findWindow("subWindow").setWindowBackgroundColor("#00000000") | 37 | + this.subWindow = window.findWindow("subWindow") |
| 38 | + this.subWindow.setWindowBackgroundColor("#00000000") | ||
| 39 | + | ||
| 31 | this.AudioSuspension.playerController.get().onTimeUpdate = (position, duration) => { | 40 | this.AudioSuspension.playerController.get().onTimeUpdate = (position, duration) => { |
| 32 | this.currentTime = DateFormatUtil.convertMillisecondsToMinutesSeconds(position); | 41 | this.currentTime = DateFormatUtil.convertMillisecondsToMinutesSeconds(position); |
| 33 | this.totalTime = DateFormatUtil.convertMillisecondsToMinutesSeconds(duration); | 42 | this.totalTime = DateFormatUtil.convertMillisecondsToMinutesSeconds(duration); |
| @@ -69,6 +78,14 @@ struct Index { | @@ -69,6 +78,14 @@ struct Index { | ||
| 69 | 78 | ||
| 70 | } | 79 | } |
| 71 | 80 | ||
| 81 | + moveWindow() { | ||
| 82 | + if (this.subWindow == null) { | ||
| 83 | + console.info('Faild in destroying the window.'); | ||
| 84 | + } else { | ||
| 85 | + this.subWindow.moveWindowTo(this.windowPosition.x, this.windowPosition.y); | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + | ||
| 72 | onPageHide() { | 89 | onPageHide() { |
| 73 | // this.status = PlayerConstants.STATUS_PAUSE; | 90 | // this.status = PlayerConstants.STATUS_PAUSE; |
| 74 | this.AudioSuspension.playerController.get()?.pause(); | 91 | this.AudioSuspension.playerController.get()?.pause(); |
| @@ -126,8 +143,14 @@ struct Index { | @@ -126,8 +143,14 @@ struct Index { | ||
| 126 | .height(3) | 143 | .height(3) |
| 127 | .margin({ top: 7 }) | 144 | .margin({ top: 7 }) |
| 128 | } | 145 | } |
| 129 | - .width("100%") | ||
| 130 | - .height("100%") | 146 | + .padding({ |
| 147 | + top: 10, | ||
| 148 | + bottom: 10, | ||
| 149 | + left: 10, | ||
| 150 | + right: 0 | ||
| 151 | + }) | ||
| 152 | + .width(243) | ||
| 153 | + .height(60) | ||
| 131 | .justifyContent(FlexAlign.Start) | 154 | .justifyContent(FlexAlign.Start) |
| 132 | 155 | ||
| 133 | Row() { | 156 | Row() { |
| @@ -145,8 +168,8 @@ struct Index { | @@ -145,8 +168,8 @@ struct Index { | ||
| 145 | })) | 168 | })) |
| 146 | Image($r("app.media.icon_audio_close")) | 169 | Image($r("app.media.icon_audio_close")) |
| 147 | .objectFit(ImageFit.Contain) | 170 | .objectFit(ImageFit.Contain) |
| 148 | - .width(24) | ||
| 149 | - .height(24) | 171 | + .width(32) |
| 172 | + .height(32) | ||
| 150 | .gesture( | 173 | .gesture( |
| 151 | TapGesture() | 174 | TapGesture() |
| 152 | .onAction((event: GestureEvent) => { | 175 | .onAction((event: GestureEvent) => { |
| @@ -183,21 +206,23 @@ struct Index { | @@ -183,21 +206,23 @@ struct Index { | ||
| 183 | this.isExpand = true | 206 | this.isExpand = true |
| 184 | this.AudioSuspension.resizeWindow(this.expandWidth, this.expandHeight) | 207 | this.AudioSuspension.resizeWindow(this.expandWidth, this.expandHeight) |
| 185 | }), | 208 | }), |
| 186 | - PanGesture({ | ||
| 187 | - fingers: 1, | ||
| 188 | - direction: PanDirection.Vertical, | ||
| 189 | - distance: 0 | ||
| 190 | - }) | 209 | + PanGesture(this.panOption) |
| 210 | + //手势识别成功回调。 | ||
| 211 | + .onActionStart((event: GestureEvent) => { | ||
| 212 | + console.info('Pan start'); | ||
| 213 | + }) | ||
| 214 | + // 手势移动过程中回调。发生拖拽时,获取到触摸点的位置,并将位置信息传递给windowPosition | ||
| 191 | .onActionUpdate((event: GestureEvent) => { | 215 | .onActionUpdate((event: GestureEvent) => { |
| 192 | - let newY = Math.ceil(this.moveY + event.offsetY); | ||
| 193 | - this.moveY = Math.min(Math.max(newY, this.topSafeHeight), this.bottomSafeHeight); | ||
| 194 | - // console.log(TAG,'this.moveY', this.moveY) | ||
| 195 | - this.AudioSuspension.moveWindow(this.moveY) | 216 | + // this.windowPosition.x += event.offsetX; |
| 217 | + let newY = this.windowPosition.y + event.offsetY; | ||
| 218 | + this.windowPosition.y = Math.min(Math.max(newY, this.topSafeHeight), this.bottomSafeHeight); | ||
| 219 | + }) | ||
| 220 | + //手势识别成功,手指抬起后触发回调。 | ||
| 221 | + .onActionEnd(() => { | ||
| 222 | + console.info('Pan end'); | ||
| 196 | }) | 223 | }) |
| 197 | ) | 224 | ) |
| 198 | ) | 225 | ) |
| 199 | - .width('100%') | ||
| 200 | - .height('100%') | ||
| 201 | .borderRadius(4) | 226 | .borderRadius(4) |
| 202 | .padding({ | 227 | .padding({ |
| 203 | top: 10, | 228 | top: 10, |
| @@ -9,6 +9,8 @@ import { VideoChannelPage } from './VideoChannelPage'; | @@ -9,6 +9,8 @@ import { VideoChannelPage } from './VideoChannelPage'; | ||
| 9 | import ChannelViewModel from 'wdComponent/src/main/ets/viewmodel/ChannelViewModel'; | 9 | import ChannelViewModel from 'wdComponent/src/main/ets/viewmodel/ChannelViewModel'; |
| 10 | import { ALL, ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknife'; | 10 | import { ALL, ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknife'; |
| 11 | import { ParamType, Tracking } from 'wdTracking/Index'; | 11 | import { ParamType, Tracking } from 'wdTracking/Index'; |
| 12 | +import { AudioSuspensionModel } from 'wdComponent' | ||
| 13 | +import { BusinessError } from '@kit.BasicServicesKit'; | ||
| 12 | 14 | ||
| 13 | const TAG = 'BottomNavigationComponent'; | 15 | const TAG = 'BottomNavigationComponent'; |
| 14 | PersistentStorage.persistProp('channelIds', ''); | 16 | PersistentStorage.persistProp('channelIds', ''); |
| @@ -52,6 +54,8 @@ export struct BottomNavigationComponent { | @@ -52,6 +54,8 @@ export struct BottomNavigationComponent { | ||
| 52 | @State assignChannel: AssignChannelParam = new AssignChannelParam() | 54 | @State assignChannel: AssignChannelParam = new AssignChannelParam() |
| 53 | // 自动刷新触发(双击tab自动刷新) | 55 | // 自动刷新触发(双击tab自动刷新) |
| 54 | @State autoRefresh: number = 0 | 56 | @State autoRefresh: number = 0 |
| 57 | + private AudioSuspension = new AudioSuspensionModel() | ||
| 58 | + @State isShowAudioCom: boolean = false | ||
| 55 | 59 | ||
| 56 | 60 | ||
| 57 | async aboutToAppear() { | 61 | async aboutToAppear() { |
| @@ -143,6 +147,9 @@ export struct BottomNavigationComponent { | @@ -143,6 +147,9 @@ export struct BottomNavigationComponent { | ||
| 143 | .hoverEffect(HoverEffect.Highlight) | 147 | .hoverEffect(HoverEffect.Highlight) |
| 144 | .visibility(this.displayDirection === DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None) | 148 | .visibility(this.displayDirection === DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None) |
| 145 | // .hitTestBehavior(HitTestMode.Block) | 149 | // .hitTestBehavior(HitTestMode.Block) |
| 150 | + .onTouch(() => { | ||
| 151 | + this.handleAudio(navItem) | ||
| 152 | + }) | ||
| 146 | .onClick(() => { | 153 | .onClick(() => { |
| 147 | Logger.info(TAG, `onChange, index: ${index}`); | 154 | Logger.info(TAG, `onChange, index: ${index}`); |
| 148 | Logger.info(TAG, `onChange, navItem: ${JSON.stringify(navItem)}`); | 155 | Logger.info(TAG, `onChange, navItem: ${JSON.stringify(navItem)}`); |
| @@ -152,7 +159,6 @@ export struct BottomNavigationComponent { | @@ -152,7 +159,6 @@ export struct BottomNavigationComponent { | ||
| 152 | "pageId": navItem.id, | 159 | "pageId": navItem.id, |
| 153 | } | 160 | } |
| 154 | Tracking.event("bar_click", params) | 161 | Tracking.event("bar_click", params) |
| 155 | - | ||
| 156 | this.onBottomNavigationIndexChange(navItem, index) | 162 | this.onBottomNavigationIndexChange(navItem, index) |
| 157 | }) | 163 | }) |
| 158 | 164 | ||
| @@ -221,9 +227,37 @@ export struct BottomNavigationComponent { | @@ -221,9 +227,37 @@ export struct BottomNavigationComponent { | ||
| 221 | return isSelect ? $r('app.media.icon_tab_res1') : $r('app.media.icon_tab_res1_no') | 227 | return isSelect ? $r('app.media.icon_tab_res1') : $r('app.media.icon_tab_res1_no') |
| 222 | } | 228 | } |
| 223 | 229 | ||
| 230 | + // 控制音频悬浮窗显隐 | ||
| 231 | + handleAudio(navItem: BottomNavDTO) { | ||
| 232 | + if (navItem.name === '视频') { | ||
| 233 | + // 判断当前窗口是否已显示,使用callback异步回调。 | ||
| 234 | + this.AudioSuspension.floatWindowClass.get().isShowing((err: BusinessError, data) => { | ||
| 235 | + const errCode: number = err.code; | ||
| 236 | + if (errCode) { | ||
| 237 | + console.error(TAG, 'Failed window is showing Cause:' + JSON.stringify(err)); | ||
| 238 | + return; | ||
| 239 | + } | ||
| 240 | + console.info(TAG, 'window is showing: ' + JSON.stringify(data)); | ||
| 241 | + if(data) { | ||
| 242 | + this.isShowAudioCom = true | ||
| 243 | + this.AudioSuspension.playerController.get()?.pause(); | ||
| 244 | + this.AudioSuspension.minimize() | ||
| 245 | + } | ||
| 246 | + }); | ||
| 247 | + } else { | ||
| 248 | + console.info(TAG, 'this.isShowAudioCom: ' + this.isShowAudioCom); | ||
| 249 | + if (this.isShowAudioCom) { | ||
| 250 | + this.AudioSuspension.showWindow() | ||
| 251 | + this.AudioSuspension.playerController.get()?.play(); | ||
| 252 | + this.isShowAudioCom = false | ||
| 253 | + } | ||
| 254 | + } | ||
| 255 | + } | ||
| 256 | + | ||
| 224 | // 底导切换函数 | 257 | // 底导切换函数 |
| 225 | async onBottomNavigationIndexChange(navItem: BottomNavDTO, index: number) { | 258 | async onBottomNavigationIndexChange(navItem: BottomNavDTO, index: number) { |
| 226 | Logger.info(TAG, `onBottomNavigationIndexChange this.currentNavIndex: ${this.currentNavIndex}`); | 259 | Logger.info(TAG, `onBottomNavigationIndexChange this.currentNavIndex: ${this.currentNavIndex}`); |
| 260 | + | ||
| 227 | if (navItem.name === '我的') { | 261 | if (navItem.name === '我的') { |
| 228 | this.barBackgroundColor = Color.White | 262 | this.barBackgroundColor = Color.White |
| 229 | this.currentBottomNavInfo = {} as BottomNavDTO | 263 | this.currentBottomNavInfo = {} as BottomNavDTO |
| @@ -237,7 +271,6 @@ export struct BottomNavigationComponent { | @@ -237,7 +271,6 @@ export struct BottomNavigationComponent { | ||
| 237 | } | 271 | } |
| 238 | } | 272 | } |
| 239 | this.currentNavIndex = index; | 273 | this.currentNavIndex = index; |
| 240 | - | ||
| 241 | // 请求顶导数据(参数): | 274 | // 请求顶导数据(参数): |
| 242 | } | 275 | } |
| 243 | 276 |
-
Please register or login to post a comment