wangliang_wd

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

* 'main' of http://192.168.1.42/developOne/harmonyPool:
  feat:  1)处理直播预告视频播放;2)处理视频资源播放完毕状态,支持重新播放
  feat: 埋点
  fix:somebug
  fix:somebug
  ref |> 解决评论重复问题
  ref |> 解决评论列表用户昵称太长问题和人民号icon显示判断
  ref |> 解决评论列表翻页新问题
  ref |> 解决发布评论后,评论数量没加1的问题
  desc:减少缓存大小
Showing 32 changed files with 310 additions and 164 deletions
... ... @@ -11,7 +11,7 @@ import { UserInfoDTO } from './UserInfoDTO'
* 接口定义:
* http://192.168.1.3:3300/project/3802/interface/api/200915
*/
export interface ContentDetailDTO {
export class ContentDetailDTO {
newsId: number;
newsTitle: string;
newsShortTitle: string;
... ... @@ -72,4 +72,8 @@ export interface ContentDetailDTO {
isNewspaper: boolean;
oldNewsId: string;
serials: any;
// 本地字段
showTime:boolean = false;
}
\ No newline at end of file
... ...
... ... @@ -32,12 +32,6 @@ export struct CardParser {
pageShowTime:number = 0;
pageHideTime:number = 0;
aboutToAppear(): void {
console.log('CardParser-contentDTO', JSON.stringify(this.contentDTO))
console.log('CardParser-compDTO', JSON.stringify(this.compDTO))
}
onPageShow() {
this.pageShowTime = DateTimeUtils.getTimeStamp()
}
... ...
... ... @@ -42,6 +42,9 @@ export struct CompParser {
@State noneAudioItems: ContentDTO[] = [];
aboutToAppear(): void {
console.log('CompParser-compDTO', JSON.stringify(this.compDTO))
// 轮播图屏蔽音频类型稿件
if (this.compDTO.compStyle === CompStyle.Zh_Carousel_Layout_01) {
this.audioItems = this.compDTO.operDataList.filter(item => {
... ...
... ... @@ -5,7 +5,7 @@ import {
ContentDetailRequest,
postInteractAccentionOperateParams
} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest';
import { RmhInfoDTO } from 'wdBean'
import { RmhInfoDTO, CompDTO, ContentDTO } from 'wdBean'
import { CommonConstants } from 'wdConstant/Index';
import { DateTimeUtils, SPHelper, Logger, ToastUtils } from 'wdKit';
import { SpConstants } from 'wdConstant/Index'
... ... @@ -14,9 +14,14 @@ import router from '@ohos.router'
import { postBatchAttentionStatusParams } from 'wdBean/Index';
import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel'
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { InfomationCardClick } from '../../utils/infomationCardClick'
@Component
export struct RmhTitle {
@State compDTO: CompDTO = new CompDTO()
@State contentDTO: ContentDTO = new ContentDTO();
@State pageId: string = '';
@State pageName: string = '';
@Prop rmhInfo: RmhInfoDTO
@Prop publishTime: string | undefined
@State loadImg: boolean = false;
... ... @@ -48,6 +53,16 @@ export struct RmhTitle {
}
ContentDetailRequest.postInteractAccentionOperate(params2).then(res => {
console.log('rmhTitle-data', JSON.stringify(res.data))
InfomationCardClick.track(
this.compDTO,
this.contentDTO,
this.pageId,
this.pageName,
'follow', // like, commentClick, follow
this.followStatus == '0' ? true : false,
)
if (this.followStatus == '1') {
this.followStatus = '0'
} else {
... ...
... ... @@ -38,7 +38,16 @@ export struct Card12Component {
Column() {
// rmh信息
if (this.contentDTO.rmhInfo) {
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
RmhTitle(
{
rmhInfo: this.contentDTO.rmhInfo,
publishTime: this.contentDTO.publishTime,
contentDTO: this.contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
}
)
}
// 标题
if (this.contentDTO.newsTitle) {
... ...
... ... @@ -41,7 +41,16 @@ export struct Card14Component {
Column() {
// rmh信息
if (this.contentDTO.rmhInfo) {
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
RmhTitle(
{
rmhInfo: this.contentDTO.rmhInfo,
publishTime: this.contentDTO.publishTime,
contentDTO: this.contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
}
)
}
// 左标题,右图
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween }) {
... ...
... ... @@ -44,8 +44,16 @@ export struct Card15Component {
build() {
Column() {
// rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
//新闻标题
RmhTitle(
{
rmhInfo: this.contentDTO.rmhInfo,
publishTime: this.contentDTO.publishTime,
contentDTO: this.contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
}
) //新闻标题
if (this.contentDTO.newsTitle) {
Text() {
if (this.titleMarked) {
... ...
... ... @@ -46,7 +46,16 @@ export struct Card16Component {
Column() {
// rmh信息
if (this.contentDTO.rmhInfo) {
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
RmhTitle(
{
rmhInfo: this.contentDTO.rmhInfo,
publishTime: this.contentDTO.publishTime,
contentDTO: this.contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
}
)
}
// 标题
if (this.contentDTO.newsTitle) {
... ...
... ... @@ -38,8 +38,16 @@ export struct Card19Component {
build() {
Column() {
// rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
// 标题
RmhTitle(
{
rmhInfo: this.contentDTO.rmhInfo,
publishTime: this.contentDTO.publishTime,
contentDTO: this.contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
}
) // 标题
if (this.contentDTO.newsTitle) {
Text() {
if (this.titleMarked) {
... ...
... ... @@ -38,8 +38,16 @@ export struct Card20Component {
build() {
Column() {
// rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
// 标题
RmhTitle(
{
rmhInfo: this.contentDTO.rmhInfo,
publishTime: this.contentDTO.publishTime,
contentDTO: this.contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
}
) // 标题
if (this.contentDTO.newsTitle) {
Text() {
... ...
... ... @@ -40,8 +40,16 @@ export struct Card21Component {
build() {
Column() {
// 顶部 rmh信息
RmhTitle({ rmhInfo: this.contentDTO.rmhInfo, publishTime: this.contentDTO.publishTime })
// 中间内容
RmhTitle(
{
rmhInfo: this.contentDTO.rmhInfo,
publishTime: this.contentDTO.publishTime,
contentDTO: this.contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
}
) // 中间内容
Grid() {
GridItem() {
Text() {
... ...
... ... @@ -44,10 +44,25 @@ export struct Card5Component {
Image(this.loadImg ? this.contentDTO.coverUrl : '')
.backgroundColor(0xf5f5f5)
.width(CommonConstants.FULL_WIDTH)
.borderRadius($r('app.float.image_border_radius'))
.borderRadius(
{
topLeft: $r('app.float.image_border_radius'),
topRight: $r('app.float.image_border_radius'),
bottomLeft: $r('app.float.image_border_radius'),
bottomRight: $r('app.float.image_border_radius')
}
)
.aspectRatio(343 / 225)
if (this.titleShowPolicy === 1 || this.titleShowPolicy === null || this.titleShowPolicy === '') {
Row()
.borderRadius(
{
topLeft: $r('app.float.image_border_radius'),
topRight: $r('app.float.image_border_radius'),
bottomLeft: $r('app.float.image_border_radius'),
bottomRight: $r('app.float.image_border_radius')
}
)
.width(CommonConstants.FULL_WIDTH)
.height(59)
.linearGradient({
... ... @@ -55,6 +70,7 @@ export struct Card5Component {
['rgba(0, 0, 0, 0.0)', 0.0], ['rgba(0, 0, 0, 0.3)', 1.0]
]
})
Row() {
Stack() {
if(this.contentDTO.objectType == '5'){
... ... @@ -69,7 +85,7 @@ export struct Card5Component {
}
Text() {
if (this.titleMarked) {
if (this.titleMarked) {
ForEach(this.textArr, (textItem: textItem) => {
if (textItem.isRed) {
Span(textItem.content)
... ...
... ... @@ -256,12 +256,14 @@ export struct CommentComponent {
//获取数据
async getData() {
commentViewModel.fetchContentCommentList(this.currentPage + '', this.publishCommentModel.targetId,
let pageIndex = this.currentPage
commentViewModel.fetchContentCommentList(pageIndex + '', this.publishCommentModel.targetId,
this.publishCommentModel.targetType)
.then(commentListModel => {
console.log('评论:', JSON.stringify(commentListModel.list))
this.currentPage++
// 这里需要先赋值,否则下次UI刷新可能重复进入第1页两次
this.currentPage = pageIndex + 1
if (Number.parseInt(commentListModel.totalCommentNum) >
Number.parseInt(this.publishCommentModel.totalCommentNumer)) {
this.publishCommentModel.totalCommentNumer = commentListModel.totalCommentNum + ''
... ... @@ -279,7 +281,9 @@ export struct CommentComponent {
if (commentListModel && commentListModel.list && commentListModel.list.length > 0) {
this.allDatas.clearAllData() // 防止数据重复问题
if (pageIndex == 1) {
this.allDatas.clearAllData() // 防止数据重复问题
}
commentListModel.list.forEach(element => {
element.hasMore = Number.parseInt(element.childCommentNum) ? true : false
let newModel = commentViewModel.deepCopyCommentItemModel(element)
... ... @@ -289,7 +293,6 @@ export struct CommentComponent {
this.allDatas.push(newModel)
});
} else {
this.hasMore = false
}
... ... @@ -327,7 +330,7 @@ struct ChildCommentItem {
}
}
.maxLines(1)
.layoutWeight(1)
.flexShrink(1)
.fontSize(14)
.fontColor($r('app.color.color_222222'))
.fontWeight(FontWeight.Medium)
... ... @@ -338,7 +341,7 @@ struct ChildCommentItem {
/// 人民号>置顶>作者
//人民号
if (this.item.fromUserType !== 1) {
if (this.item.fromUserType == 2) {
Image($r('app.media.comment_rmh_tag')).width(20).height(20).margin({ left: 5 });
}
//置顶
... ... @@ -541,6 +544,8 @@ struct commentHeaderView {
//昵称
Text(this.item.fromUserName)
.fontSize(14)
.maxLines(1)
.flexShrink(1)
.fontColor($r('app.color.color_222222'))
.fontWeight(FontWeight.Medium)
.margin({ left: 5 })
... ... @@ -550,7 +555,7 @@ struct commentHeaderView {
/// 人民号>置顶>作者
//人民号
if (this.item.fromUserType !== 1) {
if (this.item.fromUserType == 2) {
Image($r('app.media.comment_rmh_tag')).width(20).height(20).margin({ left: 5 });
}
//置顶
... ...
... ... @@ -11,6 +11,7 @@ export struct CommentListDialogView {
@Link @Watch('showCommentListChange') showCommentList: boolean
@Link contentDetailData: ContentDetailDTO // 详情页传
@Link pageInfo: PageInfoDTO // 专题页传
@Link publishCommentModel: publishCommentModel
onClose?: () => void
// @Consume pageId: TrackConstants.PageName
... ... @@ -19,6 +20,7 @@ export struct CommentListDialogView {
private dialogController: CustomDialogController = new CustomDialogController({
builder: CommentListDialog({
contentDetailData: this.contentDetailData,
publishCommentModel:this.publishCommentModel,
pageInfo: this.pageInfo,
onClose: this.onClose
}),
... ... @@ -47,7 +49,7 @@ export struct CommentListDialogView {
struct CommentListDialog {
/// 内部使用
@State private publishCommentModel: publishCommentModel = new publishCommentModel()
@Link publishCommentModel: publishCommentModel
@State private operationButtonList: string[] = []
controller?: CustomDialogController
@State windowWidth: number = AppStorage.get<number>('windowWidth') || 0
... ...
... ... @@ -224,7 +224,8 @@ struct CarouselLayout01CardView {
// if (this.item.objectType == '5' || this.item.objectType == '6') {
// Notes({ objectType: this.item.objectType })
// }
Text(`${this.item.corner}${this.item.newsTitle}`)
//Text(`${this.item.corner}${this.item.newsTitle}`)
Text(`${this.item.newsTitle}`)
.width(CommonConstants.FULL_PARENT)
.fontColor(Color.White)
.fontSize($r('app.float.font_size_18'))
... ...
... ... @@ -102,7 +102,8 @@ export struct FollowListDetailUI {
}
}
}
.cachedCount(10)
.edgeEffect(EdgeEffect.None)
.cachedCount(5)
.padding({ left: '31lpx', right: '31lpx' })
.layoutWeight(1)
.scrollBar(BarState.Off)
... ...
... ... @@ -109,7 +109,7 @@ export struct HomePageBottomCommentComponent {
}
}
}
.cachedCount(15)
.cachedCount(5)
.layoutWeight(1)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
... ...
... ... @@ -177,7 +177,7 @@ export struct HomePageBottomFollowComponent {
}
}
}
.cachedCount(15)
.cachedCount(5)
.padding({ left: '31lpx', right: '31lpx' })
.layoutWeight(1)
.scrollBar(BarState.Off)
... ...
... ... @@ -109,7 +109,7 @@ export struct OtherHomePageBottomCommentComponent {
}
}
}
.cachedCount(15)
.cachedCount(5)
.layoutWeight(1)
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
... ...
... ... @@ -138,7 +138,7 @@ export struct OtherHomePageBottomFollowComponent{
ListHasNoMoreDataUI()
}
}
}.cachedCount(15)
}.cachedCount(5)
.padding({left:'31lpx',right:'31lpx'})
.layoutWeight(1)
.scrollBar(BarState.Off)
... ...
... ... @@ -289,7 +289,7 @@ export struct SearchResultContentComponent {
ListHasNoMoreDataUI()
}
}
}.cachedCount(10)
}.cachedCount(5)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.onReachEnd(() => {
... ... @@ -305,57 +305,6 @@ export struct SearchResultContentComponent {
}
@Builder
multiCreatorUI() {
Column() {
List() {
ForEach(this.data_rmh, (item: SearchRmhDescription, index: number) => {
ListItem() {
SearchCreatorComponent({ item: item })
}
.width('150lpx')
.height('100%')
})
ListItem() {
Column() {
Text("查看更多")
.width('19lpx')
.fontSize('19lpx')
.fontWeight('400lpx')
.lineHeight('27lpx')
.fontColor($r('app.color.color_9E9E9E'))
}
.borderRadius({ topLeft: '4lpx', bottomLeft: '4lpx' })
.height('180lpx')
.width('77lpx')
.backgroundColor($r('app.color.color_EDEDED'))
.justifyContent(FlexAlign.Center)
}.height('100%')
.margin({ left: '23lpx' })
.onClick(() => {
let params: Params = {
pageID: this.keywords
}
WDRouterRule.jumpWithPage(WDRouterPage.searchCreatorPage, params)
})
}
.cachedCount(6)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.listDirection(Axis.Horizontal)
.width('100%')
.height('219lpx')
Divider()
.width('100%')
.height('12lpx')
.color($r('app.color.color_F5F5F5'))
.strokeWidth('12lpx')
}
}
@Builder
SearchListUI() {
List({space:'8lpx'}) {
ForEach(this.data_rmh, (item: SearchRmhDescription, index: number) => {
... ...
... ... @@ -505,7 +505,7 @@ export struct OperRowListView {
// 评论组件需要数据
if (Number.parseInt(this.interactData.commentNum) >
Number.parseInt(this.publishCommentModel.totalCommentNumer)) {
this.publishCommentModel.totalCommentNumer = this.interactData.commentNum + '' || '0'
this.publishCommentModel.totalCommentNumer = this.interactData.commentNum + ''
}
}
// console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res))
... ...
... ... @@ -182,7 +182,7 @@ struct SearchCreatorPage {
ListHasNoMoreDataUI()
}
}
}.cachedCount(10)
}.cachedCount(5)
.padding({left:'31lpx',right:'31lpx'})
.layoutWeight(1)
.scrollBar(BarState.Off)
... ...
... ... @@ -43,10 +43,19 @@ export class InfomationCardClick {
return summaryType;
}
public static track(compDTO: CompDTO, contentDTO: ContentDTO, pageId: string, pageName: string): void {
public static track(
compDTO: CompDTO,
contentDTO: ContentDTO,
pageId: string,
pageName: string,
action = 'detailPageShow', // like, commentClick, follow
bl = false,
followUserId = '',
followUserName = ''
): void {
try {
const extParams: ParamType = {
'action': 'detailPageShow',
'action': action,
'shareChannel': '',
'duration': 0,
'contentName': contentDTO.newsTitle,
... ... @@ -87,7 +96,15 @@ export class InfomationCardClick {
extParams['saAuthorName'] = contentDTO.source;
}
console.log('InfomationCardClick-params:', JSON.stringify(extParams))
TrackingContent.common(TrackConstants.EventType.Click, pageId, pageName, extParams)
if (action === 'detailPageShow') {
TrackingContent.common(TrackConstants.EventType.Click, pageId, pageName, extParams);
} else if (action === 'like') {
TrackingContent.like(bl, pageId, pageName, extParams);
} else if (action === 'commentClick') {
TrackingContent.commentClick(pageId, pageName, extParams);
} else if (action === 'follow') {
TrackingContent.follow(bl, followUserId, followUserName, pageId, pageName, extParams)
}
} catch (err) {
console.log('InfomationCardClick-err', JSON.stringify(err))
}
... ...
... ... @@ -112,6 +112,23 @@ export struct DetailPlayLiveCommon {
})
}
// /**
// *
// * @returns true : 沉浸式;false : 非沉浸式
// */
// isImmersionLive(): boolean {
//
// let flag = false
//
// if (this.liveState === 'wait' || this.liveLandscape === 'news') {
// flag = false
// } else if (this.liveLandscape === 'general') {
// flag = true
// }
//
// return flag
// }
onPageShow() {
this.pageShow = Math.random()
Logger.info(TAG, 'onPageShow')
... ...
... ... @@ -119,8 +119,8 @@ export struct DetailPlayLivePage {
getLiveDetails() {
const data = this.contentDetailData
console.error("XXXXZZZZ", 'contentDetailData ----liveState==>' + data.liveInfo?.liveState)
console.error("XXXXZZZZ", 'contentDetailData ----liveStyle==>' + data.liveInfo?.liveStyle)
// console.error("XXXXZZZZ", 'contentDetailData ----liveState==>' + data.liveInfo?.liveState)
// console.error("XXXXZZZZ", 'contentDetailData ----liveStyle==>' + data.liveInfo?.liveStyle)
if (data.liveInfo?.liveState == 'wait') {
//直播样式 0-正常模式 , 1-隐藏直播间,2-隐藏大家聊 【人民号发布是竖屏的,为空】
if (data.liveInfo?.liveStyle == 1) {
... ...
import { window } from '@kit.ArkUI'
import { window } from '@kit.ArkUI';
import lottie from '@ohos/lottie';
import { NumberFormatterUtils, StringUtils, WindowModel } from 'wdKit/Index'
import { DateFormatUtil, WDAliPlayerController, WDPlayerController } from 'wdPlayer/Index'
import { ContentDetailDTO, LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index'
import { DisplayDirection } from 'wdConstant/Index'
import { LiveFollowComponent, LottieView } from 'wdComponent/Index'
import { NumberFormatterUtils, StringUtils, WindowModel } from 'wdKit/Index';
import { DateFormatUtil, PlayerConstants, WDAliPlayerController } from 'wdPlayer/Index';
import { ContentDetailDTO, LiveRoomDataBean } from 'wdBean/Index';
import { DisplayDirection } from 'wdConstant/Index';
import { LiveFollowComponent, LottieView } from 'wdComponent/Index';
@Component
export struct PlayUIComponent {
playerController?: WDAliPlayerController;
//菜单键是否可见
@State @Watch('onChangeMenuVisible') isMenuVisible: boolean = true
// @Consume liveDetailsBean: LiveDetailsBean
@Consume contentDetailData: ContentDetailDTO
@Consume liveRoomDataBean: LiveRoomDataBean
@State currentTime: string = ''
... ... @@ -21,8 +20,11 @@ export struct PlayUIComponent {
//是否处于播放状态中
@State isPlayStatus: boolean = true
@Consume displayDirection: DisplayDirection
@Prop isShowBottom: boolean
// 播放地址 (视频或者 直播地址)
@Prop liveUrl: string
// 当前播放资源的状态
@Consume playSourceState: number
onChangeMenuVisible() {
if (!this.contentDetailData || !this.contentDetailData.liveInfo ||
... ... @@ -41,6 +43,21 @@ export struct PlayUIComponent {
aboutToAppear(): void {
this.onChangeMenuVisible()
this.initPlayerSet()
}
aboutToDisappear(): void {
if (this.contentDetailData.liveInfo?.liveState == 'running') {
lottie.destroy('live_status_wait')
}
}
/*
初始话播放器设置
*/
initPlayerSet(){
//播放进度监听
if (this.playerController) {
this.playerController.onTimeUpdate = (position: number, duration: number) => {
... ... @@ -49,12 +66,7 @@ export struct PlayUIComponent {
this.progressVal = Math.floor(position * 100 / duration);
}
}
}
aboutToDisappear(): void {
if (this.contentDetailData.liveInfo?.liveState == 'running') {
lottie.destroy('live_status_wait')
}
}
build() {
... ... @@ -62,7 +74,7 @@ export struct PlayUIComponent {
if (this.contentDetailData && this.contentDetailData.liveInfo) {
this.getTopUIComponent()
this.getMiddleUIComponent()
if(this.isShowBottom){
if (this.isShowBottom) {
this.getBottomUIComponent()
}
... ... @@ -251,16 +263,13 @@ export struct PlayUIComponent {
@Builder
getBottomUIComponent() {
Row() {
if (this.contentDetailData?.liveInfo?.liveState == 'wait') {
Blank()
} else if (this.contentDetailData?.liveInfo?.liveState == 'running') {
// 视频资源
if (!StringUtils.isEmpty(this.liveUrl)) {
// 暂定和播放按钮
this.playOrPauseBtn()
Blank()
} else if (this.contentDetailData?.liveInfo?.liveState == 'end') {
if (StringUtils.isEmpty(this.contentDetailData?.liveInfo?.vlive[0]?.replayUri)) {
Blank()
} else {
this.playOrPauseBtn()
// 开始时间
if (this.contentDetailData?.liveInfo?.liveState != 'running' || this.contentDetailData.showTime) {
Text(this.currentTime)
.fontColor(Color.White)
.fontWeight(600)
... ... @@ -268,7 +277,12 @@ export struct PlayUIComponent {
.margin({
left: 16
})
this.playProgressView()
}
// 进度条
this.playProgressView()
// 总的播放时间
if (this.contentDetailData?.liveInfo?.liveState != 'running' || this.contentDetailData.showTime) {
Text(this.totalTime)
.fontColor(Color.White)
.fontWeight(600)
... ... @@ -277,11 +291,13 @@ export struct PlayUIComponent {
right: 16
})
}
} else {
Blank()
}
if (this.contentDetailData?.liveInfo?.liveState == 'running'
|| (this.contentDetailData?.liveInfo?.liveState == 'end' &&
StringUtils.isNotEmpty(this.contentDetailData?.liveInfo?.vlive[0]?.replayUri))
) {
// 全屏按钮
if (!StringUtils.isEmpty(this.liveUrl)) {
Image($r('app.media.icon_live_player_full_screen'))
.width(24)
.height(24)
... ... @@ -298,6 +314,7 @@ export struct PlayUIComponent {
})
.visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None)
}
}
.alignItems(VerticalAlign.Center)
.linearGradient({ angle: 0, colors: [['#99000000', 0], ['#00000000', 1]] })
... ... @@ -313,19 +330,34 @@ export struct PlayUIComponent {
@Builder
playOrPauseBtn() {
//暂停、播放
Image(this.isPlayStatus ? $r('app.media.icon_live_player_pause') : $r('app.media.player_play_ic'))
.width(24)
.height(24)
.onClick(() => {
if (this.isPlayStatus) {
this.isPlayStatus = false
this.playerController?.pause()
} else {
if (this.playSourceState === PlayerConstants.STATUS_COMPLETION) {
//资源播放完成
Image($r('app.media.player_play_ic'))
.width(24)
.height(24)
.onClick(() => {
this.isPlayStatus = true
this.initPlayerSet()
this.playerController?.firstPlay(this.liveUrl)
this.playerController?.play()
}
})
})
} else {
//暂停、播放
Image(this.isPlayStatus ? $r('app.media.icon_live_player_pause') : $r('app.media.player_play_ic'))
.width(24)
.height(24)
.onClick(() => {
if (this.isPlayStatus) {
this.isPlayStatus = false
this.playerController?.pause()
} else {
this.isPlayStatus = true
this.playerController?.play()
}
})
}
}
@Builder
... ...
... ... @@ -13,7 +13,9 @@ const TAG: string = 'TopPlayComponent'
export struct TopPlayComponent {
@Consume @Watch('updateData') contentDetailData: ContentDetailDTO
playerController?: WDAliPlayerController
@State imgUrl: string = ''
// 预告片图片/视频url
@State previewUrl: string = ''
@State isVideoSource: boolean = false
//未开始
@State isWait: boolean = false
//已结束直播
... ... @@ -24,14 +26,15 @@ export struct TopPlayComponent {
@State isLoading: boolean = false
// 获取播放资源能播放了
@State isCanPlay: boolean = false
// 当前播放资源的状态
@Provide playSourceState: number = 0
private playUrl: string = ""
private xComponentIsLoaded: boolean = false
aboutToAppear(): void {
if (this.playerController) {
this.playerController.onCanplay = () => {
Logger.debug(TAG, 'onCanplay==>')
this.isCanPlay = true
this.isLoading = true
this.playerController?.play()
... ... @@ -40,35 +43,56 @@ export struct TopPlayComponent {
this.playerController.onStatusChange = (status: number) => {
this.playSourceState = status
Logger.debug(TAG, 'status==>' + status)
if (status === PlayerConstants.STATUS_ERROR) {
this.isError = true
this.isLoading = true
this.isCanPlay = false
} else if (status === PlayerConstants.STATUS_COMPLETION) {
// 播放完成
} else {
this.isError = false
}
}
}
this.updateData()
}
updateData() {
// 检测等待中的直播预告是否视频资源
if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.previewType === 1
&& this.contentDetailData.liveInfo.previewUrl &&
this.contentDetailData.liveInfo.previewUrl.length > 0) {
// 预告资源是视频
this.isVideoSource = true
this.contentDetailData.showTime = true
}
//直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停
if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.previewUrl &&
this.contentDetailData.liveInfo.previewUrl.length > 0) {
this.imgUrl = this.contentDetailData.liveInfo.previewUrl
Logger.debug(TAG, 'ok+' + `${this.imgUrl}`)
this.previewUrl = this.contentDetailData.liveInfo.previewUrl
} else if (this.contentDetailData.fullColumnImgUrls && this.contentDetailData.fullColumnImgUrls.length > 0) {
this.imgUrl = this.contentDetailData.fullColumnImgUrls[0].url
Logger.debug(TAG, 'ok-' + `${this.imgUrl}`)
this.previewUrl = this.contentDetailData.fullColumnImgUrls[0].url
}
this.isWait = this.contentDetailData?.liveInfo?.liveState == 'wait'
if(this.isWait ){
this.isLoading = true
Logger.debug(TAG, 'ok+' + `${this.previewUrl}`)
if (this.isVideoSource) {
this.isWait = false
this.isLoading = false
} else {
this.isWait = this.contentDetailData?.liveInfo?.liveState == 'wait'
if (this.isWait) {
this.isLoading = true
}
}
this.isEnd = this.contentDetailData?.liveInfo?.liveState === 'end' &&
StringUtils.isEmpty(this.contentDetailData?.liveInfo?.vlive[0]?.replayUri)
if (!this.isWait && this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.vlive.length > 0) {
... ... @@ -78,12 +102,18 @@ export struct TopPlayComponent {
} else if (this.contentDetailData.liveInfo.liveState == 'end') {
playUrl = this.contentDetailData.liveInfo.vlive[0].replayUri
}
// this.playerController?.firstPlay('https://rmrbcmsonline.peopleapp.com/upload/rmh/video/mp4/202404/1713752415708fb81d0b8f137b.mp4');
if (StringUtils.isNotEmpty(playUrl)) {
Logger.debug(TAG, `${playUrl}`)
this.playUrl = playUrl
if (this.isVideoSource) {
this.playUrl = this.previewUrl
this.tryToPlay()
} else {
if (StringUtils.isNotEmpty(playUrl)) {
Logger.debug(TAG, `${playUrl}`)
this.playUrl = playUrl
this.tryToPlay()
}
}
}
}
... ... @@ -115,18 +145,22 @@ export struct TopPlayComponent {
.width('100%')
.visibility(this.isWait ? Visibility.None : Visibility.Visible)
// 直播房间图
Image(this.imgUrl)
.objectFit(ImageFit.Cover)
.visibility(this.isWait || this.isEnd ? Visibility.Visible : Visibility.None)
.contrast(this.isEnd ? 0.2 : 1)
.width('100%')
if (this.isVideoSource) {
} else {
// 直播房间图
Image(this.previewUrl)
.objectFit(ImageFit.Cover)
.visibility(this.isWait || this.isEnd ? Visibility.Visible : Visibility.None)
.contrast(this.isEnd ? 0.2 : 1)
.width('100%')
}
// loading
PictureLoading().visibility(this.isLoading ? Visibility.None : Visibility.Visible)
// 视频播放器上的控制面板和信息
PlayUIComponent({ playerController: this.playerController, isShowBottom: this.isCanPlay })
PlayUIComponent({ playerController: this.playerController, isShowBottom: this.isCanPlay, liveUrl: this.playUrl })
// 直播结束
Text('直播已结束')
... ...
... ... @@ -182,7 +182,7 @@ export struct DetailPlayShortVideoPage {
index: $index,
currentIndex: $currentIndex,
showCommentList: $showCommentList,
// publishCommentModel: $publishCommentModel
publishCommentModel: $publishCommentModel
})
this.playerViewBuilder()
... ...
import { ContentDetailDTO, PageInfoDTO } from 'wdBean/Index'
import { CommentListDialogView } from 'wdComponent/Index'
import { CommentListDialogView, publishCommentModel } from 'wdComponent/Index'
@Component
export struct CommentDialogView {
@Link @Watch('showCommentListChange') showCommentList: boolean
@Link index: number
@Link currentIndex: number
@Link publishCommentModel: publishCommentModel
@Consume contentDetailData: ContentDetailDTO
@State fakePageInfo: PageInfoDTO = {} as PageInfoDTO
@State dialogOffsetY: number = 0 // (this.windowHeight - this.windowWidth * 9 / 16)
... ... @@ -29,6 +30,7 @@ export struct CommentDialogView {
CommentListDialogView({
showCommentList: this.innerShowComment,
contentDetailData: this.contentDetailData,
publishCommentModel: this.publishCommentModel,
pageInfo: this.fakePageInfo,
onClose: () => {
this.showCommentList = false
... ...
... ... @@ -50,8 +50,6 @@ export struct WDPlayerRenderLiveView {
aboutToAppear() {
MGPlayRenderViewIns.add();
console.log('playerController', this.playerController)
insIndex++;
if (!this.playerController) {
return
... ... @@ -59,7 +57,6 @@ export struct WDPlayerRenderLiveView {
this.playerController.onVideoSizeChange = (width: number, height: number) => {
// console.log(`WDPlayerRenderView onVideoSizeChange width:${width} videoTop:${height}`)
Logger.info(TAG, ` onVideoSizeChange width:${width} videoTop:${height}`)
this.videoWidth = width;
this.videoHeight = height;
this.updateLayout()
... ... @@ -83,8 +80,6 @@ export struct WDPlayerRenderLiveView {
.onLoad(async (event) => {
Logger.info(TAG, 'onLoad')
let surfaceId = this.xComponentController.getXComponentSurfaceId()
console.log('surfaceId===', surfaceId)
console.log('insId===', this.insId)
this.xComponentController.setXComponentSurfaceSize({
surfaceWidth: 1920,
surfaceHeight: 720
... ...
... ... @@ -116,7 +116,7 @@ export struct MultiPictureDetailPageComponent {
index: $index,
currentIndex: $currentIndex,
showCommentList: $showCommentList,
// publishCommentModel: $publishCommentModel
publishCommentModel: $publishCommentModel
})
}
... ...