Beruflich Dokumente
Kultur Dokumente
JavaScript Extensions
Version 1.2.1
Copyright VideoWeb
CONTENTS
2 STB_MEDIA....................................................................................................................................5
3 STB_DISPLAY ..............................................................................................................................24
4 STB .................................................................................................................................................29
1.1 Overview
Content Description
stb_media A class of media playback and media setting.
Remote control key code Key code value of remote control in JavaScript.
2 stb_media
stb_media.event The variable contain the code of the last media event
occurred.
2.2 document.createstbmedia()
Function:
document.createstbmedia ()
Prototype:
stb_media document.createstbmedia ();
Purpose:
Create a new stb_media object.
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()
{
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.
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:
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:
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.
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:
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();
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
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:
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));
}
}
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:
{
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:
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));
}
}
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.
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:
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);
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 ();
3 stb_display
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:
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()
{
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();
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();
}
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)
{
stb_display.setMatchMethod(matchmethod);
}
4 stb
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.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)
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.directopenRBwithURL() Directly enter into specified URL Redbutton State and play the
specified programme
Stb. getDVBChannelGroup() Get all services information which belong to same group with
current service
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)
{
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:
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)
{
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);
}
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);
}
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;
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:
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.
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:
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:
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:
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);
}
4.26 stb.getProperty()
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");
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
-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”);
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();
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();
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”
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”);
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 */
4.43 stb.callDRMClient()
Function:
stb.callDRMClient(char * url)
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 */
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
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();
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
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
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()
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 ();
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”);
Function:
stb. getreferervalue
Prototype:
String stb. getreferervalue
Purpose:
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;
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;
5.2 Sample
}
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>
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.