You are on page 1of 60

JavaScript Extensions

JavaScript Extensions

Version 1.2.1

Release Date 09-28-2010

Copyright VideoWeb

CONTENTS

Confidential Page 1 9/28/2010


JavaScript Extensions

1 ABOUT THIS DOCUMENT .........................................................................................................5

1.1 OVERVIEW .................................................................................................................................5

2 STB_MEDIA....................................................................................................................................5

2.1 OVERVIEW OF THIS CLASS ..........................................................................................................5


2.2 DOCUMENT.CREATESTBMEDIA() ................................................................................................6
2.3 STB_MEDIA.PLAY() ....................................................................................................................7
2.4 STB_MEDIA.STOP().....................................................................................................................8
2.5 STB_MEDIA.RESUME()................................................................................................................8
2.6 STB_MEDIA.PAUSE()...................................................................................................................9
2.7 STB_MEDIA.SETPOSITION()........................................................................................................9
2.8 STB_MEDIA.GETPOSITION() .....................................................................................................10
2.9 STB_MEDIA.SETVOLUME().......................................................................................................10
2.10 STB_MEDIA.GETVOLUME() ......................................................................................................11
2.11 STB_MEDIA.SETSPEED()...........................................................................................................11
2.12 STB_MEDIA.GETSPEED() ..........................................................................................................12
2.13 STB_MEDIA.GETAUDIOPIDS() .................................................................................................12
2.14 STB_MEDIA.SETAUDIOPID()....................................................................................................13
2.15 STB_MEDIA.GETAUDIOPID() ...................................................................................................14
2.16 STB_MEDIA.GETMUTE() ..........................................................................................................14
2.17 STB_MEDIA.SETMUTE() ...........................................................................................................15
2.18 STB_MEDIA.GETDURATION() ...................................................................................................15
2.19 STB_MEDIA.ONEVENT() ..........................................................................................................16
2.20 STB_MEDIA.ADDEVENTLISTENER() .........................................................................................17
2.21 STB_MEDIA.EVENT ...................................................................................................................18
2.22 STB_MEDIA.SETAUDIOLANGUAGE() ........................................................................................20
2.23 STB_MEDIA.PLAYDRM() .........................................................................................................20
2.24 STB_MEDIA.SETAUDIOOUTPUTMODE()...................................................................................21
2.25 STB_MEDIA.SETCHANNELBYTRIPLET()...................................................................................22
2.26 STB_MEDIA.SETCHANNELBYVIRTUALID() .............................................................................23
2.27 STB_MEDIA.GETDVBCHANNELGROUP().................................................................................23

3 STB_DISPLAY ..............................................................................................................................24

3.1 OVERVIEW OF THIS CLASS ........................................................................................................24


3.2 DOCUMENT. CREATESTBDISPLAY() ..........................................................................................24
3.3 STB_DISPLAY.SETPIG() ............................................................................................................24
3.4 STB_DISPLAY.GETPIG() ...........................................................................................................25
3.5 STB_DISPLAY.SETALPHALEVEL().............................................................................................26
3.6 STB_DISPLAY.GETALPHALEVEL() ............................................................................................26
3.7 STB_DISPLAY.SHOWVIDEO() ....................................................................................................27
3.8 STB_DISPLAY.HIDEVIDEO() ......................................................................................................27
3.9 STB_DISPLAY.SETASPECTRATIO() ............................................................................................28
3.10 STB_DISPLAY.SETMATCHMETHOD() ........................................................................................28

Confidential Page 2 9/28/2010


JavaScript Extensions

4 STB .................................................................................................................................................29

4.1 OVERVIEW OF THIS CLASS ........................................................................................................29


4.2 DOCUMENT. CREATESTB () .......................................................................................................31
4.3 STB.SETHDMODE() .................................................................................................................31
4.4 STB.REBOOT() ..........................................................................................................................32
4.5 STB.CLEANCOOKIE()................................................................................................................32
4.6 STB.SETTRACK() ......................................................................................................................33
4.7 STB.DEBUG() ............................................................................................................................33
4.8 STB.SETIMESTATE() .................................................................................................................34
4.9 STB.GETIMESTATE().................................................................................................................34
4.10 STB.NETWORKMODE................................................................................................................35
4.11 STB.LANIP ...............................................................................................................................35
4.12 STB.LANMASK .........................................................................................................................36
4.13 STB.LANGATEWAY ...................................................................................................................36
4.14 STB.DNS ...................................................................................................................................36
4.15 STB.MAC ..................................................................................................................................37
4.16 STB.GETDEFAULTERRORURL() ...............................................................................................37
4.17 STB.SETDEFAULTERRORURL() ...............................................................................................38
4.18 STB.READ() ..............................................................................................................................38
4.19 STB.WRITE().............................................................................................................................39
4.20 STB.SAVE() ...............................................................................................................................39
4.21 STB.PANELDISPLAYTEXT() ......................................................................................................40
4.22 STB.OPENFILE() .......................................................................................................................40
4.23 STB.READFILE() .......................................................................................................................41
4.24 STB.WRITEFILE()......................................................................................................................41
4.25 STB.CLOSEFILE()......................................................................................................................42
4.26 STB.GETPROPERTY() ................................................................................................................43
4.27 STB.SETPROPERTY().................................................................................................................43
4.28 STB.GETSWVERSION() ............................................................................................................44
4.29 STB.GETHWVERSION()............................................................................................................44
4.30 STB.JUMPFROMDVBOVERIP2IPTV()......................................................................................44
4.31 STB.JUMPFROMDVBOVERIP2DVB() ......................................................................................45
4.32 STB.JUMPFROMIPTV2DVBOVERIP()......................................................................................45
4.33 STB.JUMPFROMIPTV2DVB() ..................................................................................................46
4.34 STB.NETWORKRESET().............................................................................................................46
4.35 STB.GETNETWORKSTATE .........................................................................................................47
4.36 STB.GETTUNERSTATE ..............................................................................................................47
4.37 STB.JUMPCHANNELBYIDS() ....................................................................................................48
4.38 STB.GETDVBCHANNELIDS .....................................................................................................48
4.39 STB.SMARTCARDNUMBER .......................................................................................................49
4.40 STB.IMPORTCHANNELINFO()....................................................................................................49
4.41 STB.GETCHANNELLISTVIEWMODE .........................................................................................50
4.42 STB.SETCHANNELLISTVIEWMODE() .......................................................................................50
4.43 STB.CALLDRMCLIENT()..........................................................................................................50

Confidential Page 3 9/28/2010


JavaScript Extensions

4.44 STB.DIRECTOPENRBWITHURL() .............................................................................................51


4.45 STB.GETSERVICESDATA().........................................................................................................52
4.46 STB.GETEPGSCHEDULEDATA() ...............................................................................................52
4.47 STB.ISRECORDINGRUNNING() ..................................................................................................53
4.48 STB.SETCHANNELBYTRIPLET() ...............................................................................................53
4.49 STB.SETCHANNELBYVIRTUALID()..........................................................................................54
4.50 STB.GETDVBCHANNELGROUP() .............................................................................................54
4.51 STB. STB_CAPTURESCREEN()……………………………………………………...…………56
4.52 STB.GETREFERERVALUE……………………………………………………………………..56
4.53 STB. GETCALLEDHBBTVURL……………………………………………………………………57

5 REMOTE CONTROL KEY CODE ............................................................................................57

5.1 KEY CODE VALUE .....................................................................................................................57


5.2 SAMPLE ...................................................................................................................................58

6 GALIO KEYPRESS HANDLER ................................................................................................59

Confidential Page 4 9/28/2010


