王士厅

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

... ... @@ -9,6 +9,8 @@ import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment
import { PictureLoading } from '../widgets/vertical/PictureLoading';
import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
import { LiveDetailPageLogic } from '../viewModel/LiveDetailPageLogic';
import { AudioSuspensionModel } from 'wdComponent'
import { BusinessError } from '@kit.BasicServicesKit';
const TAG = 'DetailPlayLiveCommon'
... ... @@ -60,15 +62,8 @@ export struct DetailPlayLiveCommon {
// 是否隐藏Loading view
@State isHideLoading: boolean = false
async aboutToAppear(): Promise<void> {
const par: Action = router.getParams() as Action;
const params = par?.params;
this.relId = params?.extra?.relId || '';
this.relType = params?.extra?.relType || '';
this.contentId = params?.contentID || '';
this.getContentDetail()
}
private AudioSuspension = new AudioSuspensionModel()
@State isShowAudioCom: boolean = false
build() {
Column() {
... ... @@ -92,82 +87,116 @@ export struct DetailPlayLiveCommon {
/**
* 查询视频详情用于评论展示
*/
getContentDetail() {
this.liveViewModel.getContentDetail(this.contentId, this.relId, this.relType)
.then(async (data: Array<ContentDetailDTO>) => {
console.log(TAG, '查询视频详情用于评论展示 getContentDetail:', JSON.stringify(data))
if (data) {
let detailData = data[0]
//人民号类型单独获取直播地址
if (detailData.rmhPlatform === 1 && detailData.liveInfo?.liveState === 'running') { //
let vliveId = detailData.liveInfo.vlive[0].vliveId as string
let pullStreamAddressData = await this.liveViewModel.getLiveRoomPullAddress(vliveId) as GetPullAddressBean
if (pullStreamAddressData) {
// console.log(TAG, ' GetPullAddressBean:', JSON.stringify(pullStreamAddressData))
let m3u8uUrl = pullStreamAddressData.transCode[0].m3u8Url
detailData.liveInfo.vlive[0].liveUrl = m3u8uUrl
this.playUrl = m3u8uUrl
}
getContentDetail(): Promise<void> {
return new Promise<void>((resolve, reject) => {
this.liveViewModel.getContentDetail(this.contentId, this.relId, this.relType)
.then(async (data: Array<ContentDetailDTO>) => {
// console.log(TAG, '查询视频详情用于评论展示 getContentDetail:', JSON.stringify(data));
if (!data || data.length === 0) {
this.isHideLoading = true;
ToastUtils.shortToast('内容不存在');
router.back();
reject();
return;
}
this.liveState = detailData.liveInfo?.liveState
this.contentDetailData = data[0]
this.liveDetailPageLogic.contentDetailData = this.contentDetailData
this.liveDetailPageLogic.liveLandscape = detailData?.liveInfo?.liveLandScape
const detailData = data[0];
this.liveDetailPageLogic.liveState = detailData.liveInfo?.liveState
// 人民号类型单独获取直播地址
if (detailData.rmhPlatform === 1 && detailData.liveInfo?.liveState === 'running') {
const vliveId = detailData.liveInfo.vlive[0].vliveId as string;
const pullStreamAddressData = await this.liveViewModel.getLiveRoomPullAddress(vliveId) as GetPullAddressBean;
this.liveDetailPageLogic.resolvingRoomImgSource()
this.liveDetailPageLogic.resolvingRoomVliveData(0)
this.publishCommentModel.targetId = String(detailData?.newsId || '')
this.publishCommentModel.targetRelId = String(detailData?.reLInfo?.relId || '')
this.publishCommentModel.targetTitle = detailData?.newsTitle
this.publishCommentModel.targetRelType = String(detailData?.reLInfo?.relType || '')
this.publishCommentModel.targetRelObjectId = String(detailData?.reLInfo?.relObjectId || '')
this.publishCommentModel.keyArticle = String(detailData?.keyArticle || '')
this.publishCommentModel.targetType = String(detailData?.newsType || '')
this.publishCommentModel.visitorComment = String(detailData?.visitorComment || '')
this.publishCommentModel.commentContent = ''
this.liveStyle = detailData.liveInfo?.liveStyle
if (detailData.liveInfo.liveState == 'end') {
this.playUrl = detailData.liveInfo.vlive[0].replayUri
if (pullStreamAddressData) {
const m3u8uUrl = pullStreamAddressData.transCode[0].m3u8Url;
detailData.liveInfo.vlive[0].liveUrl = m3u8uUrl;
this.playUrl = m3u8uUrl;
}
}
} else {
this.isHideLoading = true
ToastUtils.shortToast('内容不存在')
router.back()
}
}, () => {
this.isHideLoading = true
ToastUtils.shortToast('内容不存在')
router.back()
this.liveState = detailData.liveInfo?.liveState;
this.contentDetailData = detailData;
this.liveDetailPageLogic.contentDetailData = this.contentDetailData;
this.liveDetailPageLogic.liveLandscape = detailData?.liveInfo?.liveLandScape;
this.liveDetailPageLogic.liveState = detailData.liveInfo?.liveState;
this.liveDetailPageLogic.resolvingRoomImgSource();
this.liveDetailPageLogic.resolvingRoomVliveData(0);
const publishCommentModel = this.publishCommentModel;
publishCommentModel.targetId = String(detailData?.newsId || '');
publishCommentModel.targetRelId = String(detailData?.reLInfo?.relId || '');
publishCommentModel.targetTitle = detailData?.newsTitle;
publishCommentModel.targetRelType = String(detailData?.reLInfo?.relType || '');
publishCommentModel.targetRelObjectId = String(detailData?.reLInfo?.relObjectId || '');
publishCommentModel.keyArticle = String(detailData?.keyArticle || '');
publishCommentModel.targetType = String(detailData?.newsType || '');
publishCommentModel.visitorComment = String(detailData?.visitorComment || '');
publishCommentModel.commentContent = '';
this.liveStyle = detailData.liveInfo?.liveStyle;
if (detailData.liveInfo?.liveState === 'end') {
this.playUrl = detailData.liveInfo.vlive[0].replayUri;
}
})
resolve();
})
.catch(() => {
this.isHideLoading = true;
ToastUtils.shortToast('内容不存在');
router.back();
reject();
});
});
}
onPageShow() {
async onPageShow() {
this.pageShow = Math.random()
Logger.info(TAG, 'onPageShow')
// Logger.info(TAG, 'onPageShow')
this.pageShowTime = DateTimeUtils.getTimeStamp()
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff'})
const par: Action = router.getParams() as Action;
const params = par?.params;
this.relId = params?.extra?.relId || '';
this.relType = params?.extra?.relType || '';
this.contentId = params?.contentID || '';
await this.getContentDetail()
// 判断当前窗口是否已显示,使用callback异步回调。
// Logger.info(TAG, 'this.liveState', this.liveState)
if(this.liveState !== 'wait') {
this.AudioSuspension.floatWindowClass.get().isShowing((err: BusinessError, data) => {
const errCode: number = err.code;
if (errCode) {
// console.error(TAG, 'Failed window is showing Cause:' + JSON.stringify(err));
return;
}
// console.info(TAG, 'window is showing: ' + JSON.stringify(data));
if(data) {
this.isShowAudioCom = true
this.AudioSuspension.playerController.get()?.pause();
this.AudioSuspension.minimize()
}
});
}
}
onPageHide() {
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000'})
this.pageHide = Math.random()
Logger.info(TAG, 'onPageHide')
// Logger.info(TAG, 'onPageHide')
//页面浏览
TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Live_Detail,
TrackConstants.PageName.Live_Detail
, Math.floor((DateTimeUtils.getTimeStamp() - this.pageShowTime) / 1000))
if(this.liveState !== 'wait') {
if (this.isShowAudioCom) {
this.AudioSuspension.showWindow()
this.isShowAudioCom = false
}
}
}
onBackPress(): boolean | void {
... ...
... ... @@ -9,8 +9,6 @@ import { VideoChannelPage } from './VideoChannelPage';
import ChannelViewModel from 'wdComponent/src/main/ets/viewmodel/ChannelViewModel';
import { ALL, ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknife';
import { ParamType, Tracking } from 'wdTracking/Index';
import { AudioSuspensionModel } from 'wdComponent'
import { BusinessError } from '@kit.BasicServicesKit';
import { GrayManageModel } from 'wdComponent/src/main/ets/viewmodel/GrayManageModel';
const TAG = 'BottomNavigationComponent';
... ... @@ -54,8 +52,6 @@ export struct BottomNavigationComponent {
@State assignChannel: AssignChannelParam = new AssignChannelParam()
// 自动刷新触发(双击tab自动刷新)
@State autoRefresh: number = 0
private AudioSuspension = new AudioSuspensionModel()
@State isShowAudioCom: boolean = false
// 国殇灰度管理
GrayManage: SubscribedAbstractProperty<GrayManageModel> = AppStorage.link<GrayManageModel>('GrayManage')
... ... @@ -157,9 +153,6 @@ export struct BottomNavigationComponent {
.hoverEffect(HoverEffect.Highlight)
.visibility(this.displayDirection === DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
// .hitTestBehavior(HitTestMode.Block)
.onTouch(() => {
this.handleAudio(navItem)
})
.onClick(() => {
// Logger.info(TAG, `onChange, index: ${index}`);
// Logger.info(TAG, `onChange, navItem: ${JSON.stringify(navItem)}`);
... ... @@ -268,32 +261,6 @@ export struct BottomNavigationComponent {
return isSelect ? $r('app.media.icon_tab_res1') : $r('app.media.icon_tab_res1_no')
}
// 控制音频悬浮窗显隐
handleAudio(navItem: BottomNavDTO) {
if (navItem.name === '视频') {
// 判断当前窗口是否已显示,使用callback异步回调。
this.AudioSuspension.floatWindowClass.get().isShowing((err: BusinessError, data) => {
const errCode: number = err.code;
if (errCode) {
// console.error(TAG, 'Failed window is showing Cause:' + JSON.stringify(err));
return;
}
// console.info(TAG, 'window is showing: ' + JSON.stringify(data));
if(data) {
this.isShowAudioCom = true
this.AudioSuspension.playerController.get()?.pause();
this.AudioSuspension.minimize()
}
});
} else {
// console.info(TAG, 'this.isShowAudioCom: ' + this.isShowAudioCom);
if (this.isShowAudioCom) {
this.AudioSuspension.showWindow()
this.isShowAudioCom = false
}
}
}
// 底导切换函数
async onBottomNavigationIndexChange(navItem: BottomNavDTO, index: number) {
// Logger.info(TAG, `onBottomNavigationIndexChange to Index:${index},this.currentNavIndex: ${this.currentNavIndex}`);
... ...
... ... @@ -13,6 +13,8 @@ import { ParamType, Tracking } from 'wdTracking/Index';
import { ColorUtils } from 'wdComponent/src/main/ets/utils/ColorUtils';
import { ImageKnifeComponent } from '@ohos/imageknife';
import { CommonUtils } from 'wdComponent/src/main/ets/utils/CommonUtils';
import { AudioSuspensionModel } from 'wdComponent'
import { BusinessError } from '@kit.BasicServicesKit';
const TAG = 'VideoChannelPage'
... ... @@ -42,6 +44,8 @@ export struct VideoChannelPage {
// 背景高度
@State backgroundImageH: number = 0
@Consume @Watch('setBarBackgroundColor') pageShow: number
private AudioSuspension = new AudioSuspensionModel()
@State isShowAudioCom: boolean = false
// 国殇灰度管理
GrayManage: SubscribedAbstractProperty<GrayManageModel> = AppStorage.link<GrayManageModel>('GrayManage')
... ... @@ -50,6 +54,9 @@ export struct VideoChannelPage {
this.backgroundImageH = px2vp(this.topSafeHeight) + 44
// console.info(`cj2024 backgroundImageH = ${this.backgroundImageH} this.topSafeHeight = ${this.topSafeHeight}`)
this.setBarBackgroundColor()
if (this.currentTopNavSelectedIndex === 0) {
this.handleAudio(this.topNavList[0])
}
}
/**
... ... @@ -100,6 +107,32 @@ export struct VideoChannelPage {
}
// 控制音频悬浮窗显隐
handleAudio(navItem: TopNavDTO) {
if (navItem.name === '视频') {
// 判断当前窗口是否已显示,使用callback异步回调。
this.AudioSuspension.floatWindowClass.get().isShowing((err: BusinessError, data) => {
const errCode: number = err.code;
if (errCode) {
// console.error(TAG, 'Failed window is showing Cause:' + JSON.stringify(err));
return;
}
// console.info(TAG, 'window is showing: ' + JSON.stringify(data));
if(data) {
this.isShowAudioCom = true
this.AudioSuspension.playerController.get()?.pause();
this.AudioSuspension.minimize()
}
});
} else {
// console.info(TAG, 'this.isShowAudioCom: ' + this.isShowAudioCom);
if (this.isShowAudioCom) {
this.AudioSuspension.showWindow()
this.isShowAudioCom = false
}
}
}
build() {
Stack({ alignContent: Alignment.Top }) {
... ... @@ -152,6 +185,7 @@ export struct VideoChannelPage {
.onClick(() => {
// 视频tab埋点
const tab = this.topNavList[index]
this.handleAudio(tab)
Logger.info(TAG, `视频tab埋点: ${JSON.stringify(tab)}`);
const params: ParamType = {
"pageName": tab.name,
... ...