html5播放器中的视频里程碑

html5播放器中的视频里程碑

本文介绍了如何使用Adobe DTM跟踪Brightcove html5播放器中的视频里程碑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于如何使用html 5跟踪Brightcove播放器中的里程碑(视频)的查询。

I have a query regarding how to track milestones(Video) in brightcove player by using html 5.

已经有可用于PLAY,PAUSE,STOP的预定义事件,但对于跟踪里程碑,我无法通过DTM进行跟踪。

There is already predefined events available for PLAY, PAUSE, STOP, but for the tracking the milestones i am unable to track it via 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');
});


推荐答案

好的,我不确定您到底是什么遇到了麻烦,但是发布新问题问同样的问题不会对您有帮助。您一直在发布这些问题,以寻求有关里程碑的帮助,但是我还没有看到您将任何与里程碑直接相关的代码都付诸东流。如果您想获得真正的帮助以了解您出了问题的地方,请发布您实际尝试过的内容与问题有关的。

Okay look, I'm not sure what exactly you are having trouble with, but posting new questions asking the same thing isn't going to help you. You keep posting these questions asking for help on milestones, but I have yet to see you pony up any code directly relevant to milestones. If you want actual help with understanding where you went wrong, then post what you have actually tried that is relevant to your question.

通常,这是一个工作示例你应该做什么。

In general, here is a working example of what you should be doing.

// 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;
  }
});

这篇关于如何使用Adobe DTM跟踪Brightcove html5播放器中的视频里程碑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!