JavaScript Extensions

1 About this document


This document is about JavaScript extensions used in VideoWeb IPTV STB. It contains the
porting used in media control and set-top box management. The following classes and functions
are used in JavaScript.

1.1 Overview

Content Description
stb_media A class of media playback and media setting.

Stb_display A class of video display.

Stb A class of set-top management functions and set-top property.

Remote control key code Key code value of remote control in JavaScript.

2 stb_media

2.1 Overview of this class

This class is used for media playback. It contain following functions:


Function or Property Description
document.createstbmedia() Create a new stb_media object.

stb_media.play() Play a media content.

stb_media.playDRM() Play an encrypt content

stb_media.stop() Stop playing a media content

stb_media.resume() Resumes the video stream playback from pause or trick


mode.

stb_media.pause() Stops the playback. The last frame is displayed on the


screen.

stb_media.setPosition() Set position based on the stream start position.

stb_media.getPosition () Returns the current position based on the stream start


position.

Confidential Page 5 9/28/2010


JavaScript Extensions

Function or Property Description


stb_media.setVolume() Sets the volume

stb_media.getVolume() Return the volume

stb_media.setSpeed() Specifies the stream playback speed.

stb_media.getSpeed() Returns the correct stream playback speed

stb_media.getAudioPIDs() Get audio list, contain language and PID.

stb_media.setAudioPID() Sets the audio PID.

stb_media.getAudioPID() Returns the current audio PID.

stb_media.getMute() Get Mute State

stb_media.setMute() Set Mute State

stb_media.getDuration() Get Movie Duration

stb_media.switchSubtitle() Switch to another Subtitle, if exist

stb_media.OnEvent() Enable Media Events handler

stb_media.addEventListener() Register a media event handler.

stb_media.event The variable contain the code of the last media event
occurred.

stb_media.setAudioLanguage() Set the Audio Language

stb.media.playDRM() Play the stream within DRM

stb_media.setAudioOutputMode() Set the Audio Output Mode

stb_media.setChannelByTriplet() DVB Channel switch by onid,tsid,sid

stb_media.setChannelByVirtualID() DVB Channel switch by virtual id

stb_media.getDVBChannelGroup() Get all services information which belong to same group


with current service

2.2 document.createstbmedia()

Function:
document.createstbmedia ()
Prototype:
stb_media document.createstbmedia ();
Purpose:
Create a new stb_media object.

Confidential Page 6 9/28/2010


JavaScript Extensions

Parameters:
None.
Return:
A new stb_media object.
Example:
var stb_media = document.createstbmedia();

2.3 stb_media.play()

Function:
stb_media.play()
Prototype:
int stb_media.play(string src);
Purpose:
Play a media content. This function will return after play the media content successful or
failure.
Parameters:
src: URL of media content. This value can be an IGMP/RTSP/HTTP URL.
The “src” must be the following formats.
a. URL for VOD:
a) Format:
rtsp://[Host][:Port]/[Path][;Offset=time]
b) Parameters:
[Host]: The address or host name of media server;
[:Port]: Server port number. The default value for RTSP is 554;
[Path]: The path of the media source;
[;Offset=time]: This parameter is used for set start player position, and the unit
for time is second.
b. URL for multicast:
a) Format:
igmp://[Multicast address]:[Port]
b) Parameters:
[Multicast address]: The multicast address, e.g. 239.255.0.1;
[Port]: The port number, e.g. 5001.
c. URL for HTTP:
a) Format:
http://xxxx.xxx.xxx/stream.xxx
Return:
0: Success;
1: Failure.
Example:
var stb_media = document.createstbmedia();
function play()
{

Confidential Page 7 9/28/2010


JavaScript Extensions

var ret = stb_media.play(url);


if (ret != 0)
{
alert(“Open media failure!”);
}
else
{
alert(“Open media success!”);
}
}

2.4 stb_media.stop()

Function:
stb_media.stop()
Prototype:
void stb_media.stop();
Purpose:
Stop playback, terminate the connection with media server and clear the screen. This function
will return after stop media content successful. An event will be triggered in the case of success or
failure.
Parameters:
None.
Return:
None.
Example:
var stb_media = document.createstbmedia();
function stop()
{
stb_media.stop();
}

2.5 stb_media.resume()

Function:
stb_media.resume ()
Prototype:
void stb_media.resume();
Purpose:
Resume the video stream playback from pause or trick mode. An event will be triggered in
the case of success or failure.

Confidential Page 8 9/28/2010


JavaScript Extensions

Parameters:
None.
Return:
None.
Example:
var stb_media = document.createstbmedia();
function resume()
{
stb_media.resume();
}

2.6 stb_media.pause()

Function:
stb_media.pause ()
Prototype:
void stb_media.pause ();
Purpose:
Stop play, and the last frame is displayed on the screen. An event will be triggered in the case
of success or failure.
Parameters:
None.
Return:
None.
Example:
var stb_media = document.createstbmedia();
function pause ()
{
stb_media.pause ();
}

2.7 stb_media.setPosition()

Function:
stb_media.setPosition()
Prototype:
int stb_media.setPosition(int position);
Purpose:
Set position based on the stream start position (in seconds). Playback is resumed from the
specified position. An event will be triggered in the case of success or failure.
Parameters:
position: position start to play, in seconds.
Return:

Confidential Page 9 9/28/2010


JavaScript Extensions

0: Success;
1: Parameters are error.
Example:
var stb_media = document.createstbmedia();
function setPosition()
{
var ret = stb_media.setPosition(300);
}

2.8 stb_media.getPosition()

Function:
stb_media.getPosition()
Prototype:
int stb_media.getPosition();
Purpose:
Returns the current position based on the stream start position (in seconds).
Parameters:
None.
Return:
>= 0: Current position, in seconds. Return 0, if the content is a multicast stream.
Example:
var stb_media = document.createstbmedia();
function getPosition()
{
var ret = stb_media.getPosition();
alert(String(ret));
}

2.9 stb_media.setVolume()

Function:
stb_media.setVolume()
Prototype:
void stb_media.setVolume(int volume);
Purpose:
Set the volume.
Parameters:
volume: 0-31.
Return:
None.
Example:

Confidential Page 10 9/28/2010


JavaScript Extensions

var stb_media = document.createstbmedia();


function setVolume()
{
stb_media.setVolume(10);
}

2.10 stb_media.getVolume()

Function:
stb_media.getVolume()
Prototype:
int stb_media.getVolume();
Purpose:
Get volume value.
Parameters:
None.
Return:
0-20: volume value.
Example:
var stb_media = document.createstbmedia();
function getVolume()
{
var volume = stb_media.getVolume();
alert(volume);
}

2.11 stb_media.setSpeed()

Function:
stb_media.setSpeed()
Prototype:
int stb_media.setSpeed(float speed);
Purpose:
Specify the stream playback speed. If the stream is currently paused, this call will restart it.
The maximum speed depends on the media server. An event will be triggered in the case of
success or failure. If fast rewind to the start of stream will trigger an event (value is 0x5019.).
Parameters:
speed: playback speed .
speed < 0: rewind from current position.
Speed = 0: pause.
0 < speed < 1.0: slow motion.

Confidential Page 11 9/28/2010


JavaScript Extensions

Speed = 1.0 : normal play.


Speed > 1 : fast forward.
For Microsoft MediaServer2003 the speed is from -10 to 10.
Return:
0: Success.
1: Parameters is error.
Example:
var stb_media = document.createstbmedia();
function setSpeed()
{
var ret = stb_media.setSpeed(16.0);
}

2.12 stb_media.getSpeed()

