王士厅

fix: 对稿件或早晚报进行语音播放时,切换至视频频道【直播】后,语音播放被暂停了,且语音动效也被删除了

@@ -9,6 +9,8 @@ import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment @@ -9,6 +9,8 @@ import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment
9 import { PictureLoading } from '../widgets/vertical/PictureLoading'; 9 import { PictureLoading } from '../widgets/vertical/PictureLoading';
10 import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index'; 10 import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
11 import { LiveDetailPageLogic } from '../viewModel/LiveDetailPageLogic'; 11 import { LiveDetailPageLogic } from '../viewModel/LiveDetailPageLogic';
  12 +import { AudioSuspensionModel } from 'wdComponent'
  13 +import { BusinessError } from '@kit.BasicServicesKit';
12 14
13 const TAG = 'DetailPlayLiveCommon' 15 const TAG = 'DetailPlayLiveCommon'
14 16
@@ -60,15 +62,8 @@ export struct DetailPlayLiveCommon { @@ -60,15 +62,8 @@ export struct DetailPlayLiveCommon {
60 // 是否隐藏Loading view 62 // 是否隐藏Loading view
61 @State isHideLoading: boolean = false 63 @State isHideLoading: boolean = false
62 64
63 - async aboutToAppear(): Promise<void> {  
64 - const par: Action = router.getParams() as Action;  
65 - const params = par?.params;  
66 - this.relId = params?.extra?.relId || '';  
67 - this.relType = params?.extra?.relType || '';  
68 - this.contentId = params?.contentID || '';  
69 - this.getContentDetail()  
70 -  
71 - } 65 + private AudioSuspension = new AudioSuspensionModel()
  66 + @State isShowAudioCom: boolean = false
72 67
73 build() { 68 build() {
74 Column() { 69 Column() {
@@ -92,82 +87,116 @@ export struct DetailPlayLiveCommon { @@ -92,82 +87,116 @@ export struct DetailPlayLiveCommon {
92 /** 87 /**
93 * 查询视频详情用于评论展示 88 * 查询视频详情用于评论展示
94 */ 89 */
95 - getContentDetail() { 90 + getContentDetail(): Promise<void> {
  91 + return new Promise<void>((resolve, reject) => {
96 this.liveViewModel.getContentDetail(this.contentId, this.relId, this.relType) 92 this.liveViewModel.getContentDetail(this.contentId, this.relId, this.relType)
97 .then(async (data: Array<ContentDetailDTO>) => { 93 .then(async (data: Array<ContentDetailDTO>) => {
98 - console.log(TAG, '查询视频详情用于评论展示 getContentDetail:', JSON.stringify(data))  
99 - if (data) {  
100 - let detailData = data[0]  
101 - //人民号类型单独获取直播地址  
102 - if (detailData.rmhPlatform === 1 && detailData.liveInfo?.liveState === 'running') { //  
103 - let vliveId = detailData.liveInfo.vlive[0].vliveId as string  
104 - let pullStreamAddressData = await this.liveViewModel.getLiveRoomPullAddress(vliveId) as GetPullAddressBean  
105 - if (pullStreamAddressData) {  
106 - // console.log(TAG, ' GetPullAddressBean:', JSON.stringify(pullStreamAddressData))  
107 - let m3u8uUrl = pullStreamAddressData.transCode[0].m3u8Url  
108 - detailData.liveInfo.vlive[0].liveUrl = m3u8uUrl  
109 - this.playUrl = m3u8uUrl 94 + // console.log(TAG, '查询视频详情用于评论展示 getContentDetail:', JSON.stringify(data));
  95 +
  96 + if (!data || data.length === 0) {
  97 + this.isHideLoading = true;
  98 + ToastUtils.shortToast('内容不存在');
  99 + router.back();
  100 + reject();
  101 + return;
110 } 102 }
111 - }  
112 -  
113 - this.liveState = detailData.liveInfo?.liveState  
114 -  
115 - this.contentDetailData = data[0]  
116 -  
117 - this.liveDetailPageLogic.contentDetailData = this.contentDetailData  
118 -  
119 - this.liveDetailPageLogic.liveLandscape = detailData?.liveInfo?.liveLandScape  
120 -  
121 - this.liveDetailPageLogic.liveState = detailData.liveInfo?.liveState  
122 -  
123 - this.liveDetailPageLogic.resolvingRoomImgSource()  
124 103
125 - this.liveDetailPageLogic.resolvingRoomVliveData(0) 104 + const detailData = data[0];
126 105
127 - this.publishCommentModel.targetId = String(detailData?.newsId || '')  
128 - this.publishCommentModel.targetRelId = String(detailData?.reLInfo?.relId || '')  
129 - this.publishCommentModel.targetTitle = detailData?.newsTitle  
130 - this.publishCommentModel.targetRelType = String(detailData?.reLInfo?.relType || '')  
131 - this.publishCommentModel.targetRelObjectId = String(detailData?.reLInfo?.relObjectId || '')  
132 - this.publishCommentModel.keyArticle = String(detailData?.keyArticle || '')  
133 - this.publishCommentModel.targetType = String(detailData?.newsType || '')  
134 - this.publishCommentModel.visitorComment = String(detailData?.visitorComment || '')  
135 - this.publishCommentModel.commentContent = ''  
136 - this.liveStyle = detailData.liveInfo?.liveStyle 106 + // 人民号类型单独获取直播地址
  107 + if (detailData.rmhPlatform === 1 && detailData.liveInfo?.liveState === 'running') {
  108 + const vliveId = detailData.liveInfo.vlive[0].vliveId as string;
  109 + const pullStreamAddressData = await this.liveViewModel.getLiveRoomPullAddress(vliveId) as GetPullAddressBean;
137 110
138 - if (detailData.liveInfo.liveState == 'end') {  
139 - this.playUrl = detailData.liveInfo.vlive[0].replayUri 111 + if (pullStreamAddressData) {
  112 + const m3u8uUrl = pullStreamAddressData.transCode[0].m3u8Url;
  113 + detailData.liveInfo.vlive[0].liveUrl = m3u8uUrl;
  114 + this.playUrl = m3u8uUrl;
  115 + }
140 } 116 }
141 117
142 - } else {  
143 - this.isHideLoading = true  
144 - ToastUtils.shortToast('内容不存在')  
145 - router.back() 118 + this.liveState = detailData.liveInfo?.liveState;
  119 + this.contentDetailData = detailData;
  120 + this.liveDetailPageLogic.contentDetailData = this.contentDetailData;
  121 + this.liveDetailPageLogic.liveLandscape = detailData?.liveInfo?.liveLandScape;
  122 + this.liveDetailPageLogic.liveState = detailData.liveInfo?.liveState;
  123 + this.liveDetailPageLogic.resolvingRoomImgSource();
  124 + this.liveDetailPageLogic.resolvingRoomVliveData(0);
  125 +
  126 + const publishCommentModel = this.publishCommentModel;
  127 + publishCommentModel.targetId = String(detailData?.newsId || '');
  128 + publishCommentModel.targetRelId = String(detailData?.reLInfo?.relId || '');
  129 + publishCommentModel.targetTitle = detailData?.newsTitle;
  130 + publishCommentModel.targetRelType = String(detailData?.reLInfo?.relType || '');
  131 + publishCommentModel.targetRelObjectId = String(detailData?.reLInfo?.relObjectId || '');
  132 + publishCommentModel.keyArticle = String(detailData?.keyArticle || '');
  133 + publishCommentModel.targetType = String(detailData?.newsType || '');
  134 + publishCommentModel.visitorComment = String(detailData?.visitorComment || '');
  135 + publishCommentModel.commentContent = '';
  136 + this.liveStyle = detailData.liveInfo?.liveStyle;
  137 +
  138 + if (detailData.liveInfo?.liveState === 'end') {
  139 + this.playUrl = detailData.liveInfo.vlive[0].replayUri;
146 } 140 }
147 - }, () => {  
148 - this.isHideLoading = true  
149 - ToastUtils.shortToast('内容不存在')  
150 - router.back()  
151 141
  142 + resolve();
152 }) 143 })
  144 + .catch(() => {
  145 + this.isHideLoading = true;
  146 + ToastUtils.shortToast('内容不存在');
  147 + router.back();
  148 + reject();
  149 + });
  150 + });
153 } 151 }
154 152
155 - onPageShow() { 153 +
  154 + async onPageShow() {
156 this.pageShow = Math.random() 155 this.pageShow = Math.random()
157 - Logger.info(TAG, 'onPageShow') 156 + // Logger.info(TAG, 'onPageShow')
158 this.pageShowTime = DateTimeUtils.getTimeStamp() 157 this.pageShowTime = DateTimeUtils.getTimeStamp()
159 WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff'}) 158 WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff'})
  159 + const par: Action = router.getParams() as Action;
  160 + const params = par?.params;
  161 + this.relId = params?.extra?.relId || '';
  162 + this.relType = params?.extra?.relType || '';
  163 + this.contentId = params?.contentID || '';
  164 + await this.getContentDetail()
  165 + // 判断当前窗口是否已显示,使用callback异步回调。
  166 + // Logger.info(TAG, 'this.liveState', this.liveState)
  167 + if(this.liveState !== 'wait') {
  168 + this.AudioSuspension.floatWindowClass.get().isShowing((err: BusinessError, data) => {
  169 + const errCode: number = err.code;
  170 + if (errCode) {
  171 + // console.error(TAG, 'Failed window is showing Cause:' + JSON.stringify(err));
  172 + return;
  173 + }
  174 + // console.info(TAG, 'window is showing: ' + JSON.stringify(data));
  175 + if(data) {
  176 + this.isShowAudioCom = true
  177 + this.AudioSuspension.playerController.get()?.pause();
  178 + this.AudioSuspension.minimize()
  179 + }
  180 + });
  181 + }
160 } 182 }
161 183
162 onPageHide() { 184 onPageHide() {
163 WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000'}) 185 WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000'})
164 this.pageHide = Math.random() 186 this.pageHide = Math.random()
165 - Logger.info(TAG, 'onPageHide') 187 + // Logger.info(TAG, 'onPageHide')
166 //页面浏览 188 //页面浏览
167 TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Live_Detail, 189 TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Live_Detail,
168 TrackConstants.PageName.Live_Detail 190 TrackConstants.PageName.Live_Detail
169 , Math.floor((DateTimeUtils.getTimeStamp() - this.pageShowTime) / 1000)) 191 , Math.floor((DateTimeUtils.getTimeStamp() - this.pageShowTime) / 1000))
170 192
  193 + if(this.liveState !== 'wait') {
  194 + if (this.isShowAudioCom) {
  195 + this.AudioSuspension.showWindow()
  196 + this.isShowAudioCom = false
  197 + }
  198 + }
  199 +
171 } 200 }
172 201
173 onBackPress(): boolean | void { 202 onBackPress(): boolean | void {
@@ -9,8 +9,6 @@ import { VideoChannelPage } from './VideoChannelPage'; @@ -9,8 +9,6 @@ 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';  
14 import { GrayManageModel } from 'wdComponent/src/main/ets/viewmodel/GrayManageModel'; 12 import { GrayManageModel } from 'wdComponent/src/main/ets/viewmodel/GrayManageModel';
15 13
16 const TAG = 'BottomNavigationComponent'; 14 const TAG = 'BottomNavigationComponent';
@@ -54,8 +52,6 @@ export struct BottomNavigationComponent { @@ -54,8 +52,6 @@ export struct BottomNavigationComponent {
54 @State assignChannel: AssignChannelParam = new AssignChannelParam() 52 @State assignChannel: AssignChannelParam = new AssignChannelParam()
55 // 自动刷新触发(双击tab自动刷新) 53 // 自动刷新触发(双击tab自动刷新)
56 @State autoRefresh: number = 0 54 @State autoRefresh: number = 0
57 - private AudioSuspension = new AudioSuspensionModel()  
58 - @State isShowAudioCom: boolean = false  
59 // 国殇灰度管理 55 // 国殇灰度管理
60 GrayManage: SubscribedAbstractProperty<GrayManageModel> = AppStorage.link<GrayManageModel>('GrayManage') 56 GrayManage: SubscribedAbstractProperty<GrayManageModel> = AppStorage.link<GrayManageModel>('GrayManage')
61 57
@@ -157,9 +153,6 @@ export struct BottomNavigationComponent { @@ -157,9 +153,6 @@ export struct BottomNavigationComponent {
157 .hoverEffect(HoverEffect.Highlight) 153 .hoverEffect(HoverEffect.Highlight)
158 .visibility(this.displayDirection === DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None) 154 .visibility(this.displayDirection === DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
159 // .hitTestBehavior(HitTestMode.Block) 155 // .hitTestBehavior(HitTestMode.Block)
160 - .onTouch(() => {  
161 - this.handleAudio(navItem)  
162 - })  
163 .onClick(() => { 156 .onClick(() => {
164 // Logger.info(TAG, `onChange, index: ${index}`); 157 // Logger.info(TAG, `onChange, index: ${index}`);
165 // Logger.info(TAG, `onChange, navItem: ${JSON.stringify(navItem)}`); 158 // Logger.info(TAG, `onChange, navItem: ${JSON.stringify(navItem)}`);
@@ -268,32 +261,6 @@ export struct BottomNavigationComponent { @@ -268,32 +261,6 @@ export struct BottomNavigationComponent {
268 return isSelect ? $r('app.media.icon_tab_res1') : $r('app.media.icon_tab_res1_no') 261 return isSelect ? $r('app.media.icon_tab_res1') : $r('app.media.icon_tab_res1_no')
269 } 262 }
270 263
271 - // 控制音频悬浮窗显隐  
272 - handleAudio(navItem: BottomNavDTO) {  
273 - if (navItem.name === '视频') {  
274 - // 判断当前窗口是否已显示,使用callback异步回调。  
275 - this.AudioSuspension.floatWindowClass.get().isShowing((err: BusinessError, data) => {  
276 - const errCode: number = err.code;  
277 - if (errCode) {  
278 - // console.error(TAG, 'Failed window is showing Cause:' + JSON.stringify(err));  
279 - return;  
280 - }  
281 - // console.info(TAG, 'window is showing: ' + JSON.stringify(data));  
282 - if(data) {  
283 - this.isShowAudioCom = true  
284 - this.AudioSuspension.playerController.get()?.pause();  
285 - this.AudioSuspension.minimize()  
286 - }  
287 - });  
288 - } else {  
289 - // console.info(TAG, 'this.isShowAudioCom: ' + this.isShowAudioCom);  
290 - if (this.isShowAudioCom) {  
291 - this.AudioSuspension.showWindow()  
292 - this.isShowAudioCom = false  
293 - }  
294 - }  
295 - }  
296 -  
297 // 底导切换函数 264 // 底导切换函数
298 async onBottomNavigationIndexChange(navItem: BottomNavDTO, index: number) { 265 async onBottomNavigationIndexChange(navItem: BottomNavDTO, index: number) {
299 // Logger.info(TAG, `onBottomNavigationIndexChange to Index:${index},this.currentNavIndex: ${this.currentNavIndex}`); 266 // Logger.info(TAG, `onBottomNavigationIndexChange to Index:${index},this.currentNavIndex: ${this.currentNavIndex}`);
@@ -13,6 +13,8 @@ import { ParamType, Tracking } from 'wdTracking/Index'; @@ -13,6 +13,8 @@ import { ParamType, Tracking } from 'wdTracking/Index';
13 import { ColorUtils } from 'wdComponent/src/main/ets/utils/ColorUtils'; 13 import { ColorUtils } from 'wdComponent/src/main/ets/utils/ColorUtils';
14 import { ImageKnifeComponent } from '@ohos/imageknife'; 14 import { ImageKnifeComponent } from '@ohos/imageknife';
15 import { CommonUtils } from 'wdComponent/src/main/ets/utils/CommonUtils'; 15 import { CommonUtils } from 'wdComponent/src/main/ets/utils/CommonUtils';
  16 +import { AudioSuspensionModel } from 'wdComponent'
  17 +import { BusinessError } from '@kit.BasicServicesKit';
16 18
17 const TAG = 'VideoChannelPage' 19 const TAG = 'VideoChannelPage'
18 20
@@ -42,6 +44,8 @@ export struct VideoChannelPage { @@ -42,6 +44,8 @@ export struct VideoChannelPage {
42 // 背景高度 44 // 背景高度
43 @State backgroundImageH: number = 0 45 @State backgroundImageH: number = 0
44 @Consume @Watch('setBarBackgroundColor') pageShow: number 46 @Consume @Watch('setBarBackgroundColor') pageShow: number
  47 + private AudioSuspension = new AudioSuspensionModel()
  48 + @State isShowAudioCom: boolean = false
45 // 国殇灰度管理 49 // 国殇灰度管理
46 GrayManage: SubscribedAbstractProperty<GrayManageModel> = AppStorage.link<GrayManageModel>('GrayManage') 50 GrayManage: SubscribedAbstractProperty<GrayManageModel> = AppStorage.link<GrayManageModel>('GrayManage')
47 51
@@ -50,6 +54,9 @@ export struct VideoChannelPage { @@ -50,6 +54,9 @@ export struct VideoChannelPage {
50 this.backgroundImageH = px2vp(this.topSafeHeight) + 44 54 this.backgroundImageH = px2vp(this.topSafeHeight) + 44
51 // console.info(`cj2024 backgroundImageH = ${this.backgroundImageH} this.topSafeHeight = ${this.topSafeHeight}`) 55 // console.info(`cj2024 backgroundImageH = ${this.backgroundImageH} this.topSafeHeight = ${this.topSafeHeight}`)
52 this.setBarBackgroundColor() 56 this.setBarBackgroundColor()
  57 + if (this.currentTopNavSelectedIndex === 0) {
  58 + this.handleAudio(this.topNavList[0])
  59 + }
53 } 60 }
54 61
55 /** 62 /**
@@ -100,6 +107,32 @@ export struct VideoChannelPage { @@ -100,6 +107,32 @@ export struct VideoChannelPage {
100 107
101 } 108 }
102 109
  110 + // 控制音频悬浮窗显隐
  111 + handleAudio(navItem: TopNavDTO) {
  112 + if (navItem.name === '视频') {
  113 + // 判断当前窗口是否已显示,使用callback异步回调。
  114 + this.AudioSuspension.floatWindowClass.get().isShowing((err: BusinessError, data) => {
  115 + const errCode: number = err.code;
  116 + if (errCode) {
  117 + // console.error(TAG, 'Failed window is showing Cause:' + JSON.stringify(err));
  118 + return;
  119 + }
  120 + // console.info(TAG, 'window is showing: ' + JSON.stringify(data));
  121 + if(data) {
  122 + this.isShowAudioCom = true
  123 + this.AudioSuspension.playerController.get()?.pause();
  124 + this.AudioSuspension.minimize()
  125 + }
  126 + });
  127 + } else {
  128 + // console.info(TAG, 'this.isShowAudioCom: ' + this.isShowAudioCom);
  129 + if (this.isShowAudioCom) {
  130 + this.AudioSuspension.showWindow()
  131 + this.isShowAudioCom = false
  132 + }
  133 + }
  134 + }
  135 +
103 build() { 136 build() {
104 Stack({ alignContent: Alignment.Top }) { 137 Stack({ alignContent: Alignment.Top }) {
105 138
@@ -152,6 +185,7 @@ export struct VideoChannelPage { @@ -152,6 +185,7 @@ export struct VideoChannelPage {
152 .onClick(() => { 185 .onClick(() => {
153 // 视频tab埋点 186 // 视频tab埋点
154 const tab = this.topNavList[index] 187 const tab = this.topNavList[index]
  188 + this.handleAudio(tab)
155 Logger.info(TAG, `视频tab埋点: ${JSON.stringify(tab)}`); 189 Logger.info(TAG, `视频tab埋点: ${JSON.stringify(tab)}`);
156 const params: ParamType = { 190 const params: ParamType = {
157 "pageName": tab.name, 191 "pageName": tab.name,