CloudTV JavaScript Specific Functionality


Developing on the H5 platform allows several additional features in comparison to your desktop browser, due to the architecture of your session running in the cloud. There are a few nearly-transparent methods available to the developer which minimize the gap between testing in Chrome and deploying to the H5 platform. For example: how to send a message to the client device; how to launch an application that is resident on the device (VOD, RTSP stream, etc.); and how to determine the client device identifier needed for integration-specific APIs such as loading a user's favorite channels from a database.

Accessing the Client ID

The device ID of the client is sent by the CloudTV client living on the device, and persists from session to session unless the non-volatile memory on the device is flashed (such as during the return process or when refurbished). A small extension to the navigator agent is available that contains this client-specific information, as shown below.

var deviceid =;
var x = new XMLHttpRequest();
//Call a "pretend" API that given the deviceid can
//tell me the preferences for this box, like
//for example zip code. This API is fictitious,
//and used to demonstrate that it 
//can be done and how to access the device id.
   "" + deviceid,

Communicating With The Client

In CloudTV, the client is a thin software layer that runs on the user device. This may be a Blu-ray player, a Motorola set top box, or a Television — each can accept commands from your application.

Telling The Client to Tune Away

If the client device is a cable box, it contains additonal software agents. The CloudTV client can communicate with these agents in a handoff (or handover) that ends the CloudTV session and starts up another agent on the device with the parameters provided. Some examples are:

  1.  vod://pid/aid (open up the agent which registered the vod:// protocol on the device and pass in pid and aid)
  2. rtsp:// (open up the agent which registered the rtsp:// protocol and pass in the IP and port of the RTSP stream)
  3. info://pid/aid (open up the agent which registered the info:// protocol on the device and pass in pid and aid)
  4. tv://123 (tune to channel 123)
  5. tv://650 (tune to channel 650)
A call using this method will either suspend or terminate (depending on the server configuration) the CloudTV session once the handoff is complete.

 var tune = function(tuneString, callback){   
console.log("Tuning client with string: " + tuneString);       
//support for developing in the browser  and current H5 platform.
//In the future, a location.href will suffice, so this code
//is forward compatible 
   if (window.__openUrl__){   
     console.log("Using window.__openUrl__(" + tuneString +")");          
   }else if (window.openApplication){   
     console.log("Using window.openApplication(" + tuneString +")");          
   //Future gen   
     console.log("Using window.location = " + tuneString);        
     window.location = tuneString;    
 return true; 
//Call the method to launch a VOD asset
tune("vod:// ")

Playing a Video Stream

In H5, the HTML5 <video> element is used for all video behavior that is run from within the application. As such, the only requiremnt to play video from a source that is not a file is that you know how to access it and that the video is in a format which can be played back by the H5 streaming engine. This might be a single MP4 file, or a UDP stream from a scalar. The implementation in your application is exactly the same.

Example of Loading a video and a UDP stream:

document.getElementById('video1').src = '../videos/intro.mp4';
document.getElementById('video2').src = 'udp://';

  • Thursday, 23 February 2012
  • Posted in: Advanced
  • Number of Views: 4568

Your destination to find out more about just how easy it is to develop advanced applications that leverage the “write-once, deploy-everywhere” content creation environment of ActiveVideo’s CloudTV™ platform. You will be able to significantly reduce app time-to-market for connected devices of all types, as well as cable settop boxes that have no additional connectivity. Manufacturers and virtual service providers, as well as cable and IPTV operators around the world are currently benefiting from the advantages of ActiveVideo’s CloudTV platform.

© 2019 Active Video Networks. All Rights Reserved