Version API #2
Avaliable for firmwares version linux-qt 3.4.0 or higher.
Set-top-boxes TVIP display Web-content using WebKit engine.
JavaScript API in Set-top-boxes Tvip is based on the following main objects:
Objects do not require an explicit creation or any initialization and is accessible from any Web-page that is open in STB browser.
Add or change mount point with indicated id. If temp equal false, then mount point will be saved after device reload, if true - then mount point will be deleted after reload or application restart.The possible mount points types (type): 1 - SMB, 2 - NFS. Point name at mount system (for example, at pop-up message): name. Parameter options set specific options as object:
SMB:
{ "address": <address>, "folder": <folder>, "username": <username>, "password": <password> }
Here, <address> - IP-adress, domain or NetBIOS-server name, <folder> - name of sharing content, <username> и <password> - optional authorization credentials.
NFS:
{ "address": <address>, "folder": <folder> }
Here, <address> - IP-adress or domain server name, <folder> - full path to sharing catalog.
Returns API version.
Returns id of currently active interface language ('en', 'ru').
Returns currently time zone (for example, Europe/Moscow).
Returns current display mode (“1080i”, “1080p”, “720p”, “576i”, etc).
Returns directory list in a specified directory.
[ "Dir1", "Dir2", "Dir3" ]
Returns file objects list in a specified directory directory. Object contains file name and file size.
[ { "name": "file1", "size": 1234567 }, { "name" : "file2", "size" : 44444 } ]
name -file name, size - file size in bytes.
Gets variable from the browser store. If name not found, empty string returns.
Returns main MAC address as string. Usually it's Ethernet interface MAC.
Returns windows network workgroup list. Example:
['WORKGOUP', 'MYGROUP']
Performs servers search in specified group network group and returns NetBIOS server names
Example:
['MYPC', 'USER2']
Returns names of available network shares by NetBIOS or IP address defined by server parameter. Example:
['shared folder', 'Downloads']
Returns all mounted devises (local and network)
[ { "label": <label>, "path" : <ospath>, "fstype" : <file_system>, "writable": <writable>, "status": <status>, "size": <size>, "free" <free> }, ]
Object fields:
label - Resource name(label) visible to user;
path - mount point
fstype - FS type (e.g. vfat, ntfs, ext2, ext3, nfs, cifs;
writable - write access (“1” - yes, “0” - no);
status - mount point status (“0” - need mount, “1” - mount in progress, “2” - mount successfully, “3” - mount error, “4” - umount in progress, “5” - unmounted, “6” - umount error),
size - FS size,
free - Available free space.
Returns true, if directory osPath exists. Otherwise returns false.
Returns true, if file (not directory) with defined name osPath exists, false otherwise.
Launches system preferences Tvip.
Outputs debugging message to terminal(Linux) or logcat(Android).
Reboots system.
Removes mount point from mount manager. id - Mount point identifier
Setups UI color that could be consider as transparent for video layer. color in RGB model.
Defines HTTP-header for browser. header - header name, value - header value. If value is empty, previously defined header will be purged.
Saves variable in browsers persistent storage. All variables are available for all browser pages.
Setups filename filter for getDirectoryFiles and getDirectoryDirs. | Will be count as delimiter.
? and * applicable as well.
e.g.
*.avi|*.mp3
If enabled=true, Cursor key press(on remote) event will be pass to Java Script directly, instead of default virtual keyboard handler.
If enabled==true, Remote “Menu” button press event will be pass to JS, instead of Tvip menu call.
If enabled==true, remote press “S.INFO” event will be passed to JS, instead of Tvip system info call.
If enabled==true, remote press “Settings” will be passed to JS, instead of Tvip settings menu call.
Switches STB in sleep mode (enabled==true) or return it to operation mode (enabled==false).
Virtual keyboard show (show=true) or hide (show=false).
Resets settings:
transparent color;
HTTP-header;
file filter.
Resets playback. If we don't need playback after page change this routine should be called.
Starts playback defined URL(local path also welcome).
Parameter mode can be:
vod - URL contains VOD-file (with final length specified);
live - URL contains live TV-stream (Timeshift and DVR are welcome);
Examples:
playUrl ("udp://239.1.1.1", "live"); // Start play multicast-stream; playUrl ("http://domain.tv/movies/movie.mkv", ""); // Start play file via http; playUrl ("http://domain.tv/hls/playlist.m3u8", ""); // Start play HLS-video;
Sets up video window size. Position seting up according current video out mode.
If w = 0 и h = 0, Full screen mode used.
If onTop = true, video window drows above UI.
Stops playback if any.
sets playback on pause.
Continues playback.
Sets playback position in milliseconds. Keep in mind that beginning of playback is minPosition see below
Returns current playback position.
Returns minimal playback position (e.g. content beginning)
Returns maximum playback position (e.g. content ends).
Sets volume level from 0 to 100
Returns current volume level from 0 to 100
Turns off (mute=true) or turns on (mute=false) sound.
Returns true, if muted, otherwise false;
Returns the type of container being played (e.g. mpegts, avi, matroska)
Returns content being played media streams count (audio, video, subtitles etc)
Returns an object with media stream info
{ "type": <videotype>, "id": <id>, "codec": <codec>, "lang" : <lang> }
Here:
videotype - media stream type;
“v” - video,
“a” - audio,
“s” - subtitles;
id - PID;
codec - codec name;
lang - Audio stream ISO 639 language code.
Returns currently played video stream index.
Returns currently played audio stream index.
Sets active audio stream (index).
Sets aspect ratio.
Available values:
“box” - Original
“full” - Full screen
“zoom” - Zoomed.
Adds new record job.
Here:
name - record name,
url - stream URL (MPEGTS via UDP, RTP, HTTP are supported.)
path - Local path to record,
start и end - start/stop time in UNIX TIMESTAMP or “YYYYMMDDTHHmmss” format.
Returns unique record job id.
Removes record job by id. If removeFile=true, stream stored to storage also will be removed.
Returns true in success.
Updates start time or(and) end time of recording id. If we need to set only one parameter leave second one empty.
Fromat for start end see at addRecord
Returns currently added jobs list.
Returns object (by id) with record parameters.
{ "id": <id>, "name": <name>, "startTime": <start>, "endTime" : <end>, "url" : <url>, "status" : <status> }
Here:
<id>, <name>, <start>, <end> - corresponds with addRecord routine parameter;
<status> - record status:
“waiting” - waiting for record,
“recording” - record in progress,
“finished” - record finished,
“error” - error occurred.
TvipEvent consist of Callback functions, which may be overloaded for events capturing.
onPlayerStateChange(int oldState, int newState);
Calls on mediaplayer playback status change. oldState - previous player status, newState - new player status.
Player possible status:
onSystemEvent(String codename, Object args);
On system event.
Examples codename: