client/player/js/LdtPlayer.js
changeset 57 3a3c15c462f8
parent 33 6eea55d40942
parent 51 2d6866072851
child 59 b5155384c914
--- a/client/player/js/LdtPlayer.js	Tue Jun 15 01:33:03 2010 +0200
+++ b/client/player/js/LdtPlayer.js	Mon Jul 12 12:01:22 2010 +0200
@@ -3,10 +3,10 @@
    ----------------------------------------------------------------
    
 	LDTPlayer is created by http://www.iri.centrepompidou.fr
-	2010-06-10
+	2010-06-14 - version 0.07
 	
-	Initiated By Samuel Huron < samuel.huron (at) cybunk (dot) com
-	this version is the 0.06
+	init By Samuel Huron < samuel.huron (at) cybunk (dot) com >
+	
 	
    ----------------------------------------------------------------
 */
@@ -146,14 +146,14 @@
 		if (tmp) { tmp.innerHTML = "volume: " + currentVolume; }
 	}
 
-	function createPlayer(width,height,url) {
+	function createPlayer(width,height,url,duration,streamerPath,MySwfPath) {
 	
-		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);
+		myUrlFragment = url.split(streamerPath);
+		file = myUrlFragment[1];
+		//alert(url+" = "+streamerPath+" + "+file);
+		streamer = streamerPath;
+		//alert(" StreamerPath : "+streamer+" - "+file);
+		//alert(" SwfPath : "+MySwfPath);
 		
 		var flashvars = {
 			streamer:streamer,
@@ -174,7 +174,7 @@
 			name:"Ldtplayer1"
 		}
 
-		swfobject.embedSWF("swf/player.swf", "ldtPlaceHolder", width, height, "9.0.115", false, flashvars, params, attributes);
+		swfobject.embedSWF(MySwfPath, "ldtPlaceHolder", width, height, "9.0.115", false, flashvars, params, attributes);
 	}
 	
 
@@ -194,19 +194,62 @@
 	var playerLdtWidth;
 	var playerLdtHeight;
 	
-	function loadJson (width,height,urlJson){
+	function loadJson (width,height,urlJson,MySwfPath){
 		
 		playerLdtWidth=width;
 		playerLdtHeight=height;
 		
 		$jIRI.ajax({
 					  dataType: 'jsonp',
-					  url:urlJson,
+					  url:urlJson,//+"?callback=callbackLdts",
+					  //jsonpCallback:callbackLdts,
 					  success: function(json){
 						
-						//alert("success !");
-					
+						//eval(json);
+						//alert("callback LDTS");
+						/* 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("<div></div>").appendTo("#output");
+						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']);
+						//alert(" MySwfPath : "+MySwfPath);
+						MyMedia.createPlayer(playerLdtWidth,playerLdtHeight,json.medias[0]["meta"]["item"]["value"],MySwfPath);
+						//alert("success loading ! "+json.medias[0]["meta"]["dc:duration"]+ " | " +json.medias[0]["meta"]["item"]["value"]);
+						
+						/* # 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]["meta"]["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 ----------------------- */
+						
+										
 					}
 					,error: function(data){
 						  alert("ERROR : "+data);
@@ -215,45 +258,6 @@
 	}
 
 	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("<div></div>").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 ----------------------- */
 		
 	}
 	
@@ -269,13 +273,10 @@
 INIT player LDT  
 */
 
-	function playerLdt (width,height,file,divId){
-	
-		//$jIRI("#playerLdt").append("<div id=\"div1\">hello</div>");
+	function playerLdt (width,height,file,divId,MySwfPath){
 		
-		
-			$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>");
-			loadJson(width,height,file);
+			$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><div class='cleaner'>&nbsp;</div>");
+			loadJson(width,height,file,MySwfPath);
 	}
 	
 	
@@ -328,8 +329,9 @@
 		trace("- content : color",url);
 		trace("- content : audio",title);
 	}
-	function createPlayerMedia(width,height){
-		createPlayer(width,height,this.url,this.duration);
+	function createPlayerMedia(width,height,MyStreamer,MySwfPath){
+		//alert("create swfpath : "+MySwfPath+" my streame : "+MyStreamer);
+		createPlayer(width,height,this.url,this.duration,MyStreamer,MySwfPath);
 		createInterface(width,height,this.duration);
 	}
 	function updatePlayerMedia(){