diff -r e6b328970ee8 -r ffb0a6d08000 web/res/metadataplayer/src/js/LdtPlayer.js --- a/web/res/metadataplayer/src/js/LdtPlayer.js Wed Jul 27 12:24:43 2011 +0200 +++ b/web/res/metadataplayer/src/js/LdtPlayer.js Wed Jul 27 12:25:45 2011 +0200 @@ -453,17 +453,17 @@ __IriSP.trace("__IriSP.Media","Media ID : "+id); __IriSP.trace("__IriSP.Media","Media URL : "+url); __IriSP.trace("__IriSP.Media","Media title : "+title); -} +}; __IriSP.Media.prototype.createPlayerMedia = function (width,height,MyStreamer,MySwfPath){ __IriSP.MyApiPlayer = new __IriSP.APIplayer(width,height,this.url,this.duration,MyStreamer,MySwfPath); //createPlayer(width,height,this.url,this.duration,MyStreamer,MySwfPath); -} +}; __IriSP.Media.prototype.getMediaDuration = function (){ return (this.duration); -} +}; __IriSP.Media.prototype.getMediaTitle = function (){ return (this.title); -} +}; @@ -527,7 +527,7 @@ __IriSP.trace("__IriSP.createInterface","END"); - } + }; /* API player - work in progress ... need refactoring of code */ @@ -558,7 +558,7 @@ - jwplayer */ -} +}; __IriSP.APIplayer.prototype.ready = function(player){ __IriSP.trace("__IriSP.APIplayer.prototype.APIpReady"," __IriSP.createInterface"); @@ -596,11 +596,11 @@ }, false); } -} +}; __IriSP.APIplayer.prototype.pause = function(){ this.hashchangeUpdate = true; __IriSP.player.sendEvent('PAUSE'); -} +}; __IriSP.APIplayer.prototype.play = function(){ this.hashchangeUpdate = true; __IriSP.trace("__IriSP.config.player.type",__IriSP.config.player.type); @@ -621,12 +621,12 @@ __IriSP.trace("vimeo",status); var status = 0; if (status!=1){__IriSP.player.api_play(); - }else{__IriSP.player.remote(moogaloop, 'api_pause') + }else{__IriSP.player.remote(moogaloop, 'api_pause'); } } -} +}; __IriSP.APIplayer.prototype.mute = function(){ __IriSP.player.sendEvent('MUTE'); @@ -636,7 +636,7 @@ } else { __IriSP.jQuery(".ui-icon-volume-on").css("background-position","-144px -160px"); } -} +}; __IriSP.APIplayer.prototype.share = function(network){ var MyMessage = encodeURIComponent("J'écoute Les Retours du Dimanche : "); @@ -659,7 +659,7 @@ window.open(shareURL+encodeURIComponent(MyURLNow)); //window.location.href = shareURL+encodeURIComponent(MyURLNow); -} +}; __IriSP.APIplayer.prototype.seek = function (time){ __IriSP.trace("__IriSP.APIplayer.prototype.seek",time); if(__IriSP.config.player.type=='jwplayer'){ @@ -669,42 +669,86 @@ __IriSP.player.seekTo(time); } this.changePageUrlOffset(time); -} +}; __IriSP.APIplayer.prototype.update = function (time){ this.hashchangeUpdate = true; __IriSP.player.sendEvent('SEEK', time); -} +}; __IriSP.APIplayer.prototype.changePageUrlOffset = function (time) { //alert(time); __IriSP.trace("__IriSP.APIplayer.prototype.changePageUrlOffset","CHANGE URL "+time); - window.location.hash = "#t=" + time; + window.location.hash = __IriSP.addTimeFragment(window.location.hash,time); window.location.href = window.location.href; -} +}; /* MEDIA FRAGMENT FUNCTION */ __IriSP.jumpToTimeoffset = function (form) { var time = form.time.value; __IriSP.MyApiPlayer.changePageUrlOffset(time); -} +}; __IriSP.retrieveTimeFragment = function (url) { - var pageoffset = 0; + var pageoffset = ""; var offsettime = 0; - if (url.split("#")[1] != null) { - pageoffset = url.split("#")[1]; - if (pageoffset.substring(2) != null) { - offsettime = pageoffset.substring(2); + url_components = url.split("#"); + + if (url_components.length > 1){ + anchors = url_components[1]; + + anchors_components = []; + if(anchors.indexOf(";")>=0) { + anchors_components = anchors.split(";"); + } + else if (anchors.indexOf("&")>=0) { + anchors_components = anchors.split("&"); + } + else { + anchors_components = [anchors]; + } + + var len = anchors_components.length; + for(var i=0;i= 0) { + res = hash_part.replace(/t=[\d.]*/, "t="+time); + } + else { + res = hash_part; + if(res.length === 0) { + res = "#"; + } + if(hash_part.length > 0 && hash_part !=="#" ) { + res = res + "&"; + } + res = res + "t="+time; + } + return res; +}; + __IriSP.ignoreTimeFragment = function(url){ if (url.split("#")[1] != null) { var pageurl= url.split("#")[0]; } return pageurl; -} +}; /* CODE SPECIAL JW PLAYER creation + listener */ @@ -765,7 +809,7 @@ // need a methode to // re execute if this swf call does'nt work -} +}; @@ -782,7 +826,7 @@ __IriSP.DailymotionAddListeners(); __IriSP.MyApiPlayer.ready(playerid); -} +}; __IriSP.DailymotionAddListeners = function () { if (__IriSP.player) { __IriSP.trace("__IriSP.addListeners","ADD Listener "); @@ -794,7 +838,7 @@ } else { __IriSP.setTimeout("__IriSP.DailymotionAddListeners()",100); } -} +}; __IriSP.DailymotionPositionListener = function() { __IriSP.currentPosition = __IriSP.player.getCurrentTime(); @@ -808,7 +852,7 @@ */ setTimeout("__IriSP.DailymotionPositionListener()",10); -} +}; /* API YOUTUBE */ onYouTubePlayerReady= function (playerid){ @@ -827,7 +871,7 @@ __IriSP.YouTubeAddListeners(); __IriSP.trace("onYouTubePlayerReady=",time); //__IriSP.MyApiPlayer.ready(playerid); -} +}; __IriSP.YouTubeAddListeners = function () { if (__IriSP.player) { __IriSP.trace("__IriSP.addListeners","ADD Listener "); @@ -838,7 +882,7 @@ } else { __IriSP.setTimeout("__IriSP.YouTubePositionListener()",100); } -} +}; __IriSP.YouTubePositionListener = function() { __IriSP.currentPosition = __IriSP.player.getCurrentTime(); @@ -853,7 +897,7 @@ setTimeout("__IriSP.YouTubePositionListener()",10); -} +}; __IriSP.YouTubeStateMonitor = function (obj) { __IriSP.player.addModelListener('__IriSP.YouTubeStateMonitor ', newstate); //alert(newstate+" "+obj.newstate); @@ -880,7 +924,7 @@ //changePageUrlOffset(currentPosition); } -} +}; /* API VIMEO */ onVimeoPlayerReady= function (playerid){ @@ -899,7 +943,7 @@ __IriSP.YouTubeAddListeners(); __IriSP.trace("onYouTubePlayerReady=",time); //__IriSP.MyApiPlayer.ready(playerid); -} +}; __IriSP.VimeoAddListeners = function () { if (__IriSP.player) { __IriSP.trace("__IriSP.addListeners","ADD Listener "); @@ -910,7 +954,7 @@ } else { __IriSP.setTimeout("__IriSP.YouTubePositionListener()",100); } -} +}; __IriSP.VimeoPositionListener = function() { __IriSP.currentPosition = __IriSP.player.getCurrentTime(); @@ -925,7 +969,7 @@ setTimeout("__IriSP.YouTubePositionListener()",10); -} +}; __IriSP.VimeoStateMonitor = function (obj) { __IriSP.player.addModelListener('__IriSP.YouTubeStateMonitor ', newstate); //alert(newstate+" "+obj.newstate); @@ -952,7 +996,7 @@ //changePageUrlOffset(currentPosition); } -} +}; /* API JW PLAYER */ __IriSP.playerReady = function (thePlayer) { @@ -975,7 +1019,7 @@ __IriSP.addListeners(); //__IriSP.trace("__IriSP.playerReady"," LISTENER END"); -} +}; __IriSP.addListeners = function () { if (__IriSP.player) { __IriSP.trace("__IriSP.addListeners","ADD Listener "); @@ -987,7 +1031,7 @@ } // et changer les boutons -} +}; __IriSP.stateMonitor = function (obj) { @@ -1010,7 +1054,7 @@ //changePageUrlOffset(currentPosition); } -} +}; __IriSP.positionListener = function(obj) { //__IriSP.trace("__IriSP.positionListener",obj.position); __IriSP.currentPosition = obj.position; @@ -1025,12 +1069,12 @@ __IriSP.MyLdt.checkTime(__IriSP.currentPosition); -} +}; __IriSP.volumeListener = function (obj) { __IriSP.currentVolume = obj.percentage; var tmp = document.getElementById("vol"); if (tmp) { tmp.innerHTML = "volume: " + __IriSP.currentVolume; } -} +}; @@ -1039,7 +1083,7 @@ // code from http://stackoverflow.com/questions/822452/strip-html-from-text-javascript __IriSP.stripHtml = function(s){ return s.replace(/\\&/g, '&').replace(/\\/g, '>').replace(/\\t/g, '   ').replace(/\\n/g, '
').replace(/'/g, ''').replace(/"/g, '"'); -} +}; // conversion de couleur Decimal vers HexaDecimal || 000 si fff __IriSP.DEC_HEXA_COLOR = function (dec){ var hexa='0123456789ABCDEF',hex=''; @@ -1052,7 +1096,7 @@ hex = hexa.charAt(dec)+hex; //if (hex == "FFCC00"){ hex="";/* by default color of Ldt annotation */ } return(hex); -} +}; /* @@ -1087,30 +1131,30 @@ this.annotationOldRead=""; __IriSP.LDTligne = this; __IriSP.trace("__IriSP.Ligne","CREATE "+__IriSP.LDTligne); -} +}; __IriSP.Ligne.prototype.addAnnotation = function (json){ var myAnnotation = new __IriSP.Annotation(json,this.duration); this.annotations.push(myAnnotation); //__IriSP.trace("__IriSP.Ligne.prototype.addAnnotation ","add annotation "+title); -} +}; __IriSP.Ligne.prototype.onClickLigneAnnotation = function(id){ //changePageUrlOffset(currentPosition); //player.sendEvent('SEEK', this.start); //__IriSP.trace("SEEK",this.start); -} +}; __IriSP.Ligne.prototype.searchLigneAnnotation = function(id){ /*for (){ }*/ -} +}; __IriSP.Ligne.prototype.listAnnotations = function(){ -} +}; __IriSP.Ligne.prototype.nextAnnotation = function (){ var annotationCibleNumber = this.numAnnotation(this.annotationOldRead)+1; var annotationCible = this.annotations[annotationCibleNumber]; if(annotationCibleNumber '+' '; @@ -1242,18 +1286,18 @@ this.htmlTags += ' '+__IriSP.MyTags.getTitle(this.tags[i]['id-ref'])+' '+" , "; } } -} +}; __IriSP.Annotation.prototype.tootTipAnnotation = function() { // 1 chercher le div correspondant // 2 y mettre les information return this.color + ' ' + this.type + ' apple'; -} +}; __IriSP.Annotation.prototype.onRollOverAnnotation = function (){ //this.tootTip(); -} +}; __IriSP.Annotation.prototype.timeToPourcent = function(time,timetotal){ return (parseInt(Math.round(time/timetotal*100))); -} +}; /* CLASS Tags */ @@ -1263,7 +1307,7 @@ this.htmlTags = null; this.weigthMax = 0; //this.mySegments = new array(); -} +}; __IriSP.Tags.prototype.addAnnotation = function (annotation){ for (var i = 0; i < this.myTags.length; ++i){ this.myTags[i].mySegments = new Array(); @@ -1271,7 +1315,7 @@ for (var j = 0; j < annotation.tags.length; ++j){ if (this.myTags[i]['id'] == annotation.tags[j]['id-ref']){ this.myTags[i].mySegments.push([annotation.begin,annotation.end,annotation.id]); - var weigthTempo = this.myTags[i].mySegments.length + var weigthTempo = this.myTags[i].mySegments.length; var tempo = this.myTags[i].mySegments[weigthTempo-1]; //__IriSP.trace ("__IriSP.Tags.prototype.addAnnotation "," "+this.myTags[i]['meta']['dc:title']+" "+this.myTags[i]['id']+" : "+tempo[0]+" - "+tempo[1]); @@ -1282,7 +1326,7 @@ } } } -} +}; __IriSP.Tags.prototype.getTitle = function (id){ for (var i = 0; i < this.myTags.length; ++i){ if(this.myTags[i]['id']==id){ @@ -1290,7 +1334,7 @@ } } -} +}; __IriSP.Tags.prototype.draw = function (){ __IriSP.trace("__IriSP.Tags.prototype.draw"," !!! WELL START " ); @@ -1307,7 +1351,7 @@ __IriSP.jQuery('#Ldt-Tags').html(this.htmlTags); __IriSP.trace("__IriSP.Tags.prototype.draw"," !!!! END WMAX= "+this.weigthMax ); -} +}; __IriSP.Tags.prototype.show = function (id){ var timeStartOffsetA = 100000000000000000000; @@ -1332,12 +1376,12 @@ if(timeStartOffset> this.myTags[i].mySegments[j][0]){ timeStartOffsetA = this.myTags[i].mySegments[j][0]; timeStartOffsetB = this.myTags[i].mySegments[j][1]; - timeStartID = this.myTags[i].mySegments[j][2] + timeStartID = this.myTags[i].mySegments[j][2]; } if(timeStartOffset> this.myTags[i].mySegments[j][0]){ timeEndOffsetA = this.myTags[i].mySegments[j][0]; timeEndOffsetB = this.myTags[i].mySegments[j][1]; - timeEndID = this.myTags[i].mySegments[j][2] + timeEndID = this.myTags[i].mySegments[j][2]; } } @@ -1357,7 +1401,7 @@ -} +}; /* CLASS TRACE */ @@ -1369,11 +1413,5 @@ __IriSP.traceNum += 1; __IriSP.jQuery("
"+__IriSP.traceNum+" - "+msg+" : "+value+"
").appendTo("#Ldt-output"); } +}; -} - - - - - - \ No newline at end of file