1 /**
  2  * @fileOverview This file with Sonettic-Cinema HD Player 5 Simple JavaScript API
  3  * @alias SimpleAPI
  4  * @author Max Klymyshyn, (c)2009 Sonettic, sonettic-cinema.com, sonettic.com
  5  * @version 1.0
  6  */
  7  
  8  
  9 /**
 10  * @func
 11  * @description method to geting Flash object. Only for internal use.
 12  * @private
 13  * @param name player name
 14  * @return Flash object
 15  */
 16 function __getSCPlayer(name){
 17 	var isIE = navigator.appName.indexOf("Microsoft") != -1;
 18 	var obj = null;
 19 	try{
 20 		obj = (isIE) ? window[name] : document[name];
 21 	}catch(e){
 22 		throw new Error("Cannot find player [" + name + "]. Details: " + e.message);
 23 	}
 24 
 25 	return obj;
 26 }
 27 
 28 
 29 /**
 30  * @func
 31  * @description This is static function to set new video source to the player with name playerName. Usage example:
 32  * @example
 33 	<pre style='color:#000000;background:#ffffff;'>
 34 <span style='color:#696969; '>// http stream and path from the root of your domain</span>
 35 setContent<span style='color:#808030; '>(</span><span style='color:#0000e6; '>'sonetticFLVPlayer'</span><span style='color:#808030; '>,</span><span style='color:#0000e6; '>'[filename]?start=[seek],/video/Walle1.flv'</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
 36 
 37 <span style='color:#696969; '>// http stream with full path of the video</span>
 38 setContent<span style='color:#808030; '>(</span><span style='color:#0000e6; '>'sonetticFLVPlayer'</span><span style='color:#808030; '>,</span><span style='color:#0000e6; '>'[filename]?start=[seek],http://myhost.com/flv/Walle1.flv'</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
 39 
 40 <span style='color:#696969; '>// progressive download and path from the root of your domain</span>
 41 setContent<span style='color:#808030; '>(</span><span style='color:#0000e6; '>'sonetticFLVPlayer'</span><span style='color:#808030; '>,</span><span style='color:#0000e6; '>'/video/Walle1.flv'</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
 42 	</pre>
 43  * @param playerName name of the player
 44  * @param videoPath path to the video, RTMP or HTTP Stream
 45  * @return void
 46  */
 47 function setContent(playerName, videoPath){
 48 	try{
 49 		__getSCPlayer(playerName).setContent(videoPath);
 50 	}catch(e){
 51 		throw new Error("setContent(...):Can't change player's content to [" + videoPath + "]. Details: " + e.message);
 52 	}
 53 }
 54 
 55 /**
 56  * @func
 57  * @deprecated This function used before ver.5 of <a href="http://sonettic-cinema.com/products/players/"><strong>Sonettic-Cinema HD Player</strong></a>.
 58  * @description This is static function is an alias to setContent and using only for backward compatibility. Use {@link setContent}
 59  * @param playerName name of the player
 60  * @param videoPath path to the video, RTMP or HTTP Stream
 61  * @return void
 62  */
 63 function setMedia(playerName, videoPath){
 64 	setContent(playerName, videoPath);
 65 }
 66 
 67 /** 
 68  * @func
 69  * @description This is static function to set position within current video in player <strong>playerName</strong>. It's pretty simple to use it, for example:
 70  * @example
 71  	<pre style='color:#000000;background:#ffffff;'>
 72  	<span style='color:#696969; '>// set position to 60 seconds from start</span>
 73 	setPosition<span style='color:#808030; '>(</span><span style='color:#0000e6; '>'sonetticFLVPlayer'</span><span style='color:#808030; '>,</span><span style='color:#0000e6; '>60</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
 74 	
 75 	<span style='color:#696969; '>// set position to 100 seconds from start</span>
 76 	setPosition<span style='color:#808030; '>(</span><span style='color:#0000e6; '>'sonetticFLVPlayer'</span><span style='color:#808030; '>,</span><span style='color:#0000e6; '>100</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
 77 	</pre>
 78  * @param playerName name of the player
 79  * @param {int} positiontime New position of the current movie in seconds
 80  * @return void
 81  */
 82 function setPosition(playerName, positiontime){
 83 	try{
 84 		__getSCPlayer(playerName).setPosition(positiontime);
 85 	}catch(e){
 86 		throw new Error("setPosition(...): Can't change video position to " + positiontime + " because " + e.message);
 87 	}
 88 }
 89 
 90 
 91 /**
 92  * @func
 93  * @description This is static function to stop playing of the current video in player <strong>playerName</strong>.
 94  * @example
 95 	<pre style='color:#000000;background:#ffffff;'>
 96 	<span style='color:#696969; '>// stop playing of video in player sonetticFLVPlayer</span>
 97 	stopMedia<span style='color:#808030; '>(</span><span style='color:#0000e6; '>'sonetticFLVPlayer'</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
 98 	</pre>
 99  * @param playerName name of the player
100  * @return void
101  */ 
102 function stopMedia(playerName){
103 	try{
104 		__getSCPlayer(playerName).stopMedia();	
105 	}catch(e){
106 		throw new Error("stopMedia(...): Can't stop media because " + e.message);
107 	}
108 }
109 
110 /**
111  * @func
112  * @description This is static function to pause current video in player <strong>playerName</strong>.
113  * @example
114 	<pre style='color:#000000;background:#ffffff;'>
115 	<span style='color:#696969; '>// pause playing of video in player sonetticFLVPlayer</span>
116 	pauseMedia<span style='color:#808030; '>(</span><span style='color:#0000e6; '>'sonetticFLVPlayer'</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
117 	</pre> 
118  * @param playerName name of the player
119  * @return void
120  */
121 function pauseMedia(playerName){
122 	try{
123 		__getSCPlayer(playerName).pauseMedia();
124 	}catch(e){
125 		throw new Error("pauseMedia(...): Can't pause media because " + e.message);
126 	}
127 }
128 
129 /**
130  * @func 
131  * @description This is static function to play current video in player <strong>playerName</strong>.
132  * @example
133 	<pre style='color:#000000;background:#ffffff;'>
134 	<span style='color:#696969; '>// lets play media</span>
135 	playMedia<span style='color:#808030; '>(</span><span style='color:#0000e6; '>'sonetticFLVPlayer'</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
136 	</pre> 
137  * @param playerName name of the player
138  * @return void
139  */
140 function playMedia(playerName){
141 	try {
142 		__getSCPlayer(playerName).playMedia();	
143 	}catch(e){
144 		throw new Error("playMedia(...): Can't play media because " + e.message);
145 	}
146 }
147 
148