我有一个关于如何使用html 5跟踪brightcove播放器中的里程碑(视频)的查询。
已经预定义的事件可用于播放,暂停,停止,但是为了跟踪里程碑,我无法通过DTM跟踪它。
下面提到的代码是我为PLAY&暂停 -
代码 -
videojs('te-brightcove-trigger-video_html5_api').on('play',function(){
var myPlayer = this;
console.log('play');
s.linkTrackVars='events,eVar21,prop21';
s.linkTrackEvents='event22';
s.eVar21 = myPlayer.mediainfo.name;
s.prop21 = myPlayer.mediainfo.name;
s.events = 'event22';
s.tl(this, 'o');
});
videojs('te-brightcove-trigger-video_html5_api').on('pause',function(){
console.log('pause');
var myPlayer = this;
s.linkTrackVars='events,eVar21,prop21';
s.linkTrackEvents='event21=6,event24';
s.eVar21 = myPlayer.mediainfo.name;
s.prop21 = myPlayer.mediainfo.name;
s.events = 'event21=6';
s.events = 'event24';
s.tl(this, 'o');
});
答案 0 :(得分:1)
好的,我不确定你到底遇到了什么问题,但发出新问题同样的问题并没有对你有所帮助。你一直在发布这些问题,寻求有关里程碑的帮助,但我还没有看到你把与里程碑直接相关的任何代码都搞砸了。如果您需要实际帮助以了解出错的地方,那么将您实际尝试过的相关的相关发布到您的问题中。
一般来说,这是你应该做的working example。
// keep track of events that are triggered to only trigger them once
videojs('te-brightcove-trigger-video_html5_api')._isEventViewed = {};
videojs('te-brightcove-trigger-video_html5_api').on('play',function(){
if (!this._isEventViewed.play) {
console.log('VIDEO: tracking PLAY event');
/* tracking code here */
this._isEventViewed.play=true;
}
});
videojs('te-brightcove-trigger-video_html5_api').on('pause',function(){
if (!this._isEventViewed.pause) {
console.log('VIDEO: tracking PAUSE event');
/* tracking code here */
this._isEventViewed.pause=true;
}
});
videojs('te-brightcove-trigger-video_html5_api').on('timeupdate',function(){
var currentTime = Number(this.currentTime());
var duration = Number(this.duration());
var percentViewed = Math.floor((currentTime/duration)*100);
var ev = this._isEventViewed;
//console.log(currentTime,' / ', duration, ' - ',percentViewed);
//console.log('_isEventViewed:',ev);
switch(true) {
case (!ev['25'] && percentViewed >= 25) :
console.log('VIDEO: tracking 25% MILESTONE event');
/* tracking code here */
ev['25']=true;
break;
case (!ev['50'] && percentViewed >= 50) :
console.log('VIDEO: tracking 50% MILESTONE event');
/* tracking code here */
ev['50']=true;
break;
case (!ev['75'] && percentViewed >= 75) :
console.log('VIDEO: tracking 75% MILESTONE event');
/* tracking code here */
ev['75']=true;
break;
} // end switch percentViewed
});
videojs('te-brightcove-trigger-video_html5_api').on('ended',function(){
if (!this._isEventViewed.ended) {
console.log('VIDEO: tracking ENDED event');
/* tracking code here */
this._isEventViewed.ended=true;
}
});