web/static/js/LdtPlayer.js
changeset 5 d42bb045f7d1
parent 0 cc4a51750724
child 8 718bebba29d5
equal deleted inserted replaced
4:cef485504ba8 5:d42bb045f7d1
     1 /* ----------------------------------------------------------------
     1 /* ----------------------------------------------------------------
     2    ----------------------------------------------------------------
     2    ----------------------------------------------------------------
     3    ----------------------------------------------------------------
     3    ----------------------------------------------------------------
     4    
     4    
     5 	LDTPlayer is created by http://www.iri.centrepompidou.fr
     5 	LDTPlayer is created by http://www.iri.centrepompidou.fr
     6 	2010-06-10
     6 	2010-06-14 - version 0.07
     7 	
     7 	
     8 	Initiated By Samuel Huron < samuel.huron (at) cybunk (dot) com
     8 	init By Samuel Huron < samuel.huron (at) cybunk (dot) com >
     9 	this version is the 0.06
     9 	
    10 	
    10 	
    11    ----------------------------------------------------------------
    11    ----------------------------------------------------------------
    12 */
    12 */
    13 
    13 
    14 
    14 
   144 		currentVolume = obj.percentage; 
   144 		currentVolume = obj.percentage; 
   145 		var tmp = document.getElementById("vol");
   145 		var tmp = document.getElementById("vol");
   146 		if (tmp) { tmp.innerHTML = "volume: " + currentVolume; }
   146 		if (tmp) { tmp.innerHTML = "volume: " + currentVolume; }
   147 	}
   147 	}
   148 
   148 
   149 	function createPlayer(width,height,url) {
   149 	function createPlayer(width,height,url,duration,streamerPath,MySwfPath) {
   150 	
   150 	
   151 		myUrlFragment = url.split("/");
   151 		myUrlFragment = url.split(streamerPath);
   152 		//
   152 		file = myUrlFragment[1];
   153 		file = myUrlFragment[myUrlFragment.length-3]+"/"+myUrlFragment[myUrlFragment.length-2]+"/"+myUrlFragment[myUrlFragment.length-1];
   153 		alert(url+" = "+streamerPath+" + "+file);
   154 		indexofff = url.lastIndexOf(file);
   154 		streamer = streamerPath;
   155 		streamer = url.substr(0,indexofff);
   155 		//alert(" StreamerPath : "+streamer+" - "+file);
   156 		alert(url+"="+streamer+" - "+file);
   156 		//alert(" SwfPath : "+MySwfPath);
   157 		
   157 		
   158 		var flashvars = {
   158 		var flashvars = {
   159 			streamer:streamer,
   159 			streamer:streamer,
   160 			file:file, 
   160 			file:file, 
   161 			//live:"true",
   161 			//live:"true",
   172 		var attributes = {
   172 		var attributes = {
   173 			id:"Ldtplayer1",  
   173 			id:"Ldtplayer1",  
   174 			name:"Ldtplayer1"
   174 			name:"Ldtplayer1"
   175 		}
   175 		}
   176 
   176 
   177 		swfobject.embedSWF("swf/player.swf", "ldtPlaceHolder", width, height, "9.0.115", false, flashvars, params, attributes);
   177 		swfobject.embedSWF(MySwfPath, "ldtPlaceHolder", width, height, "9.0.115", false, flashvars, params, attributes);
   178 	}
   178 	}
   179 	
   179 	
   180 
   180 
   181 
   181 
   182 
   182 
   192 	var MyLdt;
   192 	var MyLdt;
   193 	var Durration;
   193 	var Durration;
   194 	var playerLdtWidth;
   194 	var playerLdtWidth;
   195 	var playerLdtHeight;
   195 	var playerLdtHeight;
   196 	
   196 	
   197 	function loadJson (width,height,urlJson){
   197 	function loadJson (width,height,urlJson,MySwfPath){
   198 		
   198 		
   199 		playerLdtWidth=width;
   199 		playerLdtWidth=width;
   200 		playerLdtHeight=height;
   200 		playerLdtHeight=height;
   201 		
   201 		
   202 		$jIRI.ajax({
   202 		$jIRI.ajax({
   203 					  dataType: 'jsonp',
   203 					  dataType: 'jsonp',
   204 					  url:urlJson,
   204 					  url:urlJson,//+"?callback=callbackLdts",
       
   205 					  //jsonpCallback:callbackLdts,
   205 					  success: function(json){
   206 					  success: function(json){
   206 						
   207 						
   207 						//alert("success !");
   208 						//eval(json);
   208 					
   209 						//alert("callback LDTS");
       
   210 						/* START PARSING ----------------------- */
       
   211 						/* metas , medias , annotation-types , annotations , lists , tags , views */
       
   212 						/* # fonction avec 1 seul  media et 1 seul annotation type  code a cleaner */
       
   213 						/* # créer le player 				   */
       
   214 						//$jIRI.each(json.medias, function(i,item) {
       
   215 						//});
       
   216 						$jIRI("<div></div>").appendTo("#output");
       
   217 						MyMedia = new  Media(json.medias[0].id,json.medias[0].href,json.medias[0]["meta"]["dc:duration"],json.medias[0]['dc:title'],json.medias[0]['dc:description']);
       
   218 						//alert(" MySwfPath : "+MySwfPath);
       
   219 						MyMedia.createPlayer(playerLdtWidth,playerLdtHeight,json.medias[0]["meta"]["item"]["value"],MySwfPath);
       
   220 						//alert("success loading ! "+json.medias[0]["meta"]["dc:duration"]+ " | " +json.medias[0]["meta"]["item"]["value"]);
   209 						
   221 						
       
   222 						/* # créer lignes 				   */
       
   223 						/*$jIRI.each(json['annotation-types'], function(i,item) {
       
   224 						});*/	
       
   225 						MyLdt = new Ligne (json['annotation-types'][0].id,json['annotation-types'][0]['dc:title'],json['annotation-types'][0]['dc:description'],json.medias[0]["meta"]["dc:duration"]);
       
   226 						//alert("duration : "+json.medias[0]["dc:duration"]);
       
   227 						
       
   228 						/* # créer les annotations 				   */
       
   229 						$jIRI.each(json.annotations, function(i,item) {
       
   230 
       
   231 							MyLdt.addAnnotation(
       
   232 										item.id,
       
   233 										item.begin,
       
   234 										item.end,
       
   235 										item.media,
       
   236 										item.content.title,
       
   237 										item.content.description,
       
   238 										item.content.color);
       
   239 						
       
   240 						});	
       
   241 						$jIRI.each(json.lists, function(i,item) {
       
   242 							trace("lists","");
       
   243 						});		
       
   244 						$jIRI.each(json.tags, function(i,item) {
       
   245 							trace("tags","");
       
   246 						});	
       
   247 						$jIRI.each(json.views, function(i,item) {
       
   248 							trace("views","");
       
   249 						});	
       
   250 						/* END PARSING ----------------------- */
       
   251 						
       
   252 										
   210 					}
   253 					}
   211 					,error: function(data){
   254 					,error: function(data){
   212 						  alert("ERROR : "+data);
   255 						  alert("ERROR : "+data);
   213 					}		
   256 					}		
   214 				  });	
   257 				  });	
   215 	}
   258 	}
   216 
   259 
   217 	function callbackLdts(json){
   260 	function callbackLdts(json){
   218 		/* START PARSING ----------------------- */
       
   219 		/* metas , medias , annotation-types , annotations , lists , tags , views */
       
   220 		/* # fonction avec 1 seul  media et 1 seul annotation type  code a cleaner */
       
   221 		/* # créer le player 				   */
       
   222 		//$jIRI.each(json.medias, function(i,item) {
       
   223 		//});
       
   224 		$jIRI("<div></div>").appendTo("#output");
       
   225 		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']);
       
   226 		MyMedia.createPlayer(playerLdtWidth,playerLdtHeight);
       
   227 
       
   228 		/* # créer lignes 				   */
       
   229 		/*$jIRI.each(json['annotation-types'], function(i,item) {
       
   230 		});*/	
       
   231 		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"]);
       
   232 		//alert("duration : "+json.medias[0]["dc:duration"]);
       
   233 		
       
   234 		/* # créer les annotations 				   */
       
   235 		$jIRI.each(json.annotations, function(i,item) {
       
   236 
       
   237 			MyLdt.addAnnotation(
       
   238 						item.id,
       
   239 						item.begin,
       
   240 						item.end,
       
   241 						item.media,
       
   242 						item.content.title,
       
   243 						item.content.description,
       
   244 						item.content.color);
       
   245 		
       
   246 		});	
       
   247 		$jIRI.each(json.lists, function(i,item) {
       
   248 			trace("lists","");
       
   249 		});		
       
   250 		$jIRI.each(json.tags, function(i,item) {
       
   251 			trace("tags","");
       
   252 		});	
       
   253 		$jIRI.each(json.views, function(i,item) {
       
   254 			trace("views","");
       
   255 		});	
       
   256 		/* END PARSING ----------------------- */
       
   257 		
   261 		
   258 	}
   262 	}
   259 	
   263 	
   260 	function trace (msg,value){
   264 	function trace (msg,value){
   261 		$jIRI("<div>"+msg+" : "+value+"</div>").appendTo("#output");
   265 		$jIRI("<div>"+msg+" : "+value+"</div>").appendTo("#output");
   267 /* ----------------------------------------------------------------
   271 /* ----------------------------------------------------------------
   268    ----------------------------------------------------------------
   272    ----------------------------------------------------------------
   269 INIT player LDT  
   273 INIT player LDT  
   270 */
   274 */
   271 
   275 
   272 	function playerLdt (width,height,file,divId){
   276 	function playerLdt (width,height,file,divId,MySwfPath){
   273 	
       
   274 		//$jIRI("#playerLdt").append("<div id=\"div1\">hello</div>");
       
   275 		
       
   276 		
   277 		
   277 			$jIRI("#"+divId).append("<div id=\"ldtShow\">\n	<div id=\"ShowAnnotation\" class=\"demo\" >\n			<div id=\"ldtSaTitle\"></div>\n			<div id=\"ldtSaDescription\"></div>\n		</div>		<div id=\"ldtPlaceHolder\">\n			<a href=\"http://www.adobe.com/go/getflashplayer\">Get flash</a> to see this player	\n		</div>\n	</div>\n	<div id=\"controlerLdt\" class=\"demo\">\n		<div class=\"ldtControl1\" >\n			<button id=\"ldtCtrlPlay\" onclick=\"player.sendEvent('PLAY')\">Play</button>\n			<button id=\"ldtCtrlNext\" onclick=\"player.sendEvent('SEEK', currentPosition+10)\">next</button>\n		</div>\n		<div id=\"Annotations\" class=\"ui-slider\">\n			<div id=\"slider-range-min\"></div>\n		</div>\n		<div class=\"ldtControl2\">\n			<button id=\"ldtCtrlScreen\" onclick=\"player.fullscreen('true')\">Enlarge</button>\n			<button id=\"ldtCtrlSound\" onclick=\"player.sendEvent('MUTE')\">Sound</button>\n		</div>\n	</div>");
   278 			$jIRI("#"+divId).append("<div id=\"ldtShow\">\n	<div id=\"ShowAnnotation\" class=\"demo\" >\n			<div id=\"ldtSaTitle\"></div>\n			<div id=\"ldtSaDescription\"></div>\n		</div>		<div id=\"ldtPlaceHolder\">\n			<a href=\"http://www.adobe.com/go/getflashplayer\">Get flash</a> to see this player	\n		</div>\n	</div>\n	<div id=\"controlerLdt\" class=\"demo\">\n		<div class=\"ldtControl1\" >\n			<button id=\"ldtCtrlPlay\" onclick=\"player.sendEvent('PLAY')\">Play</button>\n			<button id=\"ldtCtrlNext\" onclick=\"player.sendEvent('SEEK', currentPosition+10)\">next</button>\n		</div>\n		<div id=\"Annotations\" class=\"ui-slider\">\n			<div id=\"slider-range-min\"></div>\n		</div>\n		<div class=\"ldtControl2\">\n			<button id=\"ldtCtrlScreen\" onclick=\"player.fullscreen('true')\">Enlarge</button>\n			<button id=\"ldtCtrlSound\" onclick=\"player.sendEvent('MUTE')\">Sound</button>\n		</div>\n	</div>");
   278 			loadJson(width,height,file);
   279 			loadJson(width,height,file,MySwfPath);
   279 	}
   280 	}
   280 	
   281 	
   281 	
   282 	
   282 	
   283 	
   283 
   284 
   326 		trace("Media ID :",id);
   327 		trace("Media ID :",id);
   327 		trace("Media URL :",this.url);
   328 		trace("Media URL :",this.url);
   328 		trace("- content : color",url);
   329 		trace("- content : color",url);
   329 		trace("- content : audio",title);
   330 		trace("- content : audio",title);
   330 	}
   331 	}
   331 	function createPlayerMedia(width,height){
   332 	function createPlayerMedia(width,height,MyStreamer,MySwfPath){
   332 		createPlayer(width,height,this.url,this.duration);
   333 		//alert("create swfpath : "+MySwfPath+" my streame : "+MyStreamer);
       
   334 		createPlayer(width,height,this.url,this.duration,MyStreamer,MySwfPath);
   333 		createInterface(width,height,this.duration);
   335 		createInterface(width,height,this.duration);
   334 	}
   336 	}
   335 	function updatePlayerMedia(){
   337 	function updatePlayerMedia(){
   336 		
   338 		
   337 	}
   339 	}