1 
  2 /**
  3  * 
  4  * @description Create a new Sonettic-Cinema embed object. 
  5  * 				This object for dynamically choice between swfobject and 
  6  * 				pure html code for generation adobe flash object code
  7  * @constructor
  8  * @class
  9  * @version 0.1a
 10  */ 
 11 function SntEmbed(id, movie, flashvars, params, attributes){
 12 	// object fields
 13 	this.callback = null;
 14 	this.callbackArgs = [];
 15 	this.movie = movie;
 16 	this.haveSwfobject = swfobject != null ? true : false;
 17 
 18 	this.width = 470;
 19 	this.height = 264;
 20 
 21 	this.id = id;
 22 	this.flashvars = flashvars != null ? flashvars : {};
 23 	
 24 	// list of default object and embed attributes
 25 	this.attributes = {
 26 		'id' : id,
 27 		'name' : id
 28 	};
 29 	
 30 	
 31 	
 32 	// list of default flash object parameters
 33 	this.params = {
 34 	    'allowFullScreen' : 'true', 
 35 	    'allowScriptAccess' : 'sameDomain',  
 36 	    'bgcolor' : 'transparent',
 37 	    'wmode' : 'transparent'	
 38 	};
 39 	
 40 	// merge params and arguments if it's available in agruments
 41 	if(params != null){
 42 		for(var i in params){ this.params[i] = params[i]; }
 43 	}
 44 	
 45 	if(attributes != null){
 46 		for(var i in attributes){ this.attributes[i] = attributes[i]; }
 47 	}
 48 	return this;
 49 };
 50 
 51 
 52 SntEmbed.prototype = {
 53 	/**
 54 	 * @function
 55 	 * @description render all embed data to flash object
 56 	 * @param SntEmbedEngine object
 57 	 * @return boolean
 58 	 */
 59 	render : function(engine){
 60 		engine.setCallback(this.callback);
 61 		return engine.render(this.id, 
 62 							this.movie,
 63 							{ width : this.width, height: this.height },
 64 							this.flashvars, 
 65 							this.params, 
 66 							this.attributes
 67 							);
 68 	},
 69 	
 70 	/** 
 71 	 * @function
 72 	 * @description Merge flashvars
 73 	 * @param fv Array with new flashvars
 74 	 */
 75 	setFlashvars : function(fv){
 76 		for(var i in fv){ this.flashvars[i] = fv[i]; }
 77 	},
 78 	
 79 	/** 
 80 	 * @function
 81 	 * @description set an callback function to execute after flash object initialize
 82 	 * @param fn callback function instance
 83 	 * @return void
 84 	 */
 85 	setCallback : function(fn){
 86 		this.callback = fn;
 87 	},
 88 	/**
 89 	 * @function
 90 	 * @description Merge attributes 
 91 	 * @param attrs List of attributes
 92 	 */
 93 	setAttributes : function(attrs){
 94 		for(var a in attrs){ this.attributes[a] = attrs[a]; }
 95 	},
 96 	
 97 	/** 
 98 	 * @function
 99 	 * @description Merge parameters
100 	 * @params list of params
101 	 */
102 	setParams : function(params){
103 		for(var p in params){ this.params[p] = params[p]; }
104 	},
105 	 /** 
106 	  * @function
107 	  * @description set container size
108 	  * @param width width of the video container
109 	  * @param height of the video container
110 	  */
111 	setSize : function(width, height){
112 		this.width = width;
113 		this.height = height;
114 	}
115 };
116 
117