diff -r 1f2c13ece5e9 -r 81d408373dde web/static/js/LdtPlayer.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/static/js/LdtPlayer.js Sat Jun 12 00:33:37 2010 +0200 @@ -0,0 +1,529 @@ +/* ---------------------------------------------------------------- + ---------------------------------------------------------------- + ---------------------------------------------------------------- + + LDTPlayer is created by http://www.iri.centrepompidou.fr + 2010-06-10 + + Initiated By Samuel Huron < samuel.huron (at) cybunk (dot) com + this version is the 0.06 + + ---------------------------------------------------------------- +*/ + + + + +/* ---------------------------------------------------------------- + ---------------------------------------------------------------- + INTERFACE : SLIDER ( CONTROL BAR ) | BUTTON () */ + + + function createInterface (width,height,duration){ + $jIRI(function() { + + $jIRI("#Annotations").width(width-(78*2)); + $jIRI("#ShowAnnotation").width(width-10); + $jIRI("#controlerLdt").width(width); + $jIRI("#Ldtplayer1").attr("z-index","100"); + + $jIRI("#ShowAnnotation").click(function () { + $jIRI(this).slideUp(); + }); + + var LdtpPlayerY = $jIRI("#ldtPlaceHolder").attr("top"); + var LdtpPlayerX = $jIRI("#ldtPlaceHolder").attr("left"); + + //alert(LdtpPlayerY+" | "+LdtpPlayerX); + //$jIRI("#ShowAnnotation").attr("position","absolute"); + /*$jIRI("#ShowAnnotation").attr("top",0); + $jIRI("#ShowAnnotation").attr("left",0);*/ + + //$jIRI("#slider-range-min").roll + $jIRI("#slider-range-min").slider({ //range: "min", + value: 0, + min: 1, + max: duration/1000,//1:54:52.66 = 3600+3240+ + step: 0.1, + slide: function(event, ui) { + + //$jIRI("#amount").val(ui.value+" s"); + player.sendEvent('SEEK', ui.value) + //player.sendEvent('PAUSE') + } + }); + $jIRI("#amount").val($jIRI("#slider-range-min").slider("value")+" s"); + + $jIRI(".ldtControl1 button:first").button({ + icons: { + primary: 'ui-icon-play' + }, + text: false + }).next().button({ + icons: { + primary: 'ui-icon-seek-next' + }, + text: false + }); + + $jIRI(".ldtControl2 button:first").button({ + icons: { + primary: 'ui-icon-newwin'//, + //secondary: 'ui-icon-volume-off' + }, + text: false + }).next().button({ + icons: { + primary: 'ui-icon-volume-on' + }, + text: false + }); + + }); + } + +/* ---------------------------------------------------------------- + ---------------------------------------------------------------- + CREER JW PLAYER creation + listener */ + + + var currentPosition = 0; + var currentVolume = 50; + var player = null; + + function playerReady(thePlayer) { + //alert("ready"); + player = window.document[thePlayer.id]; + addListeners(); + } + + function addListeners() { + if (player) { + player.addModelListener("TIME", "positionListener"); + player.addControllerListener("VOLUME", "volumeListener"); + player.addPlayPauseListener("PLAY", "state"); + } else { + setTimeout("addListeners()",100); + } + + // et changer les boutons + } + + //function + + function addPlayPauseListener(obj) { + if(obj){ + $jIRI(".control1 button:first").button({ + icons: { + primary: 'ui-icon-pause' + }, + text: false + }); + }else{ + $jIRI(".control1 button:first").button({ + icons: { + primary: 'ui-icon-play' + }, + text: false + }); + } + } + + function positionListener(obj) { + currentPosition = obj.position; + var tmp = document.getElementById("posit"); + if (tmp) { tmp.innerHTML = "position: " + currentPosition; } + $jIRI("#slider-range-min").slider("value", obj.position); + $jIRI("#amount").val(obj.position+" s"); + // afficher annotation + + MyLdt.checkTime(currentPosition); + } + + function volumeListener(obj) { + currentVolume = obj.percentage; + var tmp = document.getElementById("vol"); + if (tmp) { tmp.innerHTML = "volume: " + currentVolume; } + } + + function createPlayer(width,height,url, playerUrl) { + + myUrlFragment = url.split("/"); + // + file = myUrlFragment[myUrlFragment.length-3]+"/"+myUrlFragment[myUrlFragment.length-2]+"/"+myUrlFragment[myUrlFragment.length-1]; + indexofff = url.lastIndexOf(file); + streamer = url.substr(0,indexofff); + alert(url+"="+streamer+" - "+file); + + var flashvars = { + streamer:streamer, + file:file, + //live:"true", + autostart:"true", + controlbar:"none" + } + + var params = { + allowfullscreen:"true", + allowscriptaccess:"always", + wmode:"transparent" + } + + var attributes = { + id:"Ldtplayer1", + name:"Ldtplayer1" + } + + swfobject.embedSWF(playerUrl, "ldtPlaceHolder", width, height, "9.0.115", false, flashvars, params, attributes); + } + + + + + + +/* ---------------------------------------------------------------- + ---------------------------------------------------------------- + +LOAD JSON AND PARSE IT +*/ + + + var MyLdt; + var Durration; + var playerLdtWidth; + var playerLdtHeight; + + function loadJson (width,height,urlJson){ + + playerLdtWidth=width; + playerLdtHeight=height; + + $jIRI.ajax({ + dataType: 'jsonp', + url:urlJson, + success: function(json){ + + //alert("success !"); + + + } + ,error: function(data){ + alert("ERROR : "+data); + } + }); + } + + function callbackLdts(json){ + /* START PARSING ----------------------- */ + /* metas , medias , annotation-types , annotations , lists , tags , views */ + /* # fonction avec 1 seul media et 1 seul annotation type code a cleaner */ + /* # cr�er le player */ + //$jIRI.each(json.medias, function(i,item) { + //}); + $jIRI("
").appendTo("#output"); + MyMedia = new Media(json.medias[0].id,json.medias[0].url,json.medias[0]["dc:duration"],json.medias[0]['dc:title'],json.medias[0]['dc:description']); + MyMedia.createPlayer(playerLdtWidth,playerLdtHeight); + + /* # cr�er lignes */ + /*$jIRI.each(json['annotation-types'], function(i,item) { + });*/ + MyLdt = new Ligne (json['annotation-types'][0].id,json['annotation-types'][0]['dc:title'],json['annotation-types'][0]['dc:description'],json.medias[0]["dc:duration"]); + //alert("duration : "+json.medias[0]["dc:duration"]); + + /* # cr�er les annotations */ + $jIRI.each(json.annotations, function(i,item) { + + MyLdt.addAnnotation( + item.id, + item.begin, + item.end, + item.media, + item.content.title, + item.content.description, + item.content.color); + + }); + $jIRI.each(json.lists, function(i,item) { + trace("lists",""); + }); + $jIRI.each(json.tags, function(i,item) { + trace("tags",""); + }); + $jIRI.each(json.views, function(i,item) { + trace("views",""); + }); + /* END PARSING ----------------------- */ + + } + + function trace (msg,value){ + $jIRI("