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 |> 20004 我的>设置,wifi网络情况下自动播放视频选项,应默认打开
  fix: 对稿件进行语音播放并暂停后,点击关闭按钮后,手机下拉中的播放组件没有删除
  fix: 视频频道中对视频在播放状态下,先暂停、再播放,然后切换到其他频道再返回、视频没有继续播放
  ref |> 调整竖屏直播结束页面关注按钮高度
  ref |> 互动消息跳转时,带上relId relType
  fix: 对稿件或早晚报进行语音播放时,切换至视频频道【直播】后,语音播放被暂停了,且语音动效也被删除了
  ref |> 调整文章详情页缺省页逻辑
... ... @@ -284,7 +284,7 @@ export struct ImageAndTextPageComponent {
.justifyContent(FlexAlign.SpaceBetween)
.alignItems(VerticalAlign.Bottom)
if (this.isNetConnected && !this.detailContentEmpty) {
// if (this.isNetConnected && !this.detailContentEmpty) {
Row() {
Image($r('app.media.ic_news_detail_division'))
.width('100%')
... ... @@ -294,7 +294,7 @@ export struct ImageAndTextPageComponent {
}
.padding({ left: 15, right: 15 })
.backgroundColor(Color.White)
}
// }
}.backgroundColor(Color.White)
}
.margin({top: `${this.topSafeHeight}px`, bottom: `${this.bottomSafeHeight}px`})
... ...
... ... @@ -82,6 +82,8 @@ export struct InteractMComponent {
let contentDTO :ContentDTO = new ContentDTO();
contentDTO.objectType = this.messageModel.InteractMsubM.contentType
contentDTO.objectId = this.messageModel.InteractMsubM.contentId
contentDTO.relId = this.messageModel.InteractMsubM.contentRelId
contentDTO.relType = this.messageModel.InteractMsubM.contentRelType
ProcessUtils.processPage(contentDTO)
})
}
... ...
... ... @@ -26,7 +26,7 @@ export class MineSettingDatasModel {
mainSettingData.push(new MineMainSettingFunctionItem(null, '隐私设罝', null, 0, false,"private_setting"))
let wifiState=SPHelper.default.getSync(SpConstants.SETTING_WIFI_IMAGE_SWITCH,false) as boolean
mainSettingData.push(new MineMainSettingFunctionItem(null, '仅wifi网络加载图片', null, 1, wifiState,"wifi_switch"))
let videoState=SPHelper.default.getSync(SpConstants.SETTING_WIFI_VIDEO_SWITCH,false) as boolean
let videoState=SPHelper.default.getSync(SpConstants.SETTING_WIFI_VIDEO_SWITCH,true) as boolean
mainSettingData.push(new MineMainSettingFunctionItem(null, 'wifi网络情况下自动播放视频', null, 1, videoState,"video_switch"))
let suspensionState=SPHelper.default.getSync(SpConstants.SETTING_SUSPENSION_SWITCH,false) as boolean
// mainSettingData.push(new MineMainSettingFunctionItem(null, '开启播放器悬浮窗', null, 1, suspensionState,"suspensionState_switch"))
... ...
... ... @@ -16,7 +16,7 @@ async function onlyWifiLoadImg(): Promise<boolean> {
}
async function onlyWifiLoadVideo(): Promise<boolean> {
let loadImageOnlyWifiSwitch = await SPHelper.default.get(SpConstants.SETTING_WIFI_VIDEO_SWITCH, '') || false;
let loadImageOnlyWifiSwitch = await SPHelper.default.get(SpConstants.SETTING_WIFI_VIDEO_SWITCH, true) || false;
if (!loadImageOnlyWifiSwitch) {
// 开关没开,直接让加载视频
return true
... ...
... ... @@ -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 {
... ...
... ... @@ -117,7 +117,7 @@ export struct PlayerEndView {
.fontColor('#B2FFFFFF')
.padding({ top: 8 })
}
Blank().height(this.contentDetailData.rmhInfo == null ? 26:16)
Stack() {
Row() {
Column() {
... ... @@ -134,8 +134,7 @@ export struct PlayerEndView {
Text('观看人数').fontWeight(400).fontSize(12).fontColor(Color.White)
}
}
.padding({ top: this.contentDetailData.rmhInfo == null ? 26 : 16 })
Text('').width(1).height(32).margin({ left: 36, right: 36,top:this.contentDetailData.rmhInfo == null ? 26 : 16 }).backgroundColor('#33FFFFFF')
Text('').width(1).height(32).backgroundColor('#33FFFFFF')
}
if (this.contentDetailData.rmhInfo != null) {
Row() {
... ... @@ -149,6 +148,7 @@ export struct PlayerEndView {
left: 122,
right: 122
})
.height(42)
.backgroundColor(this.followStatus == '0' ? '#FFED2800' : '#CCCCCC')
.borderRadius(4)
.onClick(() => {
... ...
... ... @@ -306,9 +306,9 @@ export struct DetailPlayShortVideoPage {
onHeightDidChange: (height: number) => {
this.playerWidth = px2vp(this.windowWidth)
this.playerHeight = px2vp(this.windowHeight - height)
Logger.debug(TAG,
"height: " + px2vp(height) + " ===> 视频高度: " + this.playerHeight + " window height: " +
px2vp(this.windowHeight))
// Logger.debug(TAG,
// "height: " + px2vp(height) + " ===> 视频高度: " + this.playerHeight + " window height: " +
// px2vp(this.windowHeight))
}
})
this.playerViewBuilder()
... ... @@ -332,13 +332,9 @@ export struct DetailPlayShortVideoPage {
.layoutWeight(1)
.onClick(() => {
this.playerController?.switchPlayOrPause();
this.isPlay = !this.isPlay
this.playerController.onStatusChange = (status: number) => {
this.status = status
if (status === PlayerConstants.STATUS_PAUSE) {
this.isPlay = false
} else if (status === PlayerConstants.STATUS_START) {
this.isPlay = true
}
}
})
... ...
... ... @@ -27,7 +27,7 @@ export class BackgroundAudioController {
public gotContextFunc?: () => Context
public avplayerController?: WDPlayerController
private lastSession?: AVSessionManager.AVSession
private lastSession?: AVSessionManager.AVSession | null
private applyedLongTaskPlay: boolean = false
... ... @@ -64,6 +64,7 @@ export class BackgroundAudioController {
if (this.lastSession) {
this.lastSession.deactivate();
this.lastSession.destroy();
this.lastSession = null
}
}
... ...
import { AudioSuspensionModel } from 'wdComponent'
import { PlayerConstants, DateFormatUtil } from 'wdPlayer'
import { PlayerConstants, DateFormatUtil, BackgroundAudioController } from 'wdPlayer'
import { EmitterEventId, EmitterUtils, SPHelper } from 'wdKit/Index'
import window from '@ohos.window';
import lottie from '@ohos/lottie';
... ... @@ -195,6 +195,7 @@ struct Index {
if (this.AudioSuspension.playerController) {
this.AudioSuspension.playerController.get().pause()
this.AudioSuspension.minimize()
BackgroundAudioController.sharedController().destorySession()
}
}))
}
... ...
... ... @@ -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,
... ...