zhaojunkai

一级视频详情页-埋点

@@ -16,7 +16,7 @@ import { CommentDialogView } from '../view/CommentDialogView'; @@ -16,7 +16,7 @@ import { CommentDialogView } from '../view/CommentDialogView';
16 import { window } from '@kit.ArkUI'; 16 import { window } from '@kit.ArkUI';
17 import { PlayerFullScreenView } from '../view/PlayerFullScreenView'; 17 import { PlayerFullScreenView } from '../view/PlayerFullScreenView';
18 import { OperRowListView, publishCommentModel } from 'wdComponent/Index'; 18 import { OperRowListView, publishCommentModel } from 'wdComponent/Index';
19 - 19 +import {ParamType,TrackConstants } from 'wdTracking/Index';
20 const TAG = 'DetailPlayShortVideoPage'; 20 const TAG = 'DetailPlayShortVideoPage';
21 21
22 /** 22 /**
@@ -49,6 +49,8 @@ export struct DetailPlayShortVideoPage { @@ -49,6 +49,8 @@ export struct DetailPlayShortVideoPage {
49 @Consume showComment: boolean // 是否显示底部评论,首页视频频道传false 49 @Consume showComment: boolean // 是否显示底部评论,首页视频频道传false
50 @State imageVisible: boolean = true 50 @State imageVisible: boolean = true
51 @State ratio: number = 16 / 9 51 @State ratio: number = 16 / 9
  52 + pageParam: ParamType = {}
  53 + PageName: string = ''
52 54
53 /** 55 /**
54 * 页面显示重查用户关注、点赞等信息 56 * 页面显示重查用户关注、点赞等信息
@@ -91,7 +93,7 @@ export struct DetailPlayShortVideoPage { @@ -91,7 +93,7 @@ export struct DetailPlayShortVideoPage {
91 } else { 93 } else {
92 this.queryNewsInfoOfUser() 94 this.queryNewsInfoOfUser()
93 if (!this.playerController.getPlayer()) { 95 if (!this.playerController.getPlayer()) {
94 - this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl || ''); 96 + this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl || '',this.PageName,this.PageName,this.pageParam);
95 } else { 97 } else {
96 await this.playerController.play() 98 await this.playerController.play()
97 this.imageVisible = false 99 this.imageVisible = false
@@ -165,9 +167,30 @@ export struct DetailPlayShortVideoPage { @@ -165,9 +167,30 @@ export struct DetailPlayShortVideoPage {
165 } 167 }
166 this.queryNewsInfoOfUser() 168 this.queryNewsInfoOfUser()
167 169
168 - 170 + this.contentTrackingDict()
  171 + }
  172 + contentTrackingDict(){
  173 + this.pageParam = {
  174 + 'contentType': `${this.contentDetailData.newsType}`,
  175 + 'contentId': `${this.contentDetailData.newsId}`,
  176 + 'contentName': `${this.contentDetailData.newsTitle || ''}`,
  177 + }
  178 + if(this.contentDetailData.newsType == 1) {
  179 + this.PageName = TrackConstants.PageName.VideoDetail // 点播
  180 + } else if(this.contentDetailData.newsType == 2) {
  181 + this.PageName = TrackConstants.PageName.Live_Detail // 直播
  182 + } else if(this.contentDetailData.newsType == 5) {
  183 + this.PageName = TrackConstants.PageName.Summary_Detail // 专题详情页
  184 + } else if(this.contentDetailData.newsType == 8) {
  185 + this.PageName = TrackConstants.PageName.Article_Detail // 图文详情页
  186 + } else if(this.contentDetailData.newsType == 9) {
  187 + this.PageName = TrackConstants.PageName.Atlas_Detail // 图集详情页
  188 + } else if(this.contentDetailData.newsType == 14 || this.contentDetailData.newsType == 15) {
  189 + this.PageName = TrackConstants.PageName.DynamicDetail // 动态图文/动态视频
  190 + }
  191 + console.log('视频详情页',JSON.stringify(this.pageParam))
  192 + console.log('视频详情页2',JSON.stringify(this.PageName))
169 } 193 }
170 -  
171 async aboutToDisappear(): Promise<void> { 194 async aboutToDisappear(): Promise<void> {
172 console.log(TAG, 'aboutToDisappear', this.index) 195 console.log(TAG, 'aboutToDisappear', this.index)
173 await this.playerController?.pause() 196 await this.playerController?.pause()
@@ -251,7 +274,7 @@ export struct DetailPlayShortVideoPage { @@ -251,7 +274,7 @@ export struct DetailPlayShortVideoPage {
251 playerController: this.playerController, 274 playerController: this.playerController,
252 onLoad: async () => { 275 onLoad: async () => {
253 if (this.contentDetailData != null && this.contentDetailData?.videoInfo[0] != null) { 276 if (this.contentDetailData != null && this.contentDetailData?.videoInfo[0] != null) {
254 - this.playerController.firstPlay(this.contentDetailData.videoInfo[0].videoUrl); 277 + this.playerController.firstPlay(this.contentDetailData.videoInfo[0].videoUrl,this.PageName,this.PageName,this.pageParam);
255 } 278 }
256 } 279 }
257 }) 280 })
@@ -38,9 +38,8 @@ export struct PlayerRightView { @@ -38,9 +38,8 @@ export struct PlayerRightView {
38 @Consume showCommentList: boolean 38 @Consume showCommentList: boolean
39 @Consume displayDirection: DisplayDirection 39 @Consume displayDirection: DisplayDirection
40 @Consume publishCommentModel: publishCommentModel 40 @Consume publishCommentModel: publishCommentModel
41 - // @State likesStyle: number | string = 1 // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空 41 + @State likesStyle: number | string = 1 // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空
42 @State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以 42 @State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以
43 - @State likesStyle: number | string = this.contentDetailData.likesStyle // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空  
44 pageParam: ParamType = {} 43 pageParam: ParamType = {}
45 PageName: string = '' 44 PageName: string = ''
46 followUserId: string = '' 45 followUserId: string = ''
@@ -8,6 +8,8 @@ @@ -8,6 +8,8 @@
8 "version": "1.0.0", 8 "version": "1.0.0",
9 "dependencies": { 9 "dependencies": {
10 "wdKit": "file:../../commons/wdKit", 10 "wdKit": "file:../../commons/wdKit",
11 - "premierlibrary": "file:./libs/premierlibrary.har" 11 + "premierlibrary": "file:./libs/premierlibrary.har",
  12 + "wdTracking": "file:../wdTracking",
  13 + "wdBean": "file:../../features/wdBean"
12 } 14 }
13 } 15 }
@@ -3,6 +3,9 @@ import prompt from '@ohos.promptAction'; @@ -3,6 +3,9 @@ import prompt from '@ohos.promptAction';
3 import { Logger } from '../utils/Logger'; 3 import { Logger } from '../utils/Logger';
4 import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants'; 4 import { PlayerConstants, AVPlayerStatus, Events } from '../constants/PlayerConstants';
5 import { BusinessError } from '@ohos.base'; 5 import { BusinessError } from '@ohos.base';
  6 +import { TrackingPlay } from 'wdTracking/Index';
  7 +import { ParamType } from 'wdTracking/Index';
  8 +import { DateTimeUtils } from 'wdKit/Index';
6 9
7 @Observed 10 @Observed
8 export class WDPlayerController { 11 export class WDPlayerController {
@@ -17,6 +20,12 @@ export class WDPlayerController { @@ -17,6 +20,12 @@ export class WDPlayerController {
17 private seekTime: number = 0; 20 private seekTime: number = 0;
18 private positionY: number = 0; 21 private positionY: number = 0;
19 private startTime: number = 0; 22 private startTime: number = 0;
  23 + private pageParam: ParamType = {}
  24 + private pageName: string = ''
  25 + private creatStartTime:number = 0;//开始加载时间
  26 + private creatEndTime:number = 0;//加载完成时间
  27 + private prepareTime:number = 0; //加载时间
  28 + private currentPlayTime:number = 0; //当前播放时间
20 public onVideoSizeChange?: (width: number, height: number) => void; 29 public onVideoSizeChange?: (width: number, height: number) => void;
21 public onTimeUpdate?: (position: number, duration: number) => void; 30 public onTimeUpdate?: (position: number, duration: number) => void;
22 public onVolumeUpdate?: (volume: number) => void; 31 public onVolumeUpdate?: (volume: number) => void;
@@ -28,6 +37,9 @@ export class WDPlayerController { @@ -28,6 +37,9 @@ export class WDPlayerController {
28 public videoWidth: number = 0 37 public videoWidth: number = 0
29 public videoHeight: number = 0 38 public videoHeight: number = 0
30 39
  40 +
  41 +
  42 +
31 constructor() { 43 constructor() {
32 Logger.error("初始化") 44 Logger.error("初始化")
33 this.initPromise = this.createAVPlayer(); 45 this.initPromise = this.createAVPlayer();
@@ -123,6 +135,8 @@ export class WDPlayerController { @@ -123,6 +135,8 @@ export class WDPlayerController {
123 }); 135 });
124 this.avPlayer?.on(Events.ERROR, (error) => { 136 this.avPlayer?.on(Events.ERROR, (error) => {
125 this.playError(error.message); 137 this.playError(error.message);
  138 + console.log('播放错误',JSON.stringify(error))
  139 + TrackingPlay.videoPlayError(error.message, this.pageName, this.pageName, this.pageParam)
126 }) 140 })
127 this.avPlayer?.on('seekDone', (time: number) => { 141 this.avPlayer?.on('seekDone', (time: number) => {
128 this.initProgress(time); 142 this.initProgress(time);
@@ -148,8 +162,18 @@ export class WDPlayerController { @@ -148,8 +162,18 @@ export class WDPlayerController {
148 this.surfaceId = surfaceId 162 this.surfaceId = surfaceId
149 } 163 }
150 164
151 - async firstPlay(url: string) { 165 + async firstPlay(url: string,pageId?: string, pageName?: string, pageParam?: ParamType) {
152 this.url = url; 166 this.url = url;
  167 + //加载时长prepareTime
  168 + this.creatStartTime = DateTimeUtils.getTimeStamp()
  169 + console.log('开始创建',JSON.stringify(this.creatStartTime))
  170 + this.prepareTime = 0
  171 + if(pageName){
  172 + this.pageName = pageName
  173 + }
  174 + if(pageParam){
  175 + this.pageParam = pageParam
  176 + }
153 if (this.avPlayer == null) { 177 if (this.avPlayer == null) {
154 Logger.error("等待") 178 Logger.error("等待")
155 await this.initPromise; 179 await this.initPromise;
@@ -166,6 +190,11 @@ export class WDPlayerController { @@ -166,6 +190,11 @@ export class WDPlayerController {
166 } 190 }
167 Logger.error("开始播放", this.url) 191 Logger.error("开始播放", this.url)
168 this.avPlayer.url = this.url; 192 this.avPlayer.url = this.url;
  193 + //加载时长prepareTime
  194 + this.creatEndTime = DateTimeUtils.getTimeStamp()
  195 + this.prepareTime = 0
  196 + this.prepareTime = Math.floor((this.creatEndTime - this.creatStartTime)/1000)
  197 + console.log('开始播放2',JSON.stringify(this.prepareTime))
169 } 198 }
170 199
171 async release() { 200 async release() {
@@ -271,6 +300,7 @@ export class WDPlayerController { @@ -271,6 +300,7 @@ export class WDPlayerController {
271 } 300 }
272 if (mode === SliderChangeMode.End) { 301 if (mode === SliderChangeMode.End) {
273 this.seekTime = Math.floor(value * this.duration / 100); 302 this.seekTime = Math.floor(value * this.duration / 100);
  303 + this.currentPlayTime = this.seekTime
274 this.avPlayer?.seek(this.seekTime); 304 this.avPlayer?.seek(this.seekTime);
275 } 305 }
276 } 306 }
@@ -288,6 +318,7 @@ export class WDPlayerController { @@ -288,6 +318,7 @@ export class WDPlayerController {
288 } 318 }
289 319
290 initProgress(time: number) { 320 initProgress(time: number) {
  321 + this.currentPlayTime=Math.floor(time / 1000);
291 let nowSeconds = Math.floor(time / 1000); 322 let nowSeconds = Math.floor(time / 1000);
292 let totalSeconds = Math.floor(this.duration / 1000); 323 let totalSeconds = Math.floor(this.duration / 1000);
293 if (this.onTimeUpdate) { 324 if (this.onTimeUpdate) {
@@ -357,6 +388,24 @@ export class WDPlayerController { @@ -357,6 +388,24 @@ export class WDPlayerController {
357 388
358 watchStatus() { 389 watchStatus() {
359 console.log('watchStatus', this.status) 390 console.log('watchStatus', this.status)
  391 + if(this.status == 1){
  392 + console.log('播放视频')
  393 + console.log('播放视频prepareTime',JSON.stringify(this.prepareTime))
  394 + console.log('播放视频pageName',JSON.stringify(this.pageName))
  395 + console.log('播放视频pageParam',JSON.stringify(this.pageParam))
  396 + // 播放埋点
  397 + TrackingPlay.videoPositivePlay(Number(this.prepareTime),this.pageName, this.pageName, this.pageParam)
  398 + }
  399 + if(this.status == 2){
  400 + let initDuration = Math.floor(Number(this.duration)/1000)
  401 + console.log('播放结束')
  402 + console.log('播放结束currentPlayTime',JSON.stringify(this.currentPlayTime))
  403 + console.log('播放结束initDuration',JSON.stringify(initDuration))
  404 + console.log('播放结束pageName',JSON.stringify(this.pageName))
  405 + console.log('播放结束pageParam',JSON.stringify(this.pageParam))
  406 + // 播放结束埋点
  407 + TrackingPlay.videoPlayEnd(this.currentPlayTime, initDuration, this.currentPlayTime, this.pageName, this.pageName, this.pageParam)
  408 + }
360 if (this.onStatusChange) { 409 if (this.onStatusChange) {
361 this.onStatusChange(this.status) 410 this.onStatusChange(this.status)
362 } 411 }
@@ -25,7 +25,7 @@ export class TrackingPlay { @@ -25,7 +25,7 @@ export class TrackingPlay {
25 Tracking.event("video_positive_pybk", params) 25 Tracking.event("video_positive_pybk", params)
26 } 26 }
27 27
28 - // 视频 播放结束 28 + // 视频 播放结束 currentPlayTime:当前时长,totalTime:总时长 ,browseTime:浏览时长,
29 static videoPlayEnd(currentPlayTime: number, totalTime: number, browseTime: number, pageId: string, pageName: string, extParams: ParamType) { 29 static videoPlayEnd(currentPlayTime: number, totalTime: number, browseTime: number, pageId: string, pageName: string, extParams: ParamType) {
30 let params = TrackingUtils.generateParams(extParams) 30 let params = TrackingUtils.generateParams(extParams)
31 if (pageId.length) { 31 if (pageId.length) {