wangliang_wd

Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool into main

* 'main' of http://192.168.1.42/developOne/harmonyPool:
  语音播报关闭后,重新开启语音播报鸿蒙版是续播安卓是重新播放
  语音播报后导致华为自带的返回功能无效
  音频悬浮窗相关问题
  fix(17088): 功能缺陷-【生产环境】播放暂停按钮-未自动隐藏--暂停不隐藏,  播放是4秒隐藏
  fix: 18271 全域-规则_数字显示规则-展示交互问题
  fix(直播): 非沉浸式直播暂停/播放,回放优化
  fix: 19210 UI还原问题-【生产】进入财经频道,视频卡,多显示了25评文案
  fix(17087): UI还原问题-直播回顾-播放/暂停按钮位置偏左;全屏按钮偏右、回看参与人数偏左
  fix: 17931 UI还原问题-【uat】地区精选卡,上下两条线比android细
  fix: 19235 UI还原问题-【生产】进入法治频道,单图卡图片没有显示边框线
  fix: 19237 UI还原问题-【uat】进入北京频道,轮播图,进度没填满
@@ -208,14 +208,14 @@ export struct CompParser { @@ -208,14 +208,14 @@ export struct CompParser {
208 if (this.compDTO.compStyle === this.nextCompDTO.compStyle) { 208 if (this.compDTO.compStyle === this.nextCompDTO.compStyle) {
209 Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 }) 209 Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
210 } else { 210 } else {
211 - Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 16, right: 16 }) 211 + Divider().strokeWidth(5).color('#f5f5f5')
212 } 212 }
213 } else if (this.compDTO?.operDataList?.[0]?.appStyle === CompStyle.Card_10) { 213 } else if (this.compDTO?.operDataList?.[0]?.appStyle === CompStyle.Card_10) {
214 // 大专题 214 // 大专题
215 if (this.nextCompDTO?.operDataList?.[0]?.appStyle === CompStyle.Card_10) { 215 if (this.nextCompDTO?.operDataList?.[0]?.appStyle === CompStyle.Card_10) {
216 Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 }) 216 Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
217 } else { 217 } else {
218 - Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 16, right: 16 }) 218 + Divider().strokeWidth(5).color('#f5f5f5')
219 } 219 }
220 } else if (this.compDTO.compType === 'appStyle') { 220 } else if (this.compDTO.compType === 'appStyle') {
221 if ( 221 if (
@@ -225,7 +225,7 @@ export struct CompParser { @@ -225,7 +225,7 @@ export struct CompParser {
225 this.nextCompDTO.compStyle === CompStyle.Zh_Single_Row_04 || 225 this.nextCompDTO.compStyle === CompStyle.Zh_Single_Row_04 ||
226 this.nextCompDTO.compStyle === CompStyle.Zh_Single_Row_06 226 this.nextCompDTO.compStyle === CompStyle.Zh_Single_Row_06
227 ) { 227 ) {
228 - Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 16, right: 16 }) 228 + Divider().strokeWidth(5).color('#f5f5f5')
229 } else { 229 } else {
230 Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 }) 230 Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
231 } 231 }
@@ -76,8 +76,15 @@ export struct CardSourceInfo { @@ -76,8 +76,15 @@ export struct CardSourceInfo {
76 const num2: string = num.slice(-4, -3); // 千 76 const num2: string = num.slice(-4, -3); // 千
77 return num2 === '0' ? num1 + '万' : num1 + '.' + num2 + '万' 77 return num2 === '0' ? num1 + '万' : num1 + '.' + num2 + '万'
78 } else if (Number.parseInt(num) > 99999999) { 78 } else if (Number.parseInt(num) > 99999999) {
79 - const num1: string = num.slice(0, -8); // 亿  
80 - const num2: string = num.slice(-8, -7); 79 + let num1: string = num.slice(0, -8); // 亿
  80 + let num2: string = num.slice(-8, -7);
  81 + const num3: string = `0.${num.slice(-7, -6)}`
  82 + if (Math.round(Number(num3)) > Number(num3)) {
  83 + if (`${Number(num2) + 1}`.length === 2) {
  84 + num1 = `${Number(num1) + 1}`
  85 + num2 = '0'
  86 + }
  87 + }
81 return num2 === '0' ? num1 + '亿' : num1 + '.' + num2 + '亿' 88 return num2 === '0' ? num1 + '亿' : num1 + '.' + num2 + '亿'
82 } 89 }
83 return num 90 return num
@@ -140,7 +147,7 @@ export struct CardSourceInfo { @@ -140,7 +147,7 @@ export struct CardSourceInfo {
140 } 147 }
141 148
142 // 评论数 149 // 评论数
143 - if (!this.isCompInnerSource && Number(this.getContentDtoBean()?.interactData?.commentNum) > 0 && 150 + if ((this.contentDTO.rmhPlatform === 1 || this.contentDTO.source) && !this.isCompInnerSource && Number(this.getContentDtoBean()?.interactData?.commentNum) > 0 &&
144 this.showCommentNum()) { 151 this.showCommentNum()) {
145 Text(`${this.handlerNum(this.getContentDtoBean()?.interactData?.commentNum.toString())}评`) 152 Text(`${this.handlerNum(this.getContentDtoBean()?.interactData?.commentNum.toString())}评`)
146 .fontSize($r("app.float.font_size_11")) 153 .fontSize($r("app.float.font_size_11"))
@@ -148,7 +155,7 @@ export struct CardSourceInfo { @@ -148,7 +155,7 @@ export struct CardSourceInfo {
148 .flexShrink(0) 155 .flexShrink(0)
149 } else { 156 } else {
150 157
151 - if (this.isCompInnerSource && this.contentDTO.interactData && this.contentDTO.interactData?.commentNum > 0) { 158 + if ((this.contentDTO.rmhPlatform === 1 || this.contentDTO.source) && this.isCompInnerSource && this.contentDTO.interactData && this.contentDTO.interactData?.commentNum > 0) {
152 Text(`${this.handlerNum(this.contentDTO.interactData?.commentNum.toString())}评`) 159 Text(`${this.handlerNum(this.contentDTO.interactData?.commentNum.toString())}评`)
153 .fontSize($r("app.float.font_size_11")) 160 .fontSize($r("app.float.font_size_11"))
154 .fontColor($r("app.color.color_B0B0B0")) 161 .fontColor($r("app.color.color_B0B0B0"))
@@ -159,7 +166,6 @@ export struct CardSourceInfo { @@ -159,7 +166,6 @@ export struct CardSourceInfo {
159 166
160 } 167 }
161 .width(CommonConstants.FULL_WIDTH) 168 .width(CommonConstants.FULL_WIDTH)
162 - .height(16)  
163 .margin({ top: this.viewShowData ? 8 : 0 }) 169 .margin({ top: this.viewShowData ? 8 : 0 })
164 } 170 }
165 171
@@ -202,11 +208,11 @@ export struct CardSourceInfo { @@ -202,11 +208,11 @@ export struct CardSourceInfo {
202 } 208 }
203 209
204 // 评论数 210 // 评论数
205 - if (!this.isCompInnerSource && Number(this.getContentDtoBean()?.interactData?.commentNum) > 0 && 211 + if ((this.contentDTO.rmhPlatform === 1 || this.contentDTO.source) && !this.isCompInnerSource && Number(this.getContentDtoBean()?.interactData?.commentNum) > 0 &&
206 this.showCommentNum()) { 212 this.showCommentNum()) {
207 have = true 213 have = true
208 } else { 214 } else {
209 - if (this.isCompInnerSource && this.contentDTO.interactData && this.contentDTO.interactData?.commentNum > 0) { 215 + if ((this.contentDTO.rmhPlatform === 1 || this.contentDTO.source) && this.isCompInnerSource && this.contentDTO.interactData && this.contentDTO.interactData?.commentNum > 0) {
210 have = true 216 have = true
211 } 217 }
212 } 218 }
@@ -121,6 +121,7 @@ export struct Card6Component { @@ -121,6 +121,7 @@ export struct Card6Component {
121 .borderRadius(5) 121 .borderRadius(5)
122 .aspectRatio(this.contentDTO.appStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4) 122 .aspectRatio(this.contentDTO.appStyle === CompStyle.Card_13 ? 3 / 2 : 3 / 4)
123 .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 78 : 156) 123 .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 78 : 156)
  124 + .border({width: 1, color: 0xf5f5f5})
124 CardMediaInfo({ contentDTO: this.contentDTO }) 125 CardMediaInfo({ contentDTO: this.contentDTO })
125 } 126 }
126 127
@@ -300,7 +300,8 @@ struct indicatorAnimations { @@ -300,7 +300,8 @@ struct indicatorAnimations {
300 // .height(2) 300 // .height(2)
301 301
302 Image($r('app.media.swiper_indicator_gray')) 302 Image($r('app.media.swiper_indicator_gray'))
303 - .width('100%') 303 + .objectFit(ImageFit.Contain)
  304 + .width('96%')
304 .height(2) 305 .height(2)
305 Image($r('app.media.swiper_indicator_white')) 306 Image($r('app.media.swiper_indicator_white'))
306 .width(this.leftW) 307 .width(this.leftW)
@@ -334,7 +335,8 @@ struct indicatorAnimations { @@ -334,7 +335,8 @@ struct indicatorAnimations {
334 // .width('100%') 335 // .width('100%')
335 // .height(2) 336 // .height(2)
336 Image($r('app.media.swiper_indicator_gray')) 337 Image($r('app.media.swiper_indicator_gray'))
337 - .width('100%') 338 + .objectFit(ImageFit.Contain)
  339 + .width('96%')
338 .height(2) 340 .height(2)
339 Image($r('app.media.swiper_indicator_white')) 341 Image($r('app.media.swiper_indicator_white'))
340 .width(this.rightW) 342 .width(this.rightW)
@@ -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);
54 - } 51 + this.playerController.get().resetPlay()
  52 + } else {
55 this.playerController.get().switchPlayOrPause() 53 this.playerController.get().switchPlayOrPause()
  54 + }
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 {
@@ -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 }
@@ -290,7 +309,7 @@ export struct PlayUIComponent { @@ -290,7 +309,7 @@ export struct PlayUIComponent {
290 .fontWeight(600) 309 .fontWeight(600)
291 .fontSize('12fp') 310 .fontSize('12fp')
292 .margin({ 311 .margin({
293 - left: 16 312 + left: 20
294 }) 313 })
295 } 314 }
296 315
@@ -308,7 +327,7 @@ export struct PlayUIComponent { @@ -308,7 +327,7 @@ export struct PlayUIComponent {
308 .fontWeight(600) 327 .fontWeight(600)
309 .fontSize('12fp') 328 .fontSize('12fp')
310 .margin({ 329 .margin({
311 - right: 16 330 + right: 20
312 }) 331 })
313 } 332 }
314 333
@@ -376,7 +395,9 @@ export struct PlayUIComponent { @@ -376,7 +395,9 @@ export struct PlayUIComponent {
376 this.playerController?.pause() 395 this.playerController?.pause()
377 } else { 396 } else {
378 this.isPlayStatus = true 397 this.isPlayStatus = true
  398 + if (this.contentDetailData.liveInfo?.liveState == 'running') {
379 this.playerController?.firstPlay(this.liveUrl) 399 this.playerController?.firstPlay(this.liveUrl)
  400 + }
380 this.playerController?.play() 401 this.playerController?.play()
381 } 402 }
382 }) 403 })
@@ -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() {
@@ -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 209 + PanGesture(this.panOption)
  210 + //手势识别成功回调。
  211 + .onActionStart((event: GestureEvent) => {
  212 + console.info('Pan start');
190 }) 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