OnOtherVideoStateChanged Event



 
Fires when the video state of the remote video changes. The video is provided by the VoIPVideoCtrl control.


Syntax

    SiteKiosk.Plugins("SitePhone").OnOtherVideoStateChanged = handler
Remarks
    The object that caused the event can be referenced in the event function using "this".

    See also the OnOwnVideoStateChanged event.
Examples
    The following example shows the use of the OnOtherVideoStateChanged event. The example is a complete test page that demonstrates how to make video calls to other Skype accounts with SiteKiosk using a fully configured SkypeKit from the Skype/SIP settings of SiteKiosk.

    <html>
    <head>
    <script type="text/jscript">
    	window.external.InitScriptInterface();
    
    	var gk_SitePhone = null;
    	var gb_StateOnline = false;
    	var gb_LocalEnabled = true;
    	var gb_RemoteEnabled = true;
    	
    	function Log(text)
    	{
    		document.getElementById('logmessage').innerHTML = text + 
    		"<br />" + document.getElementById('logmessage').
    		innerHTML;
    	}
    	
    	function OnUnload()
    	{
    		if (gk_SitePhone == null)
    			return;
    		try
    		{
    			var Video1 = document.getElementById('Video1');
    			Video1.StopRendering();
    			Video1.ReleaseProviderPlugin();
    			var Video2 = document.getElementById('Video2');
    			Video2.StopRendering();
    			Video2.ReleaseProviderPlugin();
    		}
    		catch (e)
    		{
    			alert("OnUnload: " + e.message);
    		}
    	}
    	
    	function OnLoad()
    	{
    		
    		gk_SitePhone = SiteKiosk.Plugins("SitePhone");
    		if (gk_SitePhone == null)
    		{
    			alert("SitePhone is not defined");
    			return;
    		}
    		
    		//init video controls
    		try
    		{
    			var Video1 = document.getElementById('Video1');
    			var Video2 = document.getElementById('Video2');
    			
    			Video1.LoadParticipantAvatar(SiteKiosk.
    			SiteKioskDirectory + "\Skins\\Public\\Startpages\\
    			VoiceVideoSupport\\images\\image_men.png");
    			
    			Video1.PollFrequency = 25;
    			Video1.SetProviderPlugin(gk_SitePhone, false);
    			
    			Video2.PollFrequency = 25;
    			Video2.SetProviderPlugin(gk_SitePhone, true);
    			
    			gk_SitePhone.OnStateChanged = OnStateChanged;
    			gk_SitePhone.OnOwnVideoStateChanged = 
    			OnOwnVideoStateChanged;
    			gk_SitePhone.OnOtherVideoStateChanged = 
    			OnOtherVideoStateChanged;
    			gk_SitePhone.OnCallStateChanged = OnCallStateChanged;
    			gk_SitePhone.OnAvailabilityChanged = 
    			OnAvailabilityChanged;
    			
    			if(gk_SitePhone.State == 3) //online
    				window.setTimeout("OnStateChanged()", 100);
    				
    			var lw_State = gk_SitePhone.GetVideoState(true);
    			if(( lw_State & 0x2) == 0x2)
    				window.setTimeout
    				("OnOwnVideoStateChanged()", 100);
    			
    		}
    		catch (e)
    		{
    			alert("Exception during OnLoad: " + e.message);
    		}
    	}
    	
    	function OnAvailabilityChanged(aw_Status, as_Callee)
    	{
    		Log("OnAvailabilityChanged callee=" + as_Callee + 
    		" Status= " + aw_Status);
    	}
    	
    	function OnStateChanged()
    	{
    		if(gk_SitePhone.State == 3) //online
    		{
    			Log(">> OnStateChanged fired. State changed 
    			to 3/online. Querying Skype contacts...");
    			EnumContacts(1);
    		}
    	}
    	
    	function GetAvailability()
    	{
    		if (gk_SitePhone == null)
    			return;
    		try
    		{
    			var ls_Abonent = GetNumber();
    			var status = gk_SitePhone.GetContactAvailability
    			(ls_Abonent);
    			Log(">> Availability: " + status);
    		}
    		catch(e)
    		{
    			alert("Exception on GetAvailability: " + e.message);
    		}
    	}
    	
    	function EnumContacts(ae_Filter)
    	{
    		// enum all contacts
    		try
    		{
    			var KnownContacts = new Enumerator(gk_SitePhone.
    			GetContactNames(ae_Filter));
    			for (; !KnownContacts.atEnd(); KnownContacts.
    			moveNext())
    			{
    				Log("Contact: " + KnownContacts.item());
    			}
    		}
    		catch(e)
    		{
    			alert("Exception on EnumContacts: " + e.message);
    		}
    	}
    	
    	function OnCallStateChanged()
    	{
    		try
    		{
    			var le_Status = gk_SitePhone.CallStatus;
    			Log(">> OnCallStateChanged= " + le_Status);
    			if(le_Status ==5)
    				gb_StateOnline = true;
    			else
    				gb_StateOnline = false;
    		}
    		catch (e)
    		{
    			gb_StateOnline = false;
    		}
    	}
    
    	function OnOwnVideoStateChanged()
    	{
    		try
    		{
    			var lw_State = gk_SitePhone.GetVideoState(true);
    			if(gb_LocalEnabled && (lw_State & 0x6)==0x2)
    				ToogleRendering(true, true)
    
    			var hex = new String();
    			hex = lw_State;
    			Log(">> Local VideoStateChanged= 0x" + hex.
    			toString(16));
    		}
    		catch (e)
    		{
    		}
    	}
    
    	function OnOtherVideoStateChanged()
    	{
    		try
    		{
    			var lw_State = gk_SitePhone.GetVideoState(false);
    			if(gb_RemoteEnabled && (lw_State & 0x5)==0x1)
    				ToogleRendering(true, false)
    			
    			var hex = new String();
    			hex = lw_State;
    			Log(">> Remote VideoStateChanged= 0x" + hex.
    			toString(16));
    		}
    		catch (e)
    		{
    		}
    	}
    	
    	function ToogleRendering(ab_OnOff, ab_Local)
    	{
    		try
    		{
    			if(ab_OnOff)
    				if(ab_Local)
    				{
    					gb_LocalEnabled = true;
    					Video2.StartRendering();
    				}
    				else
    				{
    					gb_RemoteEnabled = false;
    					Video1.StartRendering();
    				}
    			else
    				if(ab_Local)
    				{
    					gb_LocalEnabled = false;
    					Video2.StopRendering();
    				}
    				else
    				{
    					gb_RemoteEnabled = false;
    					Video1.StopRendering();
    				}
    		}
    		catch(e)
    		{
    		}
    	}
    	
    	function GetNumber()
    	{
    		return document.getElementById('id_phone').value;
    	}
    	
    	function StartVideoCall()
    	{
    		if (gk_SitePhone != null && !gb_StateOnline)
    		{
    			var ls_Abonent = GetNumber();
    			try
    			{
    				gk_SitePhone.StartCall(ls_Abonent);
    			}
    			catch (e)
    			{
    				alert("CallVideo: "+ e);
    			}
    		}
    		else
    		{
    			alert("SitePhone not enabled or already online");
    		}
    	}
    	
    	function StopVideoCall()
    	{
    		if (gk_SitePhone == null || !gb_StateOnline)
    		return;
    
    		var ls_Abonent = GetNumber();
    		try
    		{
    			gk_SitePhone.FinishCall();
    			gb_StateOnline = false;
    		}
    		catch (e)
    		{
    			alert("StopVideo: "+ e);
    		}
    	}
    	
    	function RequestAuth()
    	{
    		if (gk_SitePhone == null)
    			return;
    		var ls_Abonent = GetNumber();
    		try
    		{
    			Log("Auth request to " + ls_Abonent + (gk_SitePhone.
    			SendAuthRequest(ls_Abonent, 
    			'Make me your buddy :)') ? " succeeded" : " failed"));
    		}
    		catch (e)
    		{
    			alert("RequestAuth: "+ e);
    		}
    	}
    	
    	function CheckIfLocal()
    	{
    		Log(Video2.IsLocalVideo);
    	}
    </script>
    </head>
    <body onunload='OnUnload();' bgcolor='#FFFFFF' 
    id="PageBody">
    <INPUT TYPE="button" VALUE="Click this button first to 
    initialize the page! See log messages below to monitor 
    activities." onClick='OnLoad();'>
    <br />
    <object id="Video1" width="320" height="300" 
    classid="CLSID:F3C97217-4999-4EAE-85D6-B2CDA3674870">
    <PARAM/> 
    <PARAM NAME="BackColor" VALUE="255"> 
    </object>
    <object id="Video2" width="448" height="300" 
    classid="CLSID:F3C97217-4999-4EAE-85D6-B2CDA3674870">
    <PARAM/> 
    <PARAM NAME="BackColor" VALUE="63728"> 
    </object>
    <br />
    <INPUT TYPE="button" VALUE="Start Remote" 
    onClick='ToogleRendering(true, false);'>
    <INPUT TYPE="button" VALUE="Stop Remote" 
    onClick='ToogleRendering(false, false);'>
    REMOTE<->LOCAL
    <INPUT TYPE="button" VALUE="Start Local" 
    onClick='ToogleRendering(true, true);'>
    <INPUT TYPE="button" VALUE="Stop Local" 
    onClick='ToogleRendering(false, true);'>
    <INPUT TYPE="button" VALUE="  Local Video or not? " 
    onClick='CheckIfLocal();'>
    <br />
    <br />
    Skype Name: <input type="text" id="id_phone" size="38"/>
    <INPUT TYPE="button" VALUE="Start Call" 
    onClick='StartVideoCall();'>
    <INPUT TYPE="button" VALUE="Stop Call" 
    onClick='StopVideoCall();'>
    <INPUT TYPE="button" VALUE="Request Auth" 
    onClick='RequestAuth();'>
    <INPUT TYPE="button" VALUE="Get Availability" 
    onClick='GetAvailability();'>
    <br />
    <br />
    LAST LOG MESSAGE: <span id="logmessage" 
    style="bgcolor:red">Please initialize the page with the 
    button at the top of the page!</span>
    </body>
    </html>
    

Applies to
    SiteKiosk v8.7 (and later versions).

Back to top