Function:
stb_media.getSpeed()
Prototype:
float stb_media.getSpeed();
Purpose:
Return current stream playback speed.
Parameters:
None.
Return:
Return current playback speed.
0: Paused.
Example:
var stb_media = document.createstbmedia();
function getSpeed()
{
var ret = stb_media.getSpeed();

alert(ret);
}

2.13 stb_media.getAudioPIDs()

Function:
stb_media.getAudioPIDs ()
Prototype:
String stb_media.getAudioPIDs ();
Purpose:

Confidential Page 12 9/28/2010


JavaScript Extensions

Get audio information, include language and PID.


Parameters:
None.
Return:
There are two kinds return value.
“,PID,type;…;” or “Language,PID,type;…;”
For example:
“,33,129;”: there is only one AC3 audio in the stream, and no language descriptor.
“eng,33,129;fre,34,129;ger,35,129;ita,36,129;spa,37129;por,38129;rus,39129;”: there are six
audio in the stream and are AC3 format.
Audio type definition:
0x03(3) /* MPEG1/2, layer 1/2 */
0x04(4) /* MPEG1/2, layer 3. */
0x0F(15) /* Advanced audio coding. Part of MPEG-4 */
0x11(17) /* AC plus SBR. Aka MPEG-4 High Efficiency (AAC-HE)*/
0x81(129) /* Dolby Digital AC3 audio */
0x06(6) /* Dolby Digital Plus (AC3+ or DDP) audio */
0x82(130) /* Digital Digital Surround sound. */
0x83(131) /* LPCM, HD-DVD mode */
0x84(132) /* LPCM, Blu-Ray mode */
Example:
var stb_media = document.createstbmedia();
function getAudioPIDs()
{
var audios.;
audios = stb_media. getAudioPIDs ();
alert(audios);
}

2.14 stb_media.setAudioPID()

Function:
stb_media.setAudioPID()
Prototype:
int stb_media.setAudioPID(int pid);
Purpose:
Sets the audio PID (for multi-language broadcast).
Parameters:
pid: PID number..
Return:
0: Success;
1: Failure..
Example:
var stb_media = document.createstbmedia();

Confidential Page 13 9/28/2010


JavaScript Extensions

function setAudiopid()
{
var ret;
ret = stb_media.setAudioPID(100);
if (ret != 0)
{
alert(ret);
}
}

2.15 stb_media.getAudioPID()

Function:
stb_media.getAudioPID()
Prototype:
int stb_media.getAudioPID();
Purpose:
Returns the current audio PID.
Parameters:
None.
Return:
Return current audio PID value.
Example:
var stb_media = document.createstbmedia();
function getAudiopid()
{
alert(stb_media.getAudioPID());
}

2.16 stb_media.getMute()

Function:
stb_media.getMute()
Prototype:
int stb_media.getMute();
Purpose:
Get the Mute State
Parameters:
None.
Return:
1: It’s Mute
0: It’s No Mute

Confidential Page 14 9/28/2010


JavaScript Extensions

Example:
var stb_media = document.createstbmedia();
function getMute()
{
var muteflag = stb_media.getMute();
alert(muteflag);
}

2.17 stb_media.setMute()

Function:
stb_media.setMute()
Prototype:
void stb_media.setMute(int muteflag);
Purpose:
Set the Mute State
Parameters:
Muteflag:
1 – Set mute
Other unsigned number – Set No mute
Return:
None.
Example:
var stb_media = document.createstbmedia();
function setMute()
{
stb_media.setMute(1);
}

2.18 stb_media.getDuration()

Function:
stb_media.getDuration()
Prototype:
int stb_media.getDuration();
Purpose:
Get the Movie Duration
Parameters:
None.
Return:

Confidential Page 15 9/28/2010


JavaScript Extensions

Movie Duration
Example:
var stb_media = document.createstbmedia();
function getDuration()
{
var duration= stb_media.getDuration();
alert(duration);
}

2.19 stb_media.OnEvent()

Function:
stb_media.OnEvent()
Prototype:
void stb_media.OnEvent();
Purpose:
This function is used with stb_media.addEventListener(). Enable the event handler registered
by stb_media.addEventListener().
Parameters:
None.
Return:
None.
Example:
var stb_media = document.createstbmedia();
function play()
{
stb_media.addEventListener (‘event’, MediaEventHandler, false);
stb_media.OnEvent();
var ret = stb_media.play(“rtsp://10.10.10.1/TestStream.mpg”);
if (ret != 0)
{
alert(String(ret));
}
}

Confidential Page 16 9/28/2010


JavaScript Extensions

2.20 stb_media.addEventListener()

Function:
stb_media.OnEvent()
Prototype:
void stb_media.addEventListener(String type, listener, bool useCapture);
Purpose:
Register a media event listener. When a media event (“event”) is trigged, the listener will be
invoked. In the listener, get event by stb_media.event.
Parameters:
type: must be “event”;
listener: the event listener;
useCapture: should be false.
Return:
None.
Example:
var stb_media = document.createstbmedia();
function MediaEventHandler(e)
{
var EventValue = stb_media.event;
switch (EventValue)
{
case 0x5001:
{
stb.debug(“Connect server failure”);
break;
}
case 0x5002:
{
stb.debug(“Connect with server has losted”);
break;
}
case 0x5005:
{
stb.debug(“Stream start”);
break;
}
case 0x5006:
{
stb.debug(“Stream end”);
break;
}
case 0x5011:
{

Confidential Page 17 9/28/2010


JavaScript Extensions

stb.debug(“Teardown successfull”);
break;
}
case 0x5015:
{
stb.debug(“play end”);
break;
}
default :
{
stb.debug(“Unknown message”);
}
}
}
function play()
{
stb_media.addEventListener (‘event’, MediaEventHandler, false);
stb_media.OnEvent();
var ret = stb_media.play(“rtsp://10.10.10.1/TestStream.mpg”);
if (ret != 0)
{
alert(String(ret));
}
}

2.21 stb_media.event

Property:
stb_media.event;
Prototype:
int stb_media.event;
Purpose:
The variable contain the code of the last media event occurred. It’s a read-only property.
Value:

Events value Description


0 stopped; the current media pointed to by data has stopped
playback
1 playing; the current media pointed to by data is currently playing
2 paused; the current media pointed to by data has been paused

Confidential Page 18 9/28/2010


JavaScript Extensions

Events value Description


3 connecting; connecting to media server
4 buffering; the media is being buffered before playback
5 finished; the playback of the current media has finished
6 error; an error occurred during media playback

Example:
var stb_media = document.createstbmedia();
function MediaEventHandler(e)
{
var EventValue = stb_media.event;
switch (EventValue)
{
case 0:
{
stb.debug(“the current media has been stopped”);
break;
}
case 1:
{
stb.debug(“the current media is currently playing”);
break;
}
default :
{
stb.debug(“Unknown message”);
}
}
}

function play()
{
var url = document.getElementById(“url”).value;
stb_media.addEventListener (‘event’, MediaEventHandler, false);
stb_media.OnEvent();
var ret = stb_media.play(url);
if (ret != 0)
{
alert(String(ret));
}
}

Confidential Page 19 9/28/2010


JavaScript Extensions

2.22 stb_media.setAudioLanguage()

Function:
stb_media.setAudioLanguage ()
Prototype:
bool stb_media.setAudioLanguage(string language);
Purpose:
Set the Audio Language
Parameters:
language:
“eng” – set Audio language as English
“rus” – set Audio language as Russian
“ger” – set Audio language as German
“chi” – Set Audio language as Chinese

Accordint ISO 639-3 in MPEG-2 TS.
Return:
TRUE – Successful
FALSE – FAIL
NOTE:
You can use stb_media.getAudioPIDs() to get the stream audio information.
Example:
var stb_media = document.createstbmedia();
function setLanguage()
{
stb_media.setAudioLanguage(“eng”);
}

2.23 stb_media.playDRM()

Function:
stb_media.playDRM()
Prototype:
int stb_media.playDRM(string src);
Purpose:
Play an encrypt media content. This function will return after play the media content
successful or failure.
Parameters:
src: URL of media content. This value can be an IGMP or RTSP URL.
The “src” must be the following formats.

Confidential Page 20 9/28/2010


JavaScript Extensions

d. URL for VOD:


a) Format:
rtsp://[Host][:Port]/[Path][;Offset=time]
b) Parameters:
[Host]: The address or host name of media server;
[:Port]: Server port number. The default value for RTSP is 554;
[Path]: The path of the media source;
[;Offset=time]: This parameter is used for set start player position, and the unit
for time is second.
e. URL for multicast:
a) Format:
igmp://[Multicast address]:[Port]
b) Parameters:
[Multicast address]: The multicast address, e.g. 239.255.0.1;
[Port]: The port number, e.g. 5001.
Return:
0: Success;
1: Failure.
Example:
var stb_media = document.createstbmedia();
function playD()
{
var ret = stb_media.playDRM(url);
if (ret != 0)
{
alert(“Open media failure!”);
}
else
{
alert(“Open media success!”);
}
}

