Showing
5 changed files
with
81 additions
and
16 deletions
| @@ -4,9 +4,10 @@ import router from '@ohos.router'; | @@ -4,9 +4,10 @@ import router from '@ohos.router'; | ||
| 4 | 4 | ||
| 5 | import { DetailPlayLivePage } from './DetailPlayLivePage'; | 5 | import { DetailPlayLivePage } from './DetailPlayLivePage'; |
| 6 | import { DetailPlayVLivePage } from './DetailPlayVLivePage'; | 6 | import { DetailPlayVLivePage } from './DetailPlayVLivePage'; |
| 7 | -import { Logger, ToastUtils } from 'wdKit/Index'; | 7 | +import { DateTimeUtils, Logger, ToastUtils } from 'wdKit/Index'; |
| 8 | import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel'; | 8 | import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel'; |
| 9 | import { PictureLoading } from '../widgets/vertical/PictureLoading'; | 9 | import { PictureLoading } from '../widgets/vertical/PictureLoading'; |
| 10 | +import { TrackConstants, TrackingButton, TrackingPageBrowse } from 'wdTracking/Index'; | ||
| 10 | 11 | ||
| 11 | const TAG = 'DetailPlayLiveCommon' | 12 | const TAG = 'DetailPlayLiveCommon' |
| 12 | 13 | ||
| @@ -22,6 +23,7 @@ const TAG = 'DetailPlayLiveCommon' | @@ -22,6 +23,7 @@ const TAG = 'DetailPlayLiveCommon' | ||
| 22 | @Component | 23 | @Component |
| 23 | export struct DetailPlayLiveCommon { | 24 | export struct DetailPlayLiveCommon { |
| 24 | private liveViewModel: LiveViewModel = new LiveViewModel() | 25 | private liveViewModel: LiveViewModel = new LiveViewModel() |
| 26 | + pageShowTime:number = 0; | ||
| 25 | @Provide relId: string = '' | 27 | @Provide relId: string = '' |
| 26 | @Provide contentId: string = '' | 28 | @Provide contentId: string = '' |
| 27 | @Provide relType: string = '' | 29 | @Provide relType: string = '' |
| @@ -49,6 +51,12 @@ export struct DetailPlayLiveCommon { | @@ -49,6 +51,12 @@ export struct DetailPlayLiveCommon { | ||
| 49 | 51 | ||
| 50 | } | 52 | } |
| 51 | 53 | ||
| 54 | + aboutToDisappear(): void { | ||
| 55 | + console.error("XXXXZZZZ", '---aboutToDisappear------------') | ||
| 56 | + | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + | ||
| 52 | build() { | 60 | build() { |
| 53 | Column() { | 61 | Column() { |
| 54 | // 直播预约或横屏直播统一进横屏直播 | 62 | // 直播预约或横屏直播统一进横屏直播 |
| @@ -120,7 +128,6 @@ export struct DetailPlayLiveCommon { | @@ -120,7 +128,6 @@ export struct DetailPlayLiveCommon { | ||
| 120 | this.playUrl = detailData.liveInfo.vlive[0].replayUri | 128 | this.playUrl = detailData.liveInfo.vlive[0].replayUri |
| 121 | } | 129 | } |
| 122 | 130 | ||
| 123 | - | ||
| 124 | } else { | 131 | } else { |
| 125 | this.isLoading | 132 | this.isLoading |
| 126 | ToastUtils.shortToast('内容不存在') | 133 | ToastUtils.shortToast('内容不存在') |
| @@ -139,11 +146,17 @@ export struct DetailPlayLiveCommon { | @@ -139,11 +146,17 @@ export struct DetailPlayLiveCommon { | ||
| 139 | onPageShow() { | 146 | onPageShow() { |
| 140 | this.pageShow = Math.random() | 147 | this.pageShow = Math.random() |
| 141 | Logger.info(TAG, 'onPageShow') | 148 | Logger.info(TAG, 'onPageShow') |
| 149 | + this.pageShowTime = DateTimeUtils.getTimeStamp() | ||
| 142 | } | 150 | } |
| 143 | 151 | ||
| 144 | onPageHide() { | 152 | onPageHide() { |
| 145 | this.pageHide = Math.random() | 153 | this.pageHide = Math.random() |
| 146 | Logger.info(TAG, 'onPageHide') | 154 | Logger.info(TAG, 'onPageHide') |
| 155 | + console.error("XXXXZZZZ", '---onPageHide------------') | ||
| 156 | + //页面浏览 | ||
| 157 | + TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Live_Detail,TrackConstants.PageName.Live_Detail | ||
| 158 | + ,Math.floor((DateTimeUtils.getTimeStamp() - this.pageShowTime)/1000)) | ||
| 159 | + | ||
| 147 | } | 160 | } |
| 148 | 161 | ||
| 149 | onBackPress(): boolean | void { | 162 | onBackPress(): boolean | void { |
| @@ -3,6 +3,7 @@ import { Logger, StringUtils } from 'wdKit/Index'; | @@ -3,6 +3,7 @@ import { Logger, StringUtils } from 'wdKit/Index'; | ||
| 3 | import { PlayerConstants, WDAliPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index'; | 3 | import { PlayerConstants, WDAliPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index'; |
| 4 | import { PlayUIComponent } from './PlayUIComponent'; | 4 | import { PlayUIComponent } from './PlayUIComponent'; |
| 5 | import { PictureLoading } from '../../vertical/PictureLoading'; | 5 | import { PictureLoading } from '../../vertical/PictureLoading'; |
| 6 | +import { ParamType, TrackConstants } from 'wdTracking/Index'; | ||
| 6 | 7 | ||
| 7 | const TAG: string = 'TopPlayComponent' | 8 | const TAG: string = 'TopPlayComponent' |
| 8 | 9 | ||
| @@ -31,11 +32,11 @@ export struct TopPlayComponent { | @@ -31,11 +32,11 @@ export struct TopPlayComponent { | ||
| 31 | @Provide playSourceState: number = 0 | 32 | @Provide playSourceState: number = 0 |
| 32 | private playUrl: string = "" | 33 | private playUrl: string = "" |
| 33 | private xComponentIsLoaded: boolean = false | 34 | private xComponentIsLoaded: boolean = false |
| 35 | + pageParam: ParamType = {} | ||
| 34 | 36 | ||
| 35 | aboutToAppear(): void { | 37 | aboutToAppear(): void { |
| 36 | if (this.playerController) { | 38 | if (this.playerController) { |
| 37 | this.playerController.onCanplay = () => { | 39 | this.playerController.onCanplay = () => { |
| 38 | - Logger.debug(TAG, 'onCanplay==>') | ||
| 39 | this.isCanPlay = true | 40 | this.isCanPlay = true |
| 40 | this.isLoading = true | 41 | this.isLoading = true |
| 41 | this.playerController?.play() | 42 | this.playerController?.play() |
| @@ -98,7 +99,7 @@ export struct TopPlayComponent { | @@ -98,7 +99,7 @@ export struct TopPlayComponent { | ||
| 98 | this.isEnd = this.contentDetailData?.liveInfo?.liveState === 'end' && | 99 | this.isEnd = this.contentDetailData?.liveInfo?.liveState === 'end' && |
| 99 | StringUtils.isEmpty(this.contentDetailData?.liveInfo?.vlive[0]?.replayUri) | 100 | StringUtils.isEmpty(this.contentDetailData?.liveInfo?.vlive[0]?.replayUri) |
| 100 | 101 | ||
| 101 | - // Logger.debug(TAG, `---0------>` + this.isWait + ' ->' + this.isLoading + ' ->' + this.isEnd) | 102 | + // Logger.debug(TAG, `---0------>` + this.isWait + ' ->' + this.isLoading + ' ->' + this.isEnd) |
| 102 | if (!this.isWait) { | 103 | if (!this.isWait) { |
| 103 | if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.vlive.length > 0) { | 104 | if (this.contentDetailData.liveInfo && this.contentDetailData.liveInfo.vlive.length > 0) { |
| 104 | let playUrl = '' | 105 | let playUrl = '' |
| @@ -147,7 +148,16 @@ export struct TopPlayComponent { | @@ -147,7 +148,16 @@ export struct TopPlayComponent { | ||
| 147 | Logger.debug(TAG, "播放地址为空") | 148 | Logger.debug(TAG, "播放地址为空") |
| 148 | return | 149 | return |
| 149 | } | 150 | } |
| 150 | - this.playerController?.firstPlay(this.playUrl); | 151 | + this.contentTrackingDict() |
| 152 | + this.playerController?.firstPlay(this.playUrl, TrackConstants.PageName.Live_Detail, this.pageParam); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + contentTrackingDict() { | ||
| 156 | + this.pageParam = { | ||
| 157 | + 'contentType': `${this.contentDetailData.newsType}`, | ||
| 158 | + 'contentId': `${this.contentDetailData.newsId}`, | ||
| 159 | + 'contentName': `${this.contentDetailData.newsTitle || ''}`, | ||
| 160 | + } | ||
| 151 | } | 161 | } |
| 152 | 162 | ||
| 153 | build() { | 163 | build() { |
| 1 | import { ContentDetailDTO } from 'wdBean/Index'; | 1 | import { ContentDetailDTO } from 'wdBean/Index'; |
| 2 | import { AliPlayerRenderView, WDAliPlayerController, WDPlayerRenderVLiveView } from 'wdPlayer/Index'; | 2 | import { AliPlayerRenderView, WDAliPlayerController, WDPlayerRenderVLiveView } from 'wdPlayer/Index'; |
| 3 | +import { ParamType, TrackConstants } from 'wdTracking/Index'; | ||
| 3 | import { PictureLoading } from './PictureLoading'; | 4 | import { PictureLoading } from './PictureLoading'; |
| 4 | 5 | ||
| 5 | const TAG = 'PlayerComponent' | 6 | const TAG = 'PlayerComponent' |
| 6 | 7 | ||
| 7 | @Component | 8 | @Component |
| 8 | export struct PlayerComponent { | 9 | export struct PlayerComponent { |
| 9 | - | ||
| 10 | private playerController?: WDAliPlayerController | 10 | private playerController?: WDAliPlayerController |
| 11 | @Consume @Watch('updateData') contentDetailData: ContentDetailDTO | 11 | @Consume @Watch('updateData') contentDetailData: ContentDetailDTO |
| 12 | @Consume @Watch('pageShowChange') pageShow: number | 12 | @Consume @Watch('pageShowChange') pageShow: number |
| @@ -21,6 +21,7 @@ export struct PlayerComponent { | @@ -21,6 +21,7 @@ export struct PlayerComponent { | ||
| 21 | @State liveStreamType: number | null = -1 | 21 | @State liveStreamType: number | null = -1 |
| 22 | @State playUrl: string = '' | 22 | @State playUrl: string = '' |
| 23 | @State isCanplay: boolean = false | 23 | @State isCanplay: boolean = false |
| 24 | + pageParam: ParamType = {} | ||
| 24 | 25 | ||
| 25 | pageShowChange() { | 26 | pageShowChange() { |
| 26 | this.playerController?.play() | 27 | this.playerController?.play() |
| @@ -76,7 +77,8 @@ export struct PlayerComponent { | @@ -76,7 +77,8 @@ export struct PlayerComponent { | ||
| 76 | playerController: this.playerController, | 77 | playerController: this.playerController, |
| 77 | onLoad: () => { | 78 | onLoad: () => { |
| 78 | this.isCanplay = true | 79 | this.isCanplay = true |
| 79 | - this.playerController?.firstPlay(this.playUrl); | 80 | + this.contentTrackingDict() |
| 81 | + this.playerController?.firstPlay(this.playUrl, TrackConstants.PageName.Live_Detail, this.pageParam); | ||
| 80 | } | 82 | } |
| 81 | }) | 83 | }) |
| 82 | } else if (this.liveStreamType == 0) { | 84 | } else if (this.liveStreamType == 0) { |
| @@ -84,7 +86,8 @@ export struct PlayerComponent { | @@ -84,7 +86,8 @@ export struct PlayerComponent { | ||
| 84 | playerController: this.playerController, | 86 | playerController: this.playerController, |
| 85 | onLoad: () => { | 87 | onLoad: () => { |
| 86 | this.isCanplay = true | 88 | this.isCanplay = true |
| 87 | - this.playerController?.firstPlay(this.playUrl); | 89 | + this.contentTrackingDict() |
| 90 | + this.playerController?.firstPlay(this.playUrl, TrackConstants.PageName.Live_Detail, this.pageParam); | ||
| 88 | } | 91 | } |
| 89 | }).margin({ top: 195 }).height(211) | 92 | }).margin({ top: 195 }).height(211) |
| 90 | } | 93 | } |
| @@ -106,4 +109,12 @@ export struct PlayerComponent { | @@ -106,4 +109,12 @@ export struct PlayerComponent { | ||
| 106 | .height('100%') | 109 | .height('100%') |
| 107 | .width('100%') | 110 | .width('100%') |
| 108 | } | 111 | } |
| 112 | + | ||
| 113 | + contentTrackingDict() { | ||
| 114 | + this.pageParam = { | ||
| 115 | + 'contentType': `${this.contentDetailData.newsType}`, | ||
| 116 | + 'contentId': `${this.contentDetailData.newsId}`, | ||
| 117 | + 'contentName': `${this.contentDetailData.newsTitle || ''}`, | ||
| 118 | + } | ||
| 119 | + } | ||
| 109 | } | 120 | } |
| @@ -13,7 +13,8 @@ import { | @@ -13,7 +13,8 @@ import { | ||
| 13 | import { initGlobalPlayerSettings, setupPlayerConfig } from '../utils/GlobalSetting'; | 13 | import { initGlobalPlayerSettings, setupPlayerConfig } from '../utils/GlobalSetting'; |
| 14 | import prompt from '@ohos.promptAction'; | 14 | import prompt from '@ohos.promptAction'; |
| 15 | import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants'; | 15 | import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants'; |
| 16 | -import { Logger, StringUtils } from 'wdKit/Index'; | 16 | +import { DateTimeUtils, Logger, StringUtils } from 'wdKit/Index'; |
| 17 | +import { ParamType, TrackingPlay } from 'wdTracking/Index'; | ||
| 17 | 18 | ||
| 18 | const TAG = "WDAliPlayerController" | 19 | const TAG = "WDAliPlayerController" |
| 19 | 20 | ||
| @@ -50,6 +51,11 @@ export class WDAliPlayerController { | @@ -50,6 +51,11 @@ export class WDAliPlayerController { | ||
| 50 | public onCanplay?: () => void; | 51 | public onCanplay?: () => void; |
| 51 | public onStatusChange?: (status: number) => void; | 52 | public onStatusChange?: (status: number) => void; |
| 52 | public onFirstFrameDisplay?: () => void | 53 | public onFirstFrameDisplay?: () => void |
| 54 | + // 埋点字段 | ||
| 55 | + private creatStartTime: number = 0; //开始加载时间 | ||
| 56 | + private creatEndTime: number = 0; //加载完成时间 | ||
| 57 | + private pageParam: ParamType = {} | ||
| 58 | + private pageName: string = '' | ||
| 53 | 59 | ||
| 54 | constructor() { | 60 | constructor() { |
| 55 | Logger.info(TAG, "初始化") | 61 | Logger.info(TAG, "初始化") |
| @@ -102,11 +108,29 @@ export class WDAliPlayerController { | @@ -102,11 +108,29 @@ export class WDAliPlayerController { | ||
| 102 | if (this.onFirstFrameDisplay) { | 108 | if (this.onFirstFrameDisplay) { |
| 103 | this.onFirstFrameDisplay() | 109 | this.onFirstFrameDisplay() |
| 104 | } | 110 | } |
| 111 | + | ||
| 112 | + | ||
| 113 | + if (this.pageParam) { | ||
| 114 | + console.log('播放视频pageParam', JSON.stringify(this.pageParam)) | ||
| 115 | + // 播放埋点 | ||
| 116 | + TrackingPlay.videoPositivePlay(Math.floor((DateTimeUtils.getTimeStamp() - this.creatStartTime) / 1000), | ||
| 117 | + this.pageName, this.pageName, this.pageParam) | ||
| 118 | + } | ||
| 119 | + | ||
| 105 | } | 120 | } |
| 106 | }); | 121 | }); |
| 107 | this.avPlayer?.setOnCompletionListener({ | 122 | this.avPlayer?.setOnCompletionListener({ |
| 108 | onCompletion: () => { | 123 | onCompletion: () => { |
| 109 | Logger.debug(TAG, "播放完成") | 124 | Logger.debug(TAG, "播放完成") |
| 125 | + | ||
| 126 | + if (this.pageParam) { | ||
| 127 | + let initDuration = Math.floor(Number(this.duration) / 1000) | ||
| 128 | + let currentPlayTime: number = Math.floor((DateTimeUtils.getTimeStamp() - this.creatStartTime) / 1000) //当前播放时间 | ||
| 129 | + console.log('播放结束') | ||
| 130 | + // 播放结束埋点 | ||
| 131 | + TrackingPlay.videoPlayEnd(currentPlayTime, initDuration, currentPlayTime, this.pageName, this.pageName, | ||
| 132 | + this.pageParam) | ||
| 133 | + } | ||
| 110 | } | 134 | } |
| 111 | }); | 135 | }); |
| 112 | this.avPlayer?.setOnInfoListener({ | 136 | this.avPlayer?.setOnInfoListener({ |
| @@ -197,6 +221,9 @@ export class WDAliPlayerController { | @@ -197,6 +221,9 @@ export class WDAliPlayerController { | ||
| 197 | this.errorMesage = errorInfo.getMsg() | 221 | this.errorMesage = errorInfo.getMsg() |
| 198 | this.status = PlayerConstants.STATUS_ERROR; | 222 | this.status = PlayerConstants.STATUS_ERROR; |
| 199 | this.watchStatus(); | 223 | this.watchStatus(); |
| 224 | + | ||
| 225 | + console.log('播放错误',JSON.stringify(error)) | ||
| 226 | + TrackingPlay.videoPlayError(errorInfo.getMsg(), this.pageName, this.pageName, this.pageParam) | ||
| 200 | } | 227 | } |
| 201 | }); | 228 | }); |
| 202 | this.avPlayer?.setOnLoadingStatusListener({ | 229 | this.avPlayer?.setOnLoadingStatusListener({ |
| @@ -265,12 +292,20 @@ export class WDAliPlayerController { | @@ -265,12 +292,20 @@ export class WDAliPlayerController { | ||
| 265 | } | 292 | } |
| 266 | } | 293 | } |
| 267 | 294 | ||
| 268 | - async firstPlay(url: string) { | 295 | + async firstPlay(url: string, pageName?: string, pageParam?: ParamType) { |
| 269 | if (StringUtils.isEmpty(url)) { | 296 | if (StringUtils.isEmpty(url)) { |
| 270 | Logger.error(TAG, "播放链接为空") | 297 | Logger.error(TAG, "播放链接为空") |
| 271 | return | 298 | return |
| 272 | } | 299 | } |
| 273 | 300 | ||
| 301 | + this.creatStartTime = DateTimeUtils.getTimeStamp() | ||
| 302 | + if (pageName) { | ||
| 303 | + this.pageName = pageName | ||
| 304 | + } | ||
| 305 | + if (pageParam) { | ||
| 306 | + this.pageParam = pageParam | ||
| 307 | + } | ||
| 308 | + | ||
| 274 | this.url = url; | 309 | this.url = url; |
| 275 | if (this.avPlayer == null) { | 310 | if (this.avPlayer == null) { |
| 276 | Logger.info(TAG, "等待播放器初始化") | 311 | Logger.info(TAG, "等待播放器初始化") |
| @@ -457,11 +492,7 @@ export class WDAliPlayerController { | @@ -457,11 +492,7 @@ export class WDAliPlayerController { | ||
| 457 | if (this.onStatusChange) { | 492 | if (this.onStatusChange) { |
| 458 | this.onStatusChange(this.status) | 493 | this.onStatusChange(this.status) |
| 459 | } | 494 | } |
| 460 | - // if (this.status === PlayConstants.STATUS_START) { | ||
| 461 | - // globalThis.windowClass.setWindowKeepScreenOn(true); | ||
| 462 | - // } else { | ||
| 463 | - // globalThis.windowClass.setWindowKeepScreenOn(false); | ||
| 464 | - // } | 495 | + |
| 465 | } | 496 | } |
| 466 | 497 | ||
| 467 | playError(msg?: string) { | 498 | playError(msg?: string) { |
-
Please register or login to post a comment