Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
liyubing
2024-05-30 15:34:18 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
65533739917cbf007235ef6983052287ce456bd6
65533739
1 parent
3c489aca
feat:直播详情页面,播放器埋点事件
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
16 deletions
sight_harmony/features/wdDetailPlayLive/src/main/ets/pages/DetailPlayLiveCommon.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/details/video/TopPlayComponet.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerComponent.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerInfoComponent.ets
sight_harmony/features/wdPlayer/src/main/ets/controller/WDAliPlayerController.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/pages/DetailPlayLiveCommon.ets
View file @
6553373
...
...
@@ -4,9 +4,10 @@ import router from '@ohos.router';
import { DetailPlayLivePage } from './DetailPlayLivePage';
import { DetailPlayVLivePage } from './DetailPlayVLivePage';
import { Logger, ToastUtils } from 'wdKit/Index';
import {
DateTimeUtils,
Logger, ToastUtils } from 'wdKit/Index';
import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel';
import { PictureLoading } from '../widgets/vertical/PictureLoading';
import { TrackConstants, TrackingButton, TrackingPageBrowse } from 'wdTracking/Index';
const TAG = 'DetailPlayLiveCommon'
...
...
@@ -22,6 +23,7 @@ const TAG = 'DetailPlayLiveCommon'
@Component
export struct DetailPlayLiveCommon {
private liveViewModel: LiveViewModel = new LiveViewModel()
pageShowTime:number = 0;
@Provide relId: string = ''
@Provide contentId: string = ''
@Provide relType: string = ''
...
...
@@ -49,6 +51,12 @@ export struct DetailPlayLiveCommon {
}
aboutToDisappear(): void {
console.error("XXXXZZZZ", '---aboutToDisappear------------')
}
build() {
Column() {
// 直播预约或横屏直播统一进横屏直播
...
...
@@ -120,7 +128,6 @@ export struct DetailPlayLiveCommon {
this.playUrl = detailData.liveInfo.vlive[0].replayUri
}
} else {
this.isLoading
ToastUtils.shortToast('内容不存在')
...
...
@@ -139,11 +146,17 @@ export struct DetailPlayLiveCommon {
onPageShow() {
this.pageShow = Math.random()
Logger.info(TAG, 'onPageShow')
this.pageShowTime = DateTimeUtils.getTimeStamp()
}
onPageHide() {
this.pageHide = Math.random()
Logger.info(TAG, 'onPageHide')
console.error("XXXXZZZZ", '---onPageHide------------')
//页面浏览
TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Live_Detail,TrackConstants.PageName.Live_Detail
,Math.floor((DateTimeUtils.getTimeStamp() - this.pageShowTime)/1000))
}
onBackPress(): boolean | void {
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/details/video/TopPlayComponet.ets
View file @
6553373
...
...
@@ -3,6 +3,7 @@ import { Logger, StringUtils } from 'wdKit/Index';
import { PlayerConstants, WDAliPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index';
import { PlayUIComponent } from './PlayUIComponent';
import { PictureLoading } from '../../vertical/PictureLoading';
import { ParamType, TrackConstants } from 'wdTracking/Index';
const TAG: string = 'TopPlayComponent'
...
...
@@ -31,11 +32,11 @@ export struct TopPlayComponent {
@Provide playSourceState: number = 0
private playUrl: string = ""
private xComponentIsLoaded: boolean = false
pageParam: ParamType = {}
aboutToAppear(): void {
if (this.playerController) {
this.playerController.onCanplay = () => {
Logger.debug(TAG, 'onCanplay==>')
this.isCanPlay = true
this.isLoading = true
this.playerController?.play()
...
...
@@ -98,7 +99,7 @@ export struct TopPlayComponent {
this.isEnd = this.contentDetailData?.liveInfo?.liveState === 'end' &&
StringUtils.isEmpty(this.contentDetailData?.liveInfo?.vlive[0]?.replayUri)
// Logger.debug(TAG, `---0------>` + this.isWait + ' ->' + this.isLoading + ' ->' + this.isEnd)
// Logger.debug(TAG, `---0------>` + this.isWait + ' ->' + this.isLoading + ' ->' + this.isEnd)
if (!this.isWait) {
if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.vlive.length > 0) {
let playUrl = ''
...
...
@@ -147,7 +148,16 @@ export struct TopPlayComponent {
Logger.debug(TAG, "播放地址为空")
return
}
this.playerController?.firstPlay(this.playUrl);
this.contentTrackingDict()
this.playerController?.firstPlay(this.playUrl, TrackConstants.PageName.Live_Detail, this.pageParam);
}
contentTrackingDict() {
this.pageParam = {
'contentType': `${this.contentDetailData.newsType}`,
'contentId': `${this.contentDetailData.newsId}`,
'contentName': `${this.contentDetailData.newsTitle || ''}`,
}
}
build() {
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerComponent.ets
View file @
6553373
import { ContentDetailDTO } from 'wdBean/Index';
import { AliPlayerRenderView, WDAliPlayerController, WDPlayerRenderVLiveView } from 'wdPlayer/Index';
import { ParamType, TrackConstants } from 'wdTracking/Index';
import { PictureLoading } from './PictureLoading';
const TAG = 'PlayerComponent'
@Component
export struct PlayerComponent {
private playerController?: WDAliPlayerController
@Consume @Watch('updateData') contentDetailData: ContentDetailDTO
@Consume @Watch('pageShowChange') pageShow: number
...
...
@@ -21,6 +21,7 @@ export struct PlayerComponent {
@State liveStreamType: number | null = -1
@State playUrl: string = ''
@State isCanplay: boolean = false
pageParam: ParamType = {}
pageShowChange() {
this.playerController?.play()
...
...
@@ -76,7 +77,8 @@ export struct PlayerComponent {
playerController: this.playerController,
onLoad: () => {
this.isCanplay = true
this.playerController?.firstPlay(this.playUrl);
this.contentTrackingDict()
this.playerController?.firstPlay(this.playUrl, TrackConstants.PageName.Live_Detail, this.pageParam);
}
})
} else if (this.liveStreamType == 0) {
...
...
@@ -84,7 +86,8 @@ export struct PlayerComponent {
playerController: this.playerController,
onLoad: () => {
this.isCanplay = true
this.playerController?.firstPlay(this.playUrl);
this.contentTrackingDict()
this.playerController?.firstPlay(this.playUrl, TrackConstants.PageName.Live_Detail, this.pageParam);
}
}).margin({ top: 195 }).height(211)
}
...
...
@@ -106,4 +109,12 @@ export struct PlayerComponent {
.height('100%')
.width('100%')
}
contentTrackingDict() {
this.pageParam = {
'contentType': `${this.contentDetailData.newsType}`,
'contentId': `${this.contentDetailData.newsId}`,
'contentName': `${this.contentDetailData.newsTitle || ''}`,
}
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerInfoComponent.ets
View file @
6553373
import { WDAliPlayerController
, WDPlayerController
} from 'wdPlayer/Index'
import { WDAliPlayerController } from 'wdPlayer/Index'
import { PlayerUIComponent } from './PlayerUIComponent'
@Component
...
...
sight_harmony/features/wdPlayer/src/main/ets/controller/WDAliPlayerController.ets
View file @
6553373
...
...
@@ -13,7 +13,8 @@ import {
import { initGlobalPlayerSettings, setupPlayerConfig } from '../utils/GlobalSetting';
import prompt from '@ohos.promptAction';
import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants';
import { Logger, StringUtils } from 'wdKit/Index';
import { DateTimeUtils, Logger, StringUtils } from 'wdKit/Index';
import { ParamType, TrackingPlay } from 'wdTracking/Index';
const TAG = "WDAliPlayerController"
...
...
@@ -50,6 +51,11 @@ export class WDAliPlayerController {
public onCanplay?: () => void;
public onStatusChange?: (status: number) => void;
public onFirstFrameDisplay?: () => void
// 埋点字段
private creatStartTime: number = 0; //开始加载时间
private creatEndTime: number = 0; //加载完成时间
private pageParam: ParamType = {}
private pageName: string = ''
constructor() {
Logger.info(TAG, "初始化")
...
...
@@ -102,11 +108,29 @@ export class WDAliPlayerController {
if (this.onFirstFrameDisplay) {
this.onFirstFrameDisplay()
}
if (this.pageParam) {
console.log('播放视频pageParam', JSON.stringify(this.pageParam))
// 播放埋点
TrackingPlay.videoPositivePlay(Math.floor((DateTimeUtils.getTimeStamp() - this.creatStartTime) / 1000),
this.pageName, this.pageName, this.pageParam)
}
}
});
this.avPlayer?.setOnCompletionListener({
onCompletion: () => {
Logger.debug(TAG, "播放完成")
if (this.pageParam) {
let initDuration = Math.floor(Number(this.duration) / 1000)
let currentPlayTime: number = Math.floor((DateTimeUtils.getTimeStamp() - this.creatStartTime) / 1000) //当前播放时间
console.log('播放结束')
// 播放结束埋点
TrackingPlay.videoPlayEnd(currentPlayTime, initDuration, currentPlayTime, this.pageName, this.pageName,
this.pageParam)
}
}
});
this.avPlayer?.setOnInfoListener({
...
...
@@ -197,6 +221,9 @@ export class WDAliPlayerController {
this.errorMesage = errorInfo.getMsg()
this.status = PlayerConstants.STATUS_ERROR;
this.watchStatus();
console.log('播放错误',JSON.stringify(error))
TrackingPlay.videoPlayError(errorInfo.getMsg(), this.pageName, this.pageName, this.pageParam)
}
});
this.avPlayer?.setOnLoadingStatusListener({
...
...
@@ -265,12 +292,20 @@ export class WDAliPlayerController {
}
}
async firstPlay(url: string) {
async firstPlay(url: string
, pageName?: string, pageParam?: ParamType
) {
if (StringUtils.isEmpty(url)) {
Logger.error(TAG, "播放链接为空")
return
}
this.creatStartTime = DateTimeUtils.getTimeStamp()
if (pageName) {
this.pageName = pageName
}
if (pageParam) {
this.pageParam = pageParam
}
this.url = url;
if (this.avPlayer == null) {
Logger.info(TAG, "等待播放器初始化")
...
...
@@ -457,11 +492,7 @@ export class WDAliPlayerController {
if (this.onStatusChange) {
this.onStatusChange(this.status)
}
// if (this.status === PlayConstants.STATUS_START) {
// globalThis.windowClass.setWindowKeepScreenOn(true);
// } else {
// globalThis.windowClass.setWindowKeepScreenOn(false);
// }
}
playError(msg?: string) {
...
...
Please
register
or
login
to post a comment