2.24 stb_media.setAudioOutputMode()

Function:
stb_media.setAudioOutputMode ()
Prototype:
bool stb_media.setAudioOutputMode(int devideID, int mode);
Purpose:
Set the output mode for audio device
Parameters:
deviceID:

Confidential Page 21 9/28/2010


JavaScript Extensions

0x04 – S/PDIF
0x08 – HDMI

mode: 1: PCM mode; 2: COMPRESS mode’
Return:
TRUE – Successful
FALSE – FAIL
Example:
var stb_media = document.createstbmedia();
stb_media.setAudioOutputMode(0x04, 1); //Set SPDIF to PCM
stb_media.setAudioOutputMode(0x08, 1); //Set HDMI to PCM
stb_media.setAudioOutputMode(0x04, 2); //Set SPDIF to COMPRESS
stb_media.setAudioOutputMode(0x08, 2); //Set HDMI to COMPRESS

2.25 stb_media.setChannelByTriplet()

Function:
stb_media. setChannelByTriplet ()
Prototype:
void stb_media. setChannelByTriplet (int org_network_id, int ts_id, int service_id, bool
ignoreRBApp);
Purpose:
Switch DVB Channel by ID
Parameters:
org_network_id: Channel Original network ID
ts_id: Channel TS ID
service_id: Channel Service ID
ignoreRBApp: if this parameter is true,it’s indicate that RB app is going to be ignored
Return:
0: Success;
-1: Failure.

Example:
var stb_media = document.createstbmedia();
var service_id=0x11;
var ts_id=0x22;
var org_id=0x33;
stb_media. setChannelByTriplet (org_id, ts_id, service_id,true);

Confidential Page 22 9/28/2010


JavaScript Extensions

2.26 stb_media.setChannelByVirtualID()

Function:
stb_media.setChannelByVirtualID()
Prototype:
void stb_media.setChannelByVirtualID(int virtual_id, bool ignoreRBApp);
Purpose:
Switch DVB Channel by Virtual ID
Parameters:
virtual_id: Virtual ID
ignoreRBApp: if this parameter is true,it’s indicate that RB app is going to be ignored
Return:
0: Success;
-1: Failure.
Example:
var stb_media = document.createstbmedia();
var virtual_id = 1;
stb_media. setChannelByVirtualID (virtual_id,true);

2.27 stb_media.getDVBChannelGroup()

Function:
stb_media.getDVBChannelGroup()
Prototype:
string stb_media.getDVBChannelGroup();
Purpose:
Get channels data which belong to the same group with currently channel
Parameters:

Return:
a string which can be transferred to a json object
Example:
var stb_media = document.createstbmedia();
var strgroup;
strgroup = stb_media. getDVBChannelGroup ();

Confidential Page 23 9/28/2010


JavaScript Extensions

3 stb_display

3.1 Overview of this class

This class is used for video display. It contain following functions:


Function or Property Description
document.createstbdisplay() Create a new stb_display object.

stb_display.setPIG() Displays video in window mode or full screen mode.

stb_display.getPIG() Retrieve PIG mode.

stb_display.setAlphaLevel() Sets transparency level.

stb_display.getAlphaLevel() Retrieve transparency level.

stb_display.showVideo() Show the Video Layer

stb_display.hideVideo() Hide the Video Layer

stb_display.setAspectRatio() Set Video Aspect Ratio

stb_display.setMatchMethod() Set Video Match Method

3.2 document. Createstbdisplay()

Function:
document.createstbdisplay()
Prototype:
stb_display document.createstbdisplay();
Purpose:
Create a new stb_display object.
Parameters:
None.
Return:
A new stb_ display object.
Example:
var stb_display = document.createstbdisplay();

3.3 stb_display.setPIG()

Function:
stb_display.setPIG()
Prototype:

Confidential Page 24 9/28/2010


JavaScript Extensions

void stb_display.setPIG( oolean state, int width, int height, int x, int y);
Purpose:
Displays video in window mode, or returns vide on full-screen mode.
Parameters:
state:
true, PIG mode;
false, full screen mode;
width: video width, 720 for SD maximum-width; 1280 for HD maximum-height
height: video height, 576 for SD maximum-width; 720 for HD maximum-height;
x: 0 – 720(SD) or 0 – 1280(HD);
y: 0 – 576(SD) or 0 – 720(HD);
Note: if status is true and width plus x is larger than maximum-width or height plus y is
larger than maximum-height, it will do nothing.
Return:
None.
Example:
var stb_display = document.createstbdisplay();
function setPIG()
{
stb_display.setPIG(true, 400, 300, 100, 100);
}

function setFullScreen()
{
stb_display.setPIG(false, 0, 0, 0, 0);
}

3.4 stb_display.getPIG()

Function:
stb_display.getPIG()
Prototype:
oolean stb_display.getPIG();
Purpose:
Retrieve PIG mode.
Parameters:
None.
Return:
true: PIG mode;
false: full screen mode;
Example:
var stb_display = document.createstbdisplay();
function getPIG()

Confidential Page 25 9/28/2010


JavaScript Extensions

{
var nPIG = display.getPIG();
alert(nPIG);
}

3.5 stb_display.setAlphaLevel()

Function:
stb_display.setAlphaLevel()
Prototype:
void stb_display.setAlphaLevel(int level);
Purpose:
Sets transparency level.
Parameters:
level:0-255. 0, OSD fully transparent; 255, OSD not transparent.
Return:
None.
Example:
var stb_display = document.createstbdisplay();
function setAlphaLevel()
{
stb_display.setAlphaLevel(128);
}

3.6 stb_display.getAlphaLevel()

Function:
stb_display.getAlphaLevel()
Prototype:
int stb_display.getAlphaLevel();
Purpose:
Retrieve transparency level.
Parameters:
None.
Return:
Return 0-255.
Example:
var stb_display = document.createstbdisplay();
function getAlphaLevel()
{
var retAlphaLevel = stb_display.getAlphaLevel();

Confidential Page 26 9/28/2010


JavaScript Extensions

alert(retAlphaLevel);
}

3.7 stb_display.showVideo()

