Voici un exemple pratique qui permet de suivre 1/4 des étapes (25,50,75,100).
1) Assurez-vous que vous disposez des éléments suivants dans votre s_code.js
fichier
s.loadModule("Media");
s.Media.autoTrack=false;
s.Media.trackWhilePlaying=true;
s.Media.trackMilestones="25,50,75,100";
Le module médias est également requis dans le s_code. Voici un extrait de ce dont vous aurez besoin
s.m_Media_c="var m=s.m_i('Media');m.cn=function(n){var m=this;return m.s.rep(m.s.rep(m.s.rep(n,\"\\n\",''),\"\\r\",''),'--**--','')};m.open=function(n,l,p,b){var m=this,i=new Object,tm=new Date,a='',"
+"x;n=m.cn(n);if(!l)l=-1;if(n&&p){if(!m.l)m.l=new Object;if(m.l[n])m.close(n);if(b&&b.id)a=b.id;if(a)for (x in m.l)if(m.l[x]&&m.l[x].a==a)m.close(m.l[x].n);i.n=n;i.l=l;i.o=0;i.x=0;i.p=m.cn(m.playerNa"
+"me?m.playerName:p);i.a=a;i.t=0;i.ts=0;i.s=Math.floor(tm.getTime()/1000);i.lx=0;i.lt=i.s;i.lo=0;i.e='';i.to=-1;i.tc=0;i.fel=new Object;i.vt=0;i.sn=0;i.sx=\"\";i.sl=0;i.sg=0;i.sc=0;i.lm=0;i.lom=0;m.l"
+"[n]=i}};m._delete=function(n){var m=this,i;n=m.cn(n);i=m.l[n];m.l[n]=0;if(i&&i.m)clearTimeout(i.m.i)};m.close=function(n){this.e(n,0,-1)};m.play=function(n,o,sn,sx,sl){var m=this,i;i=m.e(n,1,o,sn,s"
+"x,sl);if(i&&!i.m){i.m=new Object;i.m.m=new Function('var m=s_c_il['+m._in+'],i;if(m.l){i=m.l[\"'+m.s.rep(i.n,'\"','\\\\\"')+'\"];if(i){if(i.lx==1)m.e(i.n,3,-1);i.m.i=setTimeout(i.m.m,1000)}}');i.m."
+"m()}};m.stop=function(n,
2. lier le lecteur vidéo HTML5 à Omniture
var html5Player = document.getElementById('video');
html5Player.addEventListener('loadedmetadata',playerHandler,false);
html5Player.addEventListener('play',playerHandler,false);
html5Player.addEventListener('pause',playerHandler,false);
html5Player.addEventListener('ended',playerHandler,false);
var videoOpened = false;
var currentTime = 0;
function playerHandler(e){
// window.console.log(e);//video meta
//window.console.log(e.type);
if (html5Player.currentTime > 0) {
currentTime = html5Player.currentTime;
}
switch(e.type){
case 'play':
if(!videoOpened){
window.console.log('opened');
s.Media.open(videoPageName, html5Player.duration, publicationName);
s.Media.play(videoPageName, 0);
}else{
window.console.log('play');
s.Media.play(videoPageName, currentTime);
}
// alert('currentTime: ' + currentTime);
// alert('duration: ' + Math.floor(html5Player.duration));
// alert('videoPageName: ' + videoPageName);
videoOpened = true;
break;
case 'pause':
window.console.log('pause');
s.Media.stop(videoPageName,currentTime);
break;
case 'ended':
window.console.log('ended');
s.Media.stop(videoPageName,currentTime);
s.Media.close(videoPageName);
break;
default:
break;
}
}