<?xml version="1.0" encoding="UTF-8"?>
<rmml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="L:\collaborative-nir\program\Cscl3DWS\rmml\RMML.xsd">
	<include src="chembase.xml"/>
	<!-- Можно выделть в отдельный файл -->
<!-- NN_COLLECTION = "COLLECTION";
NN_ELEMENT = "ELEMENT";
NN_TITLE = "TITLE";
NN_PICTURE = "PICTURE";
NN_SOUND = "SOUND";
NN_TEXT = "TEXT";
NN_GROUP = "GROUP";
NN_LINK = "LINK";
 -->	<scene _name="CCollectPlayerScene" _class="CChemBaseScene" _final="false">
		<image name="imBackground" />
		<text name="txTitle" width="600"/>
		<activex name="collPlayer" src="eval(COLLECTPLAYERPATH +'collectPlayer.swf')" visible="true" x="50" y="56" height="503" width="701" depth="-500">
 			<script>
				this.videoCount=-1;
				this.arrVideoFiles = new Array();
				this.timeInt = new Array();	
				function sendVideoTimes0 ()
					{
						var videoParam = "0|" +    Math.ceil(parent.video0.currentPos * 1000) + '|' +Math.floor( parent.video0.duration * 1000);
						//trace(videoParam);
 						call( "SetVariable","videoCurTimes", videoParam);	
					}
				function sendVideoTimes1 ()
					{
						var videoParam = "1|" +    Math.ceil(parent.video1.currentPos * 1000) + '|' +Math.floor( parent.video1.duration * 1000);
						call( "SetVariable","videoCurTimes", videoParam);
					}			
				this.timeIntFunct = new Array(sendVideoTimes0,sendVideoTimes1);				
			</script>
			<script>
				function FSCommand(args, cmd)
				{
					trace ("__________FSCommand("+cmd+", "+args+")");
	   				if (cmd == 'loadVideo')
   					{
   						this.loadVideo(args);
   					}						
					else if (cmd == 'loadVideoFinish')
   					{
   						this.loadVideoFinish();
   					}						
					else if (cmd == 'playVideo')
   					{
   						//trace("playVideo");
   						this.playVideo( args);
   					}						
   					else if (cmd == 'stopVideo')
   					{
   						//trace("stopVideo");
   						this.stopVideo( args);
   					}						
   					else if (cmd == 'pauseVideo')
   					{
   						//trace("pauseVideo");
   						this.pauseVideo(args);
   					}						
   					else if (cmd == 'rewindVideo')
   					{
   						//trace("rewindVideo");
   						this.	rewindVideo(args);
   					}						
				};
			</script> 		
			<script><![CDATA[
				function loadVideo( prm) 
				{
					trace( '--- loadVideo: ' + prm);
					
					var re = new RegExp( );
					re = /(\d+) *, *("|')(.*)\2 *, *(\d+) *, *(\d+)/g;
					re.global = true;
					re.lastIndex = 0;
					var params = re.exec( prm);
					this.videoCount++;
					var videoFileName = params[ 3].substring( params[ 3].lastIndexOf("c"), params[ 3].length);
					this.arrVideoFiles[ this.videoCount] = scene.resPath+"/"+ videoFileName + '.mpg';
					
					trace( '--- loadVideo: ' + this.arrVideoFiles[this.videoCount]);
					
					var video = eval( 'scene.video' + params[ 1]);					
					video.x = Number( params[ 4]);
					video.y = Number( params[ 5]);
				}
				function loadVideoFinish()
				{
					trace("LoadVideoFinish");
					var i=0;
					for (i=0; i <= this.videoCount; i++)
					{
	   					if (resourceExists(arrVideoFiles[i]))
   						{
   							var vr= eval('scene.video'+i);
   							vr.src = ':' + arrVideoFiles[i];
   							
	   						if (vr.x>1000 && vr.y>1000)
   							{
   								vr.x =this.x + (this.width - vr.width)/2;
   								vr.y =this.y +(400 - vr.height)/2;
   							}
   							else
   							{
   								vr.x  = vr.x +this.x+20;
   								vr.y  = vr.y +this.y+25;
   							}
   							videoParam =  i + "|" + vr.width + "|" +  vr.height + "|" +  vr.duration;
   							vr.visible=true;
   							//trace(videoParam);
   							this.call("SetVariable","videoExist",videoParam);																				
   						}
   						else
   						{
   							this.call( "SetVariable", "videoNotExist", '"' + i + '"');
   						}
   						
					}					
				}
				function playVideo(n)
				{
					//trace("playVideo");
					var vid = eval("scene.video"+n);
					vid.play();
					//trace(this.timeIntFunct[n]);					
					this.timeInt[n] = scene.setInterval(eval("sendVideoTimes"+n),10);
				}
				function pauseVideo(n)
				{
					//trace("pauseVideo");
					var vid = eval("scene.video"+n);
					vid.stop();
				}
			function stopVideo(n)
				{
					//trace("stopVideo");
					var vid = eval("scene.video"+n);
					vid.stop();
				}
			function rewindVideo(n)
				{
					//trace("rewindVideo");
					var vid = eval("scene.video"+n);
					vid.rewind();
				}
			]]></script>
		</activex>
		<video name="video0"   visible="false" windowed="true" depth="-1000">
			<script event="onPlayed">
				scene.clearInterval(scene.collPlayer.timeInt[0]);
				scene.collPlayer.rewindVideo(0);
			</script>
		</video>
		<video name="video1"  visible="false" windowed="true" depth="-1000">
			<script event="onPlayed">
				scene.clearInterval(scene.collPlayer.timeInt[1]);
				scene.collPlayer.rewindVideo(1);
			</script>
		</video>
		<xml name="collElem">
		</xml>
		<script>
			function parseElement(element)
				{					   
				var node = element.firstChild;
					while (node != null) 
						{
							switch (node.nodeName.toUpperCase()) 
								{
									case "PICTURE": Player.module.extract(this.resPath+"/"+node.getAttribute("file"));break;
									case "SOUND":   Player.module.extract(this.resPath+"/"+node.getAttribute("file"));break;
								}
							node = node.nextSibling;
						}
					xmlFile = Player.module.extract( collElem.src);
					xmlFile = xmlFile.replace( '\\', '/');

					pos = collElem.src.length - 5;
 					collPlayer.call("SetVariable","forLoad",xmlFile);
				}
		</script> 
		<script><![CDATA[
			var pos = collElem.src.lastIndexOf( "\\");
			if (pos == -1)
				pos = collElem.src.lastIndexOf( "/");
			this.resPath=collElem.src.substr(0,pos);
			var node = collElem.XMLDocument.firstChild;
			while (node != null && node.nodeName.toUpperCase() != "COLLECTION")
				node = node.nextSibling;
			node = node.firstChild;
			while (node != null && node.nodeName.toUpperCase() != "ELEMENT") 
				node = node.nextSibling;
			if (node != null)
				parseElement( node);
		]]>
		</script> 
	</scene>
</rmml>
 