Function:
stb_display.showVideor()
Prototype:
void stb_display.showVideo();
Purpose:
Show the Video Layer
Parameters:
None.
Return:
None
Example:
var stb_display = document.createstbdisplay();
function showVideo()
{
stb_display.showVideo();
}

3.8 stb_display.hideVideo()

Function:
stb_display.hideVideo()
Prototype:
void stb_display.hideVideo()
Purpose:
Hide the Video Layer
Parameters:
None.
Return:
None
Example:
var stb_display = document.createstbdisplay();
function hideVideo()
{
stb_display.hideVideo();
}

Confidential Page 27 9/28/2010


JavaScript Extensions

3.9 stb_display.setAspectRatio()

Function:
stb_display.setAspectRatio ()
Prototype:
bool stb_display.setAspectRatio (int nAspectRatio)
Purpose:
Set Video Aspect Ratio
Parameters:
nAspectRatio: 0 – Default Aspect Ratio, which in accordance with Stream Aspect Ratio
1 – 4:3
2 – 16:9
Return:
TRUE – Set successful
FALSE- Set Failure
Example:
var stb_display = document.createstbdisplay();
function setAspectRatio(aspectratio)
{
stb_display.setAspectRatio(aspectratio);
}

3.10 stb_display.setMatchMethod()

Function:
stb_display.setMatchMethod ()
Prototype:
bool stb_display.setMatchMethod (int nMatchMethod)
Purpose:
Set Video Match Method(Full Screen/Letter Box/Pan Scan)
Parameters:
nAspectRatio: 0 – Default Full Screen
1 – Pan Scan
2 – Letter Box
Return:
TRUE – Set successful
FALSE- Set Failure
Example:
var stb_display = document.createstbdisplay();
function setMatchMethod(matchmethod)
{

Confidential Page 28 9/28/2010


JavaScript Extensions

stb_display.setMatchMethod(matchmethod);
}

4 stb

4.1 Overview of this class

This class is used for Set-top management functions and set-top property. It contain following
functions and property.
Function or Property Description
document.createstb() Create a new stb object.

stb.setHDMode() Sets the TV Mode (NTSC/PAL).

stb.reboot() Reboot set-top box.

stb.cleanCookie () Clean the cookies.

stb.setTrack() Set the audio track

stb.debug() Print the string in terminator.

stb.setImeState() Set IME state.

stb.getImeState() Get IME state.

stb.networkMode Retrieve the network mode.

stb.lanIP Retrieve the Local IP Address

stb.lanMask Retrieve the Local IP Mask

stb.lanGateway Retrieve the Local Gateway Address

stb.dns Retrieve the DNS address

stb.mac Retrieve the MAC address

stb.getDefaultErrorURL() Get Default Error URL

stb.setDefaultErrorURL () Set Default Error URL

stb.read() Read setting value from Flash

stb.write() Write setting value into memory and bring it into effect

stb.save() Save all settings(You should call stb.write() first, if you want to
change some settings)

Confidential Page 29 9/28/2010


JavaScript Extensions

Function or Property Description


stb.panelDisplayText () Display Text on Front Panel

stb.openFile() Open a file

stb.readFile() Read data from file

stb.writeFile() Write data into file

stb.closeFile() Close file

stb.getProperty() There are 20 persistent strings that can be used to store things.
The values are also available after removing power of the S500.
stb.setProperty() There are 20 persistent strings that can be used to store things.
The values are also available after removing power of the S500.
stb.getSWVersion() Get Software version

stb.getHWVersion() Get Hardware version

stb.jumpFromDVBoverIP2IPTV() Jump mode from DVB over IP to IPTV

stb.jumpFromDVBoverIP2DVB() Jump mode from DVB over IP to DVB

stb.jumpFromIPTV2DVBoverIP () Jump mode from IPTV to DVB over IP

stb.jumpFromIPTV2DVB() Jump mode from IPTV to DVB

stb.networkReset() Reset network(equal to restart network)

stb.getNetworkState Get Network working state

stb.getTunerState Get Tuner working state

stb.jumpChannelByIDs() Switch DVB Channel By ID

stb.getDVBChannelIDs() Get DVB Channel ID information

stb.SmartCardNumber Get Smart Card Number

stb.importChannelInfo() Import channel info

stb.directopenRBwithURL() Directly enter into specified URL Redbutton State and play the
specified programme

stb.getServicesData() Get all services information

stb.getEPGScheduleData() Get service event information of scheduled recording

stb.isRecordingrunning() Get the status whether the recording is running or not

Stb. getDVBChannelGroup() Get all services information which belong to same group with
current service

Stb. stb_capturescreen() Capture full screen

Confidential Page 30 9/28/2010


JavaScript Extensions

Function or Property Description


stb. getreferervalue Get a application’s url. this application will launch other Hbbtv
application use “stb.directopenRBwithURL”

Stb. getcalledhbbtvurl Get a url which open by “stb.directopenRBwithURL”

4.2 document. createstb ()

Function:
document.createstb ()
Prototype:
stb document.createstb();
Purpose:
Create a new stb object.
Parameters:
None.
Return:
Return a new stb object.
Example:
var stb = document.createstb ();

4.3 stb.setHDMode()

Function:
stb.setHDMode();
Prototype:
void stb.setHDMode (HDMode);
Purpose:
Set HDTV mode(PAL/NTSC720P-50Hz/720P-60Hz/1080I-50Hz/1080I-60Hz)
Parameters:
tvmode: 0 – PAL
1 – NTSC
2 – 720P-50Hz
3 – 720P-60Hz
4 – 1080I-50Hz
5 – 1080I-60Hz
Return:
None.
Example:
var stb = document.createstb();
function setHDTVmode(hdTVmode)

Confidential Page 31 9/28/2010


JavaScript Extensions

{
stb.setHDMode(hdtvmode);
}

4.4 stb.reboot()

Function:
stb.reboot()
Prototype:
boolean stb.reboot();
Purpose:
Reboot set-top box|.
Parameters:
None.
Return:
Return true if successful, false if failure.
Example:
var stb = document.createstb();
function reboot()
{
var ret = stb.reboot();
if (ret == 0)
{
alert(ret);
}
}

4.5 stb.cleanCookie()

Function:
stb.cleanCookie ()
Prototype:
void stb.cleanCookie ();
Purpose:
Clean the cookies.
Parameters:
None.
Return:
None.
Example:

Confidential Page 32 9/28/2010


JavaScript Extensions

var stb = document.createstb();


function cleanCookie()
{
stb.cleanCookie();
}

4.6 stb.setTrack()

Function:
stb.setTrack()
Prototype:
void stb.setTrack(string track);
Purpose:
Set the audio track.
Parameters:
track: 0, stereo; 1, left mono; 2, right mono.
Return:
None.
Example:
var stb = document.createstb();
function setTrack()
{
stb.setTrack(1);
}

4.7 stb.debug()

Function:
stb.debug();
Prototype:
void stb.debug(String info);
Purpose:
Print the string in terminator if “export AS_DEBUG_LEVEL=2” is set.
Parameters:
info: the string to be printed.
Return:
None.
Example:
var stb = document.createstb();
function keyAction(e)
{

Confidential Page 33 9/28/2010


JavaScript Extensions

stb.debug(String(e.which));
}

4.8 stb.setImeState()

Function:
stb. setImeState()
Prototype:
void stb.setImeState (BOOL state);
Purpose:
Set the IME state.
Parameters:
state: false, disable IME; true, enable IME.
Return:
None.
Example:
var stb = document.createstb();
function setIME()
{
stb.setImeState(true);
}

4.9 stb.getImeState()

Function:
stb.getImeState()
Prototype:
BOOL stb.getImeState();
Purpose:
Get the IME state.
Parameters:
None.
Return:
true: IME enable;
false: IME disable;
Example:
var stb = document.createstb();
function getIME()
{
var state = stb.getImeState();
alert(state);
}

Confidential Page 34 9/28/2010


JavaScript Extensions

4.10 stb.networkMode

Property:
stb.networkMode;
Prototype:
int stb.networkMode;
Purpose:
Retrieve network mode.
Value:
0, DHCP;
1, static IP;
-1, error.
Example:
var stb = document.createstb();
function networkMode()
{
var mode = stb.networkMode;
alert(mode);
}

4.11 stb.lanIP

Property:
stb.lanIP;
Prototype:
string stb.lanIP;
Purpose:
Retrieve LAN IP address.
Value:
An IP address string or “0.0.0.0” in the case of LAN IP address in not valid.
Example:
var stb = document.createstb();
function lanIP()
{
var ip = stb.lanIP;
alert(ip);
}

Confidential Page 35 9/28/2010


JavaScript Extensions

4.12 stb.lanMask

Property:
stb.lanMask;
Prototype:
string stb.lanMask;
Purpose:
Retrieve LAN IP Mask.
Value:
An IP mask string or “0.0.0.0” in the case of LAN IP address in not valid.
Example:
var stb = document.createstb();
function lanMask()
{
var mask = stb.lanMask;
alert(mask);
}

4.13 stb.lanGateway

Property:
stb.lanGateway;
Prototype:
string stb.lanGateway;
Purpose:
Retrieve LAN gateway address.
Value:
IP gateways address string or “0.0.0.0” in the case of LAN IP address in not valid.
Example:
var stb = document.createstb();
function lanGateway()
{
var gw = stb.lanGateway;
alert(gw);
}

4.14 stb.dns

Property:
stb.dns;

Confidential Page 36 9/28/2010


JavaScript Extensions

Prototype:
string stb.dns;
Purpose:
Retrieve DNS address.
Value:
IP address string or “0.0.0.0” in the case of DNS address in not valid.
Example:
var stb = document.createstb();
function dns()
{
var dns = stb.dns;
alert(dns);
}

4.15 stb.mac

Property:
stb.mac;
Prototype:
string stb.mac;
Purpose:
Retrieve MAC address.
Value:
MAC address string.
Example:
var stb = document.createstb();
function mac()
{
var mac = stb.mac;
alert(mac);
}

4.16 stb.getDefaultErrorURL()

Function:
stb.getDefaultErrorURL ()
Prototype:
string stb.getDefaultErrorURL (errorCode);
Purpose:
Return the URL of page, when there occurs an access error, the Browser will open
Parameters:

Confidential Page 37 9/28/2010


JavaScript Extensions

None.
Return:
URL
Example:
var stb = document.createstb ();
function getDefaultErrorURL()
{
var ret = stb.getDefaultErrorURL (503);
}

4.17 stb.setDefaultErrorURL()

Function:
stb.setDefaultErrorURL ()
Prototype:
bool stb.setDefaultErrorURL (errorcode, url);
Purpose:
Set your own Error Page, when Browser occurs an error, let browser open the “ulr” as error
page
Parameters:
errorcode – HTML Error Code
Return:
1: Success;
0: Failure;
Example:
var stb = document.createstb ();
function setDefaultErrorURL()
{
var ret = stb.setDefaultErrorURL ();
}

4.18 stb.read()

Function:
stb.read();
Prototype:
string stb.read(String option);
Purpose:
Read STB setting option value
Parameters:
option: name of setting.

Confidential Page 38 9/28/2010


JavaScript Extensions

Return:
None.
Example:
var stb = document.createstb();
function read()
{
var timezone;
timezone = stb.read(“TimeZone”);
}
var stb = document.createstb();
var cn = stb.read("ChannelName");
alert(cn);

4.19 stb.write()

Function:
stb.write();
Prototype:
void stb.write(option, value);
Purpose:
Bring the option settings into effect with the specific value
Parameters:

Return:
None.
Example:
var stb = document.createstb();
function wirte()
{
var option = “VideoStandard”
stb.write(option, 1);
}

4.20 stb.save()

Function:
stb.save();
Prototype:
void stb.save();
Purpose:

Confidential Page 39 9/28/2010


JavaScript Extensions

Save all settings


Parameters:
Return:
None.
NOTE:
You should call stb.write() first, if you want to bring the setting into effect.
Example:
var stb = document.createstb();
function save(e)
{
stb.save();
}

4.21 stb.panelDisplayText()

Function:
stb.panelDisplayText ();
Prototype:
void stb.panelDisplayText (string text, int length);
Purpose:
Display text on front panel
Parameters:
text: the text you want to display
length:length of text you want to display
Return:
None.
Example:
var stb = document.createstb();
function displayText(e)
{
stb.panelDisplayText (“12345”, 4);
}

4.22 stb.openFile()

Function:
stb.openFile();
Prototype:
int stb.openFile (string filename);
Purpose:

Confidential Page 40 9/28/2010


JavaScript Extensions

open
Parameters:
filename: the name of file you want to open
Return:
-1: open error;
Other: successful and return the file description which would be used in
stb.readFile()/stb.writeFile()/stb.closeFile()
NOTE:
You should use stb.closeFile() close file

Example:
var stb = document.createstb();
function openMyfile()
{
stb.openFile (“MyFile”);
}

4.23 stb.readFile()

Function:
stb.readFile();
Prototype:
string stb.readFile(int fd, int len, int offset);
Purpose:
Read file content.
Parameters:
fd: file description
len: the length of content you want to read
offset: the offset you want to start to read
Return:
the conent of reading.
Example:
var stb = document.createstb();
function readMyFile(fd)
{
alert(stb.readFile(fd, 1024, 0);
}

4.24 stb.writeFile()

Function:

Confidential Page 41 9/28/2010


JavaScript Extensions

stb.writeFile();
Prototype:
int stb.writeFile (int fd, ,string data, int length, int offset);
Purpose:
Write something into File.
Parameters:
fd: file description
data: the data you want to write into file
length: length of data
offset: the offset you want to write
Return:
-1 : fail
Others: the length of data has been written into file
Example:
var stb = document.createstb();
function writeMyFile(fd)
{
stb.writeFile (fd, “Hello world!”, 20, 0);
}

4.25 stb.closeFile()

Function:
stb.closeFile();
Prototype:
int stb.closeFile (int fd);
Purpose:
close file
Parameters:
fd: the fd has been created by stb.openFile();
Return:
-1: close error;
Other: successful

NOTE:
Close the file has been opened by stb.openFile()

Example:
var stb = document.createstb();
function closeMyFile(fd)
{
stb.closeFile(fd);
}

Confidential Page 42 9/28/2010


JavaScript Extensions

4.26 stb.getProperty()

There are 20 persistent strings that can be used to store things.


The values are also available after removing power of the S500.

Function:
stb.getProperty();
Prototype:
string stb.getProperty (string data);
Purpose:
Read out persistent String.
Parameters:
String1…String20
Return:
String

4.27 stb.setProperty()

Function:
stb.setProperty();
Prototype:
string stb.setProperty (string name, string value);
Purpose:
Write something into persistent String.
Parameters:
string: “String1”…”String20”
string: value to be stored

Example:

stb=document.createstb();
var string1=stb.getProperty("String1");
stb.setProperty("String1", "Anixe Test String");

Confidential Page 43 9/28/2010


JavaScript Extensions

4.28 stb.getSWVersion()

Function:
stb.getSWVersion();
Prototype:
string stb.getSWVersion ();
Purpose:
Read out installed software version.
Parameters:
None
Return:
String: 001.002.003

4.29 stb.getHWVersion()

Function:
string stb.getHWVersion();
Prototype:
string stb.getHWVersion ();
Purpose:
Read out installed hardware version.
Parameters:
None
Return:
String: 001.002.003

4.30 stb.jumpFromDVBoverIP2IPTV()

Function:
stb.jumpFromDVBoverIP2IPTV()
Prototype:
int stb.jumpFromDVBoverIP2IPTV(string url);
Purpose:
Jump mode from DVB over IP to IPTV and open the specific URL
Parameters:
url
Return:
0 – successful

Confidential Page 44 9/28/2010


JavaScript Extensions

-1 - failure

Example:
stb=document.createstb();
stb.jumpFromDVBoverIP2IPTV(“http://www.google.com”)

4.31 stb.jumpFromDVBoverIP2DVB()

Function:
stb.jumpFromDVBoverIP2DVB()
Prototype:
int stb.jumpFromDVBoverIP2DVB(void);
Purpose:
Jump mode from DVB over IP to DVB
Parameters:
None
Return:
0 – successful
-1 - failure

Example:
stb=document.createstb();
stb.jumpFromDVBoverIP2DVB();

4.32 stb.jumpFromIPTV2DVBoverIP()

Function:
stb.jumpFromIPTV2DVBoverIP()
Prototype:
int stb. jumpFromIPTV2DVBoverIP (string url);
Purpose:
Jump mode from IPTV to DVB over IP and open the specific URL
Parameters:
url
Return:
0 – successful
-1 - failure

Example:
stb=document.createstb();
stb.jumpFromIPTV2DVBoverIP (“http://www.example.com”);

Confidential Page 45 9/28/2010


JavaScript Extensions

4.33 stb.jumpFromIPTV2DVB()

Function:
stb.jumpFromIPTV2DVB()
Prototype:
int stb. jumpFromIPTV2DVB();
Purpose:
Jump mode from IPTV to DVB
Parameters:
None
Return:
0 – successful
-1 - failure

Example:
stb=document.createstb();
stb.jumpFromIPTV2DVB();

4.34 stb.networkReset()

Function:
stb.networkReset()
Prototype:
int stb. networkReset (void);
Purpose:
Reset Network
Parameters:
None
Return:
0 – successful
-1 - failure

Example:
stb=document.createstb();
stb. networkReset();

Confidential Page 46 9/28/2010


JavaScript Extensions

4.35 stb.getNetworkState

Function:
stb.getNetworkState
Prototype:
int stb.getNetworkState;
Purpose:
Get Network State
Parameters:
None
Return:
0 – Successful
1 – link down
2 – IP conflict
3 – IP Error
4 – Netmask Error
5 – Gateway Error
6 – DHCP fail
7 – DHCP timeout
8 – DHCP Parameters Error
9 – NTP timeout
10 – NTP unresolved
11 – NTP fail
Example:
stb=document.createstb();
stb. getNetworkState;

4.36 stb.getTunerState

Function:
stb.getTunnerState
Prototype:
int stb. getTunnerState;
Purpose:
Get Tuner State
Parameters:
None
Return:
0 – Signal lost
1 – Connect
Example:
stb=document.createstb();

Confidential Page 47 9/28/2010


JavaScript Extensions

stb. getTunnerState;

4.37 stb.jumpChannelByIDs()

Function:
stb.jumpChannelByIDs()
Prototype:
int stb.jumpChannelByIDs (string channelIDs);
Purpose:
Switch DVB Channel by ID
Parameters:
Channel ID string the format like: “AABBCC”
AA means Service ID (4Bytes-Hexadecimal without “0x” )
BB means TS ID(4Bytes-Hexadecimal without “0x” )
CC means Original ID (4Bytes-Hexadecimal without “0x” )
Note:
NOT recommended to used, can be replaced by stb_media.setChannelByTriplet()
Return:
0 – successful
-1 - failure

Example:
stb=document.createstb();
var service_id=0x11;
var ts_id=0x12;
var org_id=0x32;
var id=”001100120032”
stb.jumpChannelByIDs (id);

4.38 stb.getDVBChannelIDs

Function:
stb.getDVBChannelIDs ()
Prototype:
string stb.getDVBChannelIDs (void);
Purpose:
Get DVB Channel ID string
Parameters:
None
Return:
Channel ID string the format like: “AA:BB:CC”

Confidential Page 48 9/28/2010


JavaScript Extensions

AA means Original ID
BB means TS ID
CC means Service ID

Example:
stb=document.createstb();
var IDs = stb.getDVBChannelIDs ();

4.39 stb.SmartCardNumber

Function:
stb.SmartCardNumber
Prototype:
string stb.SmartCardNumber
Purpose:
Get Smart Card number
Parameters:
None
Return:
Smart Card Number string
Example:
stb=document.createstb();
var ca_number = stb.SmartCardNumber;

4.40 stb.importChannelInfo()

Function:
stb.importChannelInfo()
Prototype:
int stb.importChannelInfo
Purpose:
Update DVB Channels from XML list file
Parameters:
filepath: XML list file location(HTTP or local)
Return:
0 – successful
Others - failure
Example:
stb=document.createstb();
var return = stb.importChannelInfo(“http://xxx.xxx.xxx”);

Confidential Page 49 9/28/2010


JavaScript Extensions

4.41 stb.getChannelListViewMode

Function:
stb.getChannelListViewMode ()
Prototype:
int stb.getChannelListViewMode(void)
Purpose:
Get currently used view mode (1 for Astra, 0 for VideoWeb)
Parameters:
None
Return:
1 for Astra, 0 for VideoWeb, other for failure.
Example:
stb=document.createstb();
var return = stb.getChannelListViewMode ();

4.42 stb.setChannelListViewMode()

Function:
stb.setChannelListViewMode ()
Prototype:
int stb.setChannelListViewMode(int mode)
Purpose:
Set view mode to desired one (1 for Astra, 0 for VideoWeb)
Parameters:
mode: desired view mode.
Return:
No sense.
Example:
stb=document.createstb();
/* switch to ASTRA view mode*/
stb.setChannelListViewMode (1);
/* the result can be checked by: stb.getChannelListViewMode() = = 1 */

/* switch to VideoWeb view mode*/


stb.setChannelListViewMode (0);
/* the result can be checked by: stb.getChannelListViewMode() = = 0 */

4.43 stb.callDRMClient()

Function:
stb.callDRMClient(char * url)

Confidential Page 50 9/28/2010


JavaScript Extensions

Prototype:
int stb.setChannelListViewMode(char * url)
Purpose:
For interacting with smdaemon, used for registering STB and authorizing VOD playback.
Parameters:
Path and query part of a complete URL.
Return:
0: success -1: failure.
Example:
stb=document.createstb();

/* Register STB */
ret =
stb.callDRMClient("register?sn=ct_stb&ainfo=password&rsurl=http://10.9.8.28:8082
/esam/esamservice");
if( ret = = 0)
/* success */
Else
/* failure */

/* Authorizing playback of VOD */


ret = stb.callDRMClient("request_service?service=ODSS&m=--7koukr");
if( ret = = 0)
/* success */
Else
/* failure */

4.44 stb.directopenRBwithURL()

Function:
stb.directopenRBwithURL (char * url, int onid, int tsid, int sid, bool force_flag)
Prototype:
void stb.directopenRBwithURL (char * url, int onid, int tsid, int sid, bool force_flag)
Purpose:
Enter into Redbutton state with specified URL and play specified programme.
Parameters:
url: The URL will be opened
onid: Original network ID
tsid: TS ID
sid: Service ID
force_flag: true means that url should be opened whether there is the service with 3 ids or not,
false means that if there is no service with 3 ids, then the url should be ignored, nothing will be

Confidential Page 51 9/28/2010


JavaScript Extensions

done.
Return:
0 if there is a service with 3 ids and url is not NULL;
-1 if there is no service with 3 ids or url is NULL.
Example:
stb=document.createstb();

stb.directopenRBwithURL(http://xxx.xxx.xxx, xxx, xxx, xxx, true);

4.45 stb.getServicesData()

Function:
stb.getServicesData()
Prototype:
string stb.getServicesData()
Purpose:
Get all services data.
Format:
[Name of service, virtual ID, on_id, ts_id,service_id][assigned group index,...]
If there is no virtual ID for one service ,it will be 0
Parameters:

Return:
a string which can be transferred to a json object
NULL if there is no service
Example:
var stb=document.createstb();
var strservices;
strservices = stb.getServicesData();

4.46 stb.getEPGScheduleData()

Function:
stb.getEPGScheduleData()
Prototype:
string stb.getEPGScheduleData()
Purpose:
Get EPG Schedule data.
"index":["event name", day, month, start hour, start minute, end hour, end minute, duration
hour,duration minute, type, days]
type value may be 1 :Once, 2: Daily, 3: Weekly

Confidential Page 52 9/28/2010


JavaScript Extensions

days will only take effect when type is 3: Weekly. This value needs to be changed to binary. For
example, "82" will be "1010010"(Sat, Fri, Thur, Wed, Tue, Mon, Sun), so it means recording will
start in Saturday, Thursday and Monday.
Parameters:

Return:
a string which can be transferred to a json object
NULL if there is no scheduled recording data
Example:
var stb=document.createstb();
var strservices;
strservices = stb.getEPGScheduleData ();

4.47 stb.isRecordingrunning()

Function:
stb.isRecordingrunning()
Prototype:
bool stb.isRecordingrunning()
Purpose:
Get Recording Running State.
Parameters:

Return:
true if recording is running
false if there is no recording now
Example:
var stb=document.createstb();
var success;
succss = stb.isRecordingrunning();

4.48 stb.setChannelByTriplet()

Function:
stb. setChannelByTriplet ()
Prototype:
void stb.setChannelByTriplet (int org_network_id, int ts_id, int service_id, bool
ignoreRBApp);
Purpose:
Switch DVB Channel by ID

Confidential Page 53 9/28/2010


JavaScript Extensions

Parameters:
org_network_id: Channel Original network ID
ts_id: Channel TS ID
service_id: Channel Service ID
ignoreRBApp: if this parameter is true,it’s indicate that RB app is going to be ignored
Return:
0: Success;
-1: Failure.

Example:
var stb = document. createstb ();
var service_id=0x11;
var ts_id=0x22;
var org_id=0x33;
stb. setChannelByTriplet (org_id, ts_id, service_id,true);

4.49 stb.setChannelByVirtualID()

Function:
stb.setChannelByVirtualID()
Prototype:
void stb.setChannelByVirtualID(int virtual_id, bool ignoreRBApp);
Purpose:
Switch DVB Channel by Virtual ID
Parameters:
virtual_id: Virtual ID
ignoreRBApp: if this parameter is true,it’s indicate that RB app is going to be ignored
Return:
0: Success;
-1: Failure.
Example:
var stb_media = document. createstb ();
var virtual_id = 1;
stb. setChannelByVirtualID (virtual_id,true);

4.50 stb.getDVBChannelGroup()

Function:
stb.getDVBChannelGroup()

Confidential Page 54 9/28/2010


JavaScript Extensions

Prototype:
string stb.getDVBChannelGroup();
Purpose:
Get channels data which belong to the same group with currently channel
Parameters:

Return:
a string which can be transferred to a json object
Example:
var stb = document. createstb ();
var strgroup;
strgroup = stb. getDVBChannelGroup ();

4.51 stb. stb_capturescreen ()

Function:
stb. stb_capturescreen ()
Prototype:
bool stb. stb_capturescreen (char *dir_name);
Purpose:
Capture full screen . save picture as BMP format
Parameters:
char *dir_name: Full directory name
Return:
True: Success;
False: Failure.
Example:
var stb = document. createstb ();
BOOL strgroup;
strgroup = stb. stb_capturescreen(“../../picture.bmp”);

4.52 stb. getreferervalue

Function:
stb. getreferervalue
Prototype:
String stb. getreferervalue
Purpose:

Confidential Page 55 9/28/2010


JavaScript Extensions

Get a application’s url. This application will launch other Hbbtv application use
“stb.directopenRBwithURL”
Parameters:
Return:
a String
Example:
var stb = document. createstb ();
var url=stb.getreferervalue;

4.53 stb. getcalledhbbtvurl

Function:
stb. getcalledhbbtvurl
Prototype:
String stb. getcalledhbbtvurl
Purpose:
Get a url which open by “stb.directopenRBwithURL”
Parameters:
Return:
a String
Example:
var stb = document. createstb ();
var url=stb. getcalledhbbtvurl;

Confidential Page 56 9/28/2010


JavaScript Extensions

5 Remote control key code

5.1 Key code value

This table lists the IR keys value used in JavaScript.

Key Value (e.which)


MUTE 0x4000008F
1 0x31
2 0x32
3 0x33
4 0x34
5 0x35
6 0x36
7 0x37
8 0x38
9 0x39
0 0x30
INFO 457
CLEAR 8
+ 447
- 448
EXIT 27
BACK 0x40000206
UP 38

Confidential Page 57 9/28/2010


JavaScript Extensions

Key Value (e.which)


LEFT 37
RIGHT 39
DOWN 40
ENTER 13
RED 403
GREEN 404
BLUE 405
YELLOW 406
EPG 458
TEXT 459
WEB 770
MENU 462
REW 412
FFWD 417
PLAY/PAUSE 415
STOP 413
ARCHIV 0x40000091
AUFNAHME 416

5.2 Sample

This is a sample in html.


<script>
function keyAction(e)
{
switch(e.which)
{
case 0x4000008F:
{
stb.debug(String("Mute"));
break;

Confidential Page 58 9/28/2010


JavaScript Extensions

}
case 0x31:
{
stb.debug(String(1));
break;
}
case 0x32:
{
stb.debug(String(2));
break;
}
case 0x40000207:
{
stb.debug(String("GOTO"));
break;
}
}
return 0;
}

document.onkeypress=keyAction;

</script>

6 Galio KeyPress Handler


This is about Galio Event Handler. Please see example code (Please pay more attention on
red below).
In JS code:
function keyAction(e)
{
nKeyCode= e.which;
switch(nKeyCode)
{
case MUTE:
//do some mute thing
break;
case VOL_UP:
//do some Volume up thing
break;
case OTHER_THING:
// do some other thing

Confidential Page 59 9/28/2010


JavaScript Extensions

break;
default:
{
/* Here it's very important, "return true" will active our application handler to deal with
this key, if there is a handler in VideoWeb application, likes a default handler, we
assumed that it hadn't deal by user, so we'll active our default handler
to handle it */
return true;
}
}
/* And "return false" means it will not handled by VideoWeb application, because we assumed that
it had been deal by user */
return false;
}

This means that, if you want to handle a Event you can add it to your key press handler, with a
return false. And if you don’t’ want to handle it, you can delete it from your key press handler and
return true, VideoWeb application would handle it if there is a default handler.

Confidential Page 60 9/28/2010

You might also like