(2010) App Development Guide For Internet@TV (V1.09)
(2010) App Development Guide For Internet@TV (V1.09)
(2010) App Development Guide For Internet@TV (V1.09)
for Internet@TV
Year 2010
Version 1.09
Internet@TV
Application Development Guide for Internet@TV
INTERNET@TV .............................................................................................................................................................. 1
PREFACE ............................................................................................................................................................................ 7
1. INTRODUCTION .................................................................................................................................................... 8
3. APPLICATIONS .................................................................................................................................................... 10
2
Application Development Guide for Internet@TV
3
Application Development Guide for Internet@TV
5.6.7. Reference................................................................................................................................................... 64
5.6.7.1. CImageViewer ........................................................................................................................................................64
5.6.7.7. hide().......................................................................................................................................................................68
4
Application Development Guide for Internet@TV
5.6.7.9. play().......................................................................................................................................................................68
5.6.7.17. show().................................................................................................................................................................73
5
Application Development Guide for Internet@TV
9. APPENDIX.............................................................................................................................................................. 97
6
Application Development Guide for Internet@TV
Preface
Purpose of Document
This document is written to help application developers who enjoy the Internet@TV service by providing
an overview of the service and basic knowledge required to be obtained by application developers. Using
this document, developers can develop and manage applications for digital TVs.
Target Readers
This document is aimed at programmers who have used web development languages such as HTML, CSS
and JavaScript. This document will be even more helpful for those who have web development experience.
7
Application Development Guide for Internet@TV
1. Introduction
This section describes what Internet@TV is, how it is configured and how it works.
With Internet@TV, digital TV users can not only download applications from HubSite and install them in
their TVs but also personally develop applications tailored to their needs and install them in their TVs.
PAVV
HubSite
8
Application Development Guide for Internet@TV
2. Samsung Internet@TV
This section describes the operating principle and environment of Samsung Internet@TV.
We will look at Maple, the browser dedicated to internet TVs manufactured by Samsung, in Chapter 7.
Maple.
9
Application Development Guide for Internet@TV
3. Applications
This section looks at applications that we will develop for Samsung TVs.
You can exploit the Software development kit (SDK) to develop new applications designed to be run on
your TV screen.
10
Application Development Guide for Internet@TV
11
Application Development Guide for Internet@TV
Get the Application Press the INTERNET(INFO.L) button on the remote control or go through Menu>
Manager started Application>Internet@TV to open the application
Press arrow button located in the center of the remote control to select an
Select an application
application.
12
Application Development Guide for Internet@TV
Settings
The Application Manager provides several JavaScript modules used in applications. This enhances
convenience of application development. If you want to get detailed information on use of a common
module, see Ch. 5 Common modules.
13
Application Development Guide for Internet@TV
4. Creating an application
An index.html file. The file serves as the access point of the application.
An application configuration file. This is an XML file in the root of the application structure that holds
information about setting an application.
JavaScript files. These are used for a preview of the application and for controlling the behavior of
the application.
CSS files. The look of the application is determined by these files.
Image files, which are used by your application.
Let‟s make an application that displays text written in CSS and responds to remote control buttons events.
The structure and look of an application we will make now are shown as below.
14
Application Development Guide for Internet@TV
The config.xml file is called first among all the files the application has in it. <ver> tag value decides
whether to update the application and images designated in <ThumbIcon> tag are shown in thumbnail. For
information about other tags, turn to Ch. 4.3. config.xml.
<category>lifestyle</category>
<autoUpdate>y</autoUpdate>
<cpname>MyCP</cpname>
<cpauthjs></cpauthjs>
<login>y</login>
<ver>0.930</ver>
<mgrver>1.000</mgrver>
<fullwidget>n</fullwidget>
<srcctl>n</srcctl>
<ticker>n</ticker>
<childlock>n</childlock>
<audiomute>n</audiomute>
<videomute>n</videomute>
<dcont>y</dcont>
<network>y</network>
<hubsite>n</hubsite>
<widgetname>HelloWorld</widgetname>
<description>Welcome!</description>
<width>960</width>
<height>540</height>
<author>
<name>Samsung Electronics Co. Ltd.</name>
<email></email>
<link>http://www.sec.co.kr/</link>
<organization>Samsung Electronics Co. Ltd.</organization>
</author>
</widget>
15
Application Development Guide for Internet@TV
What you have to do next is writing index.html which will be the access point of the application. The
following example is about HTML code that includes the Main.js file under the JavaScript folder and calls
the Main.onLoad() function when the document is loaded.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Hello World!!</title>
<script type="text/javascript" language="javascript" src="JavaScript/Main.js"></script>
</head>
<body onload="Main.onLoad();">
<div>Welcome to Samsung application world!</div>
</body>
</html>
If the HTML document is loaded, the onLoad() function of the Main object is called, because you
registered the Main.onLoad() function in the onload property in the <body> tag. Make a Main object and
add the onload function.
If you have done all the work, you will get a debug message of Main.onLoad(). But the „Welcome to
Samsung application world!‟ that you entered will not appear on the TV screen. If the application is
successfully loaded, it has to ask the Application Manager to display itself on the screen using the common
module provided by the Application Manager. The common module is a library containing essential
functions provided by the Application Manager. For more information, refer to Ch. 5 Common Modules. Add
the following code to <head> of index.html.
16
Application Development Guide for Internet@TV
If the above code is added, a common module is available to use by JavaScript. Declare the common
module as a global variable for Main.js you were working on and call the sendReadyEvent() function. By
doing this, you can make the Application Manager display an application on the screen.
Ok, now run the application you‟ve just made. You will see the words “Welcome to Samsung application
world!” that you entered in the index.html file appearing on the screen. Maybe you don‟t like the look of
the application because its font size is too small and font color is just simple black. You may want to make
your application more stylish. Then, you can give the application a style using CSS.
Create a file in the CSS folder and enter text as you see in the below box to specify the style of the
„welcome‟ element.
body {
margin: 0;
padding: 0;
17
Application Development Guide for Internet@TV
background-color: transparent;
}
#welcome {
position: absolute;
left: 50px;
top: 50px;
width: 500px;
height: 50px;
background-color: #AFAFAF;
color: #99FFFF;
font-size: 30px;
text-align: center;
}
Now, we‟ll make your application respond to the remote control. By pressing any of the five buttons
located in the center of the remote control, you can change the words your application displays on the
screen.
If a button on the remote control is pressed, a „keydown‟ event occurs. An element having focus is
required to receive the event to the index.html file. Add <a> element and Register a function that will be
executed when that event occurs in the onkeydown property. Place focus on <a> and press the remote
control key, the function registered previously is executed.
Add <a> which executes Main.keyDown() method when a „keydown‟ event occurs.
<body onload="Main.onLoad();">
<div id='welcome'>Welcome to Samsung application world!</div>
<a href='javascript:void(0);' id='anchor' onkeydown='Main.keyDown();'></a>
</body>
Write a keyDown() method bringing key code value when pressing the remote control key
In a function processed by keys such as keydown(), each key has its own key code value.
The Application Manager provides a common module containing key code values to distinguish keys. Add
18
Application Development Guide for Internet@TV
the below code to <head> in the index.html file to use a common module „TVKeyValue‟.
Modify Main.js in order to change the contents of „welcome‟ Div. This creates common module objects,
classify keys in keydown() method, and define actions for each key. For detailed information on common
modules and key code list, see Chapter 5. Common Modules.
switch (keyCode) {
case tvKey.KEY_LEFT:
alert("left");
document.getElementById("welcome").innerHTML = "Nice to meet you.";
/**
* Code for Left key event!
*/
break;
case tvKey.KEY_RIGHT:
alert("right");
document.getElementById("welcome").innerHTML = "I'm so happy.";
break;
case tvKey.KEY_UP:
alert("up");
document.getElementById("welcome").innerHTML = "I Love you.";
break;
case tvKey.KEY_DOWN:
alert("down");
document.getElementById("welcome").innerHTML = "Good job.";
break;
case tvKey.KEY_ENTER:
19
Application Development Guide for Internet@TV
alert("enter");
break;
case tvKey.KEY_RETURN:
break;
}
}
You will see the value of the „welcome‟ Div tag change as you press the up, down, left or right button.
With Samsung Internet@TV, you can do almost everything you do on a web page. You can create “TV-
oriented” applications with extended functions using many plugins.
4.2.6.1. config.xml
<previewjs>PreviewHelloWorld</previewjs>
<cpname>Junyoung</cpname>
<cplogo>Resource/image/settings_logo.png</cplogo>
<cpauthjs></cpauthjs>
<ver>0.930</ver>
<mgrver>1.000</mgrver>
<fullwidget>n</fullwidget>
<srcctl>n</srcctl>
<ticker>n</ticker>
<childlock>n</childlock>
<audiomute>n</audiomute>
<videomute>n</videomute>
<dcont>y</dcont>
<network>y</network>
<hubsite>n</hubsite>
<widgetname>HelloWorld</widgetname>
<description>Welcome!</description>
<width>960</width>
<height>540</height>
20
Application Development Guide for Internet@TV
<author>
<name>Samsung SDS</name>
<email></email>
<link>http://acme-widget.example.com</link>
<organization>Acme Examples, Inc.</organization>
</author>
</widget>
4.2.6.2. index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Hello World!!</title>
<script type="text/javascript" language="javascript"
src="$MANAGER_WIDGET/Common/API/Widget.js"></script>
<script type="text/javascript" language="javascript"
src="$MANAGER_WIDGET/Common/API/TVKeyValue.js"></script>
<script type="text/javascript" language="javascript" src="JavaScript/Main.js"></script>
<body onload="Main.onLoad();">
<div id='welcome'>Welcome to Samsung widget world!</div>
<a href='javascript:void(0);' id='anchor' onkeydown='Main.keyDown();'></a>
</body>
</html>
4.2.6.3. Main.js
21
Application Development Guide for Internet@TV
switch (keyCode) {
case tvKey.KEY_LEFT:
alert("left");
document.getElementById("welcome").innerHTML = "Nice to meet you.";
/**
* Code for Left key event!
*/
break;
case tvKey.KEY_RIGHT:
alert("right");
document.getElementById("welcome").innerHTML = "I'm so happy.";
break;
case tvKey.KEY_UP:
alert("up");
document.getElementById("welcome").innerHTML = "I Love you.";
break;
case tvKey.KEY_DOWN:
alert("down");
document.getElementById("welcome").innerHTML = "Good job.";
break;
case tvKey.KEY_ENTER:
alert("enter");
break;
case tvKey.KEY_RETURN:
break;
}
}
4.2.6.4. Main.css
body {
margin: 0;
padding: 0;
background-color: transparent;
}
#welcome {
position: absolute;
left: 50px;
top: 50px;
width: 500px;
height: 50px;
background-color: #AFAFAF;
color: #99FFFF;
font-size: 30px;
text-align: center;
}
22
Application Development Guide for Internet@TV
4.3. config.xml
The config.xml file contains information about the application‟s execution, update, operating environment
setting and other related issues. Depending on that information, the Application Manager controls the
version of your application, sets an environment in which your application is run, and creates and manages
user accounts. The config.xml file should be located in the directory in which the application is installed,
and contain the following elements.
23
Application Development Guide for Internet@TV
24
Application Development Guide for Internet@TV
25
Application Development Guide for Internet@TV
4.3.2. Example
<?xml version="1.0" encoding="UTF-8"?>
<widget>
<ThumbIcon>Resource/image/icon/picasa_106.png</ThumbIcon>
<BigThumbIcon>Resource/image/icon/picasa_115.png</BigThumbIcon>
<ListIcon>Resource/image/icon/picasa_85.png</ListIcon>
<BigListIcon>Resource/image/icon/picasa_95.png</BigListIcon>
<category>lifestyle</category>
<autoUpdate>y</autoUpdate>
<cpname>Picasa</cpname>
<cpauthjs>Auth11101000000</cpauthjs>
<login>y</login>
<ver>2.000</ver>
<mgrver>1.035</mgrver>
<fullwidget>y</fullwidget>
<srcctl>n</srcctl>
<ticker>n</ticker>
<childlock>n</childlock>
<audiomute>y</audiomute>
<videomute>y</videomute>
<dcont>y</dcont>
<movie>y</movie>
<network>y</network>
<hubsite>n</hubsite>
<width>960</width>
<height>540</height>
<author>
<name>Samsung Electronics Co. Ltd.</name>
<email></email>
<link>http://www.sec.co.kr/</link>
<organization>Samsung Electronics Co. Ltd.</organization>
</author>
</widget>
26
Application Development Guide for Internet@TV
4.4. Single-Sign-On
This section describes SSO functions supported by the application manager, how to register account
information and get the information from the application.
Input of account information via TV remote control is so inconvenient that users could be stressed out if
they should enter account information whenever they use the application. To improve this inconvenience,
Single-Sign-On (hereinafter referred to as “SSO”) is provided by application manager. Application manager
saves the account information that users have entered and sends it to the application. These enable users
not to enter account information repeatitively. The account information is encrypted and saved in safe
area.
① Generate a TV Account
It is necessary to create a TV account to use SSO. TV account is an account generated in the Application
manager and has four-digit PIN number as a password. You can make the account in Settings-
>Internet@TV-ID.
③ Sign-in to TV account
You can sign in to the TV account created in ① pressing Red key on the initial screen. In general, account
information on several service sites can be registered in a TV account. Sign-in make you enable to get
account information on a service site you want to get in several applications.
④ Execution of an Application
At this stage, the application manager decides whether the application SSO is available to sign in or not. If
available, the account information is given. Account information should be inputted through the process in
②.
27
Application Development Guide for Internet@TV
In an application, account information coexists with various circumstances information provided by the
application manager. Thus, it is required to use account information after parsing.
Following chapter describes modules necessary to be realized in an application to register service sites,
how to parse and use the account information received by the application manager.
Registration of account information on service sites can be done through „Settings‟ -> Internet@TV ID. If
you wish to display the names of the service sites you want to show, configure config.xml as suggested
below.
<cpname>YourCompany</cpname>
<login>y</login>
Then, you can find YourCompany item in the list of service sites. If you can‟t, restart TV. Application
manager could need to be reloaded.
Now, the account information on service site, „YourCompany‟ can be entered. However, if there is no
module which confirms validity of the entered account information, the registration cannot be completed.
You should generate the module in person.
Validity Confirmation is to make sure that the entered account information is consistent with the ID and
Password which are available to sign-in on the real service site. If sign-in can be made by API in each
service site, the information is turned out to be valid.
In Google, there is ClientLogin to judge validity. If sign-in is successfully done and auth token is granted,
the account information is regarded valid. Refer to the URL states below regarding Client Login.
(http://code.google.com/intl/ko/apis/accounts/docs/AuthForInstalledApps.html)
28
Application Development Guide for Internet@TV
<cpauthjs>Auth11101000000</cpauthjs>
② Create a file
Create a js file corresponding to the entered file name in the process of ①. A module will be written in
this file. This file is embedded in the top level directory where index.html exists.
Example
// Object Generated
var Auth11101000000 = {
}
// checkAccount Method Added
Auth11101000000.checkAccount = function (id, pw, fnCallback) {
/**
* The id and pw inputted from the application manager are transferred to the factor.
* Check validity of id and pw, and then operate callback function.
*/
// ...
// Confirmation on Validity
// ...
29
Application Development Guide for Internet@TV
}
}
The value transferring to the Callback function and the effect are like below.
Applications are able to get account information on service sites. Proceed like the order stated below.
<cpname>YourCompany</cpname>
<login>y</login>
30
Application Development Guide for Internet@TV
All the conditions are satisfied, ID and Password are transferred to Browser global variable
window.location.search. This variable includes circumstances information, and it should be parsed. Refer
to 6.7 for further information on window.location.search.
31
Application Development Guide for Internet@TV
4.5. Reset
Reset describes functions to initialize the application.
The function to execute initial modules realized by applications when deleting or initializing applications
in Application Manager.
var MyReset= {
…
}
MyReset.reset = function() {
32
Application Development Guide for Internet@TV
...
...
alert("Reset Complete!");
}
33
Application Development Guide for Internet@TV
The below example is HTML code that includes XHRExample.js, and executes the XHRExample.onload()
function when the „load‟ event occurs.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>XHR Example</title>
<script type="text/javascript" language="javascript"
src="$MANAGER_WIDGET/Common/API/TVKeyValue.js"></script>
<script type="text/javascript" language="javascript"
src="$MANAGER_WIDGET/Common/API/Widget.js"></script>
<script type="text/javascript" language="javascript" src="XHRExample.js"></script>
</head>
<body onload="XHRExample.onload()">
<div id='intro'>XHR Example.</div>
</body>
</html>
The below is JavaScript code. XHRExample is has been declared as an object and has the variable of
XHRObj in it. If XHRObj already exists, XHRExample calls the destroy() method. We will look at this more
specifically later in this chapter. If an XHR object has been successfully created, set it and request data. If
the state of XHR changes to 4, which means data reception is completed, recieveData() that you
registered in onreadystatechange is executed.
var XHRExample = {
XHRObj : null
}
XHRExample.onload = function () {
widgetAPI.sendReadyEvent();
var URL = ""; // Test URL here
34
Application Development Guide for Internet@TV
if (this.XHRObj != null)
this.XHRObj.destroy();
this.XHRObj = new XMLHttpRequest();
if (this.XHRObj) {
this.XHRObj.onreadystatechange = function () {
if (XHRExample.XHRObj.readyState == 4) {
XHRExample.recieveData();
}
};
this.XHRObj.open("GET", URL, true);
this.XHRObj.send(null);
}
}
XHRExample.recieveData = function () {
alert(this.XHRObj.responseText);
}
The above example has two remarkable points. One is that the variable of XHRObj is in the XHRExample
object. The other is that the destroy() method is called before an object is assigned to XHRObj.
With Samsung TVs, if you run out of the memory by continuing to create and use the XHR object,
applications in your TV do not work anymore at a certain time. In order to avoid this kind of situation, you
should delete objects you used in the past and assign new ones when you use XHR. To free up objects that
had been used, the object pointer should be maintained. For this, developers should memorize and
manage the variable dealing with XHR objects.
If you want to remove an XHR object from the memory, use the destroy() method of it, and this is the
method that Maple provides to allow you to use the limited memory efficiently.
XHRObjet.destroy
Syntax XHRObject.destroy()
Parameter None
Return Value None
Remarks This function, which is executed to optimize the memory usage, is only provided by
35
Application Development Guide for Internet@TV
In the above example, two common modules provided by the Application Manager are included. For more
information, turn to Ch. 5 Common modules.
36
Application Development Guide for Internet@TV
5. Common modules
Create an object.
alert(tvKey.KEY_LEFT);
5.3. TVKeyValue
TVKeyValue
37
Application Development Guide for Internet@TV
38
Application Development Guide for Internet@TV
KEY_STOP
KEY_1
KEY_2
KEY_3
KEY_4
KEY_5
KEY_6
KEY_7
KEY_8
KEY_9
KEY_0
KEY_EMPTY
KEY_PRECH
KEY_SOURCE
KEY_CHLIST
KEY_MENU
KEY_WLINK
KEY_CC
KEY_CONTENT
KEY_FAVCH
KEY_REC
KEY_EMODE
KEY_DMA
KEY_PANEL_CH_UP
KEY_PANEL_CH_DOWN
KEY_PANEL_VOL_UP
KEY_PANEL_VOL_DOWN
KEY_PANEL_ENTER
KEY_PANEL_SOURCE
KEY_PANEL_MENU
KEY_PANEL_POWER
Methods None
39
Application Development Guide for Internet@TV
5.4. Widget
This is an object that has functions needed for desirable operation of an application. A method that
notifies the Application Manager of starting of an application, a method that registers and frees up keys
users want to use, and other methods are contained in this object.
Widget
5.4.1. sendReadyEvent()
sendReadyEvent
Notifies the Application Manager that the application is ready to be displayed. This event should be passed
to display and run the application on the screen.
Syntax sendReadyEvent()
Parameter None
Return Value None
Remarks (Since Internet@TV version 2.265)
40
Application Development Guide for Internet@TV
5.4.2. sendExitEvent()
sendExitEvent
Brings the same effect as pressing the exit key. Stops the application and goes back to the TV screen.
Syntax sendExitEvent()
Parameter None
Return Value None
Remarks (Since Internet@TV version 2.265)
var widgetAPI = new Common.API.Widget();
Example
widgetAPI.sendExitEvent ();
Enumeration None
5.4.3. sendReturnEvent()
sendReturnEvent
Brings the same effect of pressing the Return key. Finishes the application and takes you to the Application
Manager.
Syntax sendReturnEvent()
Parameter None
Return Value None
Remarks (Since Internet@TV version 2.265)
var widgetAPI = new Common.API.Widget();
Example
widgetAPI.sendReturnEvent ();
Enumeration None
5.4.4. blockNavigation()
blockNavigation
41
Application Development Guide for Internet@TV
Syntax blockNavigation(keyEvent)
Parameter keyEvent: Key event
Return Value None
KEY_RETURN and KEY_EXIT events forcibly close the operating application. The func
Remarks prevents forced closure and keep being executing.
(Since Internet@TV version 2.265)
function keyDown () {
switch(event.keyCode) {
case this.tvKey.KEY_LEFT:
// Do something
break;
case this.tvKey.KEY_RIGHT:
// Do something
break;
case this.tvKey.KEY_RETURN:
Example widgetAPI.blockNavigation(event);
// Not terminated
break;
case this.tvKey.KEY_EXIT:
// Terminated by force
break;
default:
break;
}
}
Enumeration None
5.4.5. putInnerHTML()
putInnerHTML
42
Application Development Guide for Internet@TV
widgetAPI.putInnerHTML(divElement, contents);
Enumeration None
5.4.6. getChannelWidgetListPath()
getChannelWidgetListPath
Method that brings the path of xml file having the child application list of the current channel bound
application
Syntax getChannelWidgetListPath()
Parameter None
Return Value string : xml file path
This method is used when the channel bound application needs information on the
Remarks currently installed child application.
(Since Internet@TV version 2.265)
var widgetAPI = new Common.API.Widget();
Example
var xmlPath = widgetAPI.getChannelWidgetListPath();
Enumeration None
5.4.7. getSearchWidgetListPath()
getSearchWidgetListPath
Method that brings the path of xml file having the list of applications related
Syntax getSearchWidgetListPath()
Parameter None
Return Value string : xml file path
This method is used when a search tag in config.xml requires information on an
Remarks application whose search tag is set as „y‟.
(Since Internet@TV version 2.265)
var widgetAPI = new Common.API.Widget();
Example
var xmlPath = widgetAPI.getSearchWidgetListPath();
Enumeration None
43
Application Development Guide for Internet@TV
5.4.8. runSearchWidget()
runSearchWidget
Syntax runSearchWidget ()
appID : The application ID you intend to operate
Parameter
extraInfo : The string that transferred to the executing application
Return Value None
This method is used when the channel bound application requires information on the
Remarks installed child application at present.
(Since Internet@TV version 2.265)
var widgetAPI = new Common.API.Widget();
Example
widgetAPI.runSearchWidget(“111011000001”,”key1=value1&key2=value2”);
Enumeration None
5.4.9. checkSapTicket ()
checkSapTicket
Method called when checking to have the valid ticket for current logged-in user.
Syntax checkSapTicket ()
Parameter None
Return Value None
You should register event handler for passing the return value.
If you have valid ticket, the return value is “stat=ok&ticket=686a8281-e952-4dcc-
Remarks a67b-57e8f92e5530”
Otherwise, it is “stat=fail&ticket=null”.
(Since Internet@TV version 3.037)
// Register Event Handler
curWidget.onWidgetEvent = AAAA;
44
Application Development Guide for Internet@TV
}
Enumeration None
5.4.10. requestSapTicket ()
requestSapTicket
Method called when requesting new Sap Ticket for Application Server.
Syntax requestSapTicket ()
Parameter None
Return Value None
You should register event handler for passing the return value.
If new ticket is generated normally, the return value is “stat=ok&ticket=686a8281-
Remarks e952-4dcc-a67b-57e8f92e5530”
Otherwise, it is “stat=fail&ticket=null”.
(Since Internet@TV version 3.037)
// Register Event Handler
curWidget.onWidgetEvent = AAAA;
5.5. Plugin
The Application Manager provides a wrapper class that allows you to use some plugin functions in more
convenient ways. If you want to take advantage of this class, just insert objects needed for use of plugins
in the index.html document. Then, the Application Manager will give you an appropriate class method.
Plugin
45
Application Development Guide for Internet@TV
46
Application Development Guide for Internet@TV
style='opacity:0.0;background-color:#000000;width:0px;height:0px;'></OBJECT>
pluginObjectVideo
<OBJECT id='pluginObjectVideo' border=0 classid='clsid:SAMSUNG-INFOLINK-VIDEO'
style='opacity:0.0;background-color:#000000;'></OBJECT>
pluginObjectNNavi
<OBJECT id='pluginObjectNNavi' classid='clsid:SAMSUNG-INFOLINK-NNAVI'
style='opacity:0.0;background-color:#000000;width:0px;height:0px;'></OBJECT>
pluginObjectAppCommon
<OBJECT id='pluginObjectAppCommon' classid='clsid:SAMSUNG-INFOLINK-APPCOMMON'
style='opacity:0.0;background-color:#000000;width:0px;height:0px;'></OBJECT>
5.5.1. setOnWatchDog()
setOnWatchDog
Syntax setOnWatchDog()
Parameter None
Return Value None
Remarks (Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.setOnWatchDog();
Enumeration None
5.5.2. setOffWatchDog()
setOffWatchDog
Syntax setOffWatchDog()
Parameter None
Return Value None
Remarks (Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.setOffWatchDog();
Enumeration None
47
Application Development Guide for Internet@TV
5.5.3. setOnOSDState()
setOnOSDState
5.5.4. setOffOSDState()
setOffOSDState
48
Application Development Guide for Internet@TV
5.5.5. registKey()
registKey
Syntax registKey(pNumKeyCode)
Parameter pNumKeyCode: key code
Return Value None
Registration/Unregistration of keys should be done after window.onshow event. Refer
Remarks to Chap. 6.4 How to use keys on remote control for more details.
(Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.registKey(tvKey.KEY_ TOOLS);
Enumeration None
5.5.6. unregistKey()
unregistKey
Syntax unregistKey(pNumKeyCode)
Parameter pNumKeyCode: key code
Return Value None
Registration/Unregistration of keys should be done after window.onshow event. Refer
Remarks to Chap. 6.4 How to use keys on remote control for more details.
(Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.unregistKey(tvKey.KEY_ TOOLS);
Enumeration None
5.5.7. registIMEKey()
registIMEKey
49
Application Development Guide for Internet@TV
Syntax registIMEKey()
Parameter None
Return Value None
Registers number keys from 0 to 9, „-„(hyphen), and previous channel key used in
entering IME.
Remarks Registration/Unregistration of keys should be done after window.onshow event. Refer
to Chap. 6.4 How to use keys on remote control for more details.
(Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.registIMEKey();
Enumeration None
5.5.8. unregistIMEKey()
unregistIMEKey
Syntax unregistIMEKey()
Parameter None
Return Value None
Unregisters number keys from 0 to 9, „-„(hyphen), previous channel key used in
entering IME.
Remarks Registration/Unregistration of keys should be done after window.onshow event. Refer
to Chap. 6.4 How to use keys on remote control for more details.
(Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.unregistIMEKey();
Enumeration None
5.5.9. registAllKey
registAllKey
50
Application Development Guide for Internet@TV
Syntax registAllKey()
Parameter None
Return Value None
Registers all keys
Registration/Unregistration of keys should be done after window onshow event. Refer
Remarks
to Chap. 6.4 How to use keys on remote control for more details.
(Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.registAllKey();
Enumeration None
5.5.10. unregistAllKey()
unregistAllKey
Syntax unregistAllKey()
Parameter None
Return Value None
Unregisters all keys
Registration/Unregistration of keys should be done after window onshow event. Refer
Remarks
to Chap. 6.4 How to use keys on remote control for more details.
(Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.unregistAllKey();
Enumeration None
5.5.11. registFullWidgetKey()
registFullWidgetKey
Syntax registFullWidgetKey()
Parameter None
51
Application Development Guide for Internet@TV
5.5.12. registPartWidgetKey()
registPartWidgetKey
Syntax registPartWidgetKey ()
Parameter None
Return Value None
Registers keys for part widget
Registration/Unregistration of keys should be done after window onshow event. Refer
Remarks
to Chap. 6.4 How to use keys on remote control for more details.
(Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI. registPartWidgetKey ();
Enumeration None
5.5.13. SetBannerState()
SetBannerState
A function using when you want to put volume and channel OSD with the application.
52
Application Development Guide for Internet@TV
pluginAPI.unregistKey(tvKey.KEY_VOL_UP);
pluginAPI.unregistKey(tvKey.KEY_VOL_DOWN);
pluginAPI.SetBannerState(PL_NNAVI_STATE_BANNER_VOL);
Enumeration None
5.5.14. ShowTools()
ShowTools
53
Application Development Guide for Internet@TV
5.5.15. setOnIdleEvent()
setOnIdleEvent
The function to set idle on to close the application in case that there is no input for a certain time
Syntax setOnIdleEvent()
Parameter None
Return Value None
1. Default is set as „Idle ON‟.
2. Recall the function when idle process is required after calling setOffIdleEvent
Remarks
method.(ex. When closing image playing)
(Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.setOnIdleEvent();
Enumeration None
5.5.16. setOffIdleEvent()
setOffIdleEvent
The function to set idle off in order not to close the application despite no input for a certain time
Syntax setOffIdleEvent()
Parameter None
Return Value None
1. Default is set as „idle ON‟.
Remarks 2. Setting Idle off is needed in case of watching clips for a long time
(Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.setOffIdleEvent();
Enumeration None
5.5.17. setOnScreenSaver()
setOnScreenSaver
54
Application Development Guide for Internet@TV
Syntax setOnScreenSaver()
Parameter None
Return Value None
Screensaver is off when the application is closed.
Remarks
(Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.setOnScreenSaver();
Enumeration None
5.5.18. setOffScreenSaver()
setOffScreenSaver
Syntax setOffScreenSaver()
Parameter None
Return Value None
Available after calling setOnScreenSaver
Remarks
(Since Internet@TV version 2.265)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.setOffScreenSaver();
Enumeration None
5.5.19. isViewerKey()
isViewerKey
The function to decide whether the key value currently entered is for TV View or application
55
Application Development Guide for Internet@TV
5.5.20. setOnFullScreen ()
setOnFullScreen
Syntax setOnFullScreen()
Parameter None
Return Value None
In case of <fullwidget>y</fullwidget>, it is not necessary to call this function.
Remarks
(Since Internet@TV version 2.306)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.setOnFullScreen();
Enumeration None
5.5.21. setOffFullScreen()
setOffFullScreen
Syntax setOffFullScreen()
Parameter None
Return Value None
Available after calling setOnFullScreen.
Remarks
(Since Internet@TV version 2.306)
var pluginAPI = new Common.API.Plugin();
Example
pluginAPI.setOffFullScreen();
Enumeration None
56
Application Development Guide for Internet@TV
5.6. CImageViewer
Introduces a common module „ClmageViewer‟ and describes how to use it
5.6.1. CImageViewer?
CImageViewer is a common module that enables JPEG files to be played in SAMSUNG DTV. With this
module, Images can be displayed on DTV big screen with high resolution,1920 x 1080 pixels. In addition,
images are marked by scaling the size you need at the location you prefer, and transition effect in various
manners is available.
If you want to utilize CImageViewer, TV source should be designated as a Media source. Source Transition
can be made by setting <srcctl> item to „y‟ or through SetMediaSource() of TVMW Plugin.
5.6.2. Specifications
Features Description
1920 x 1080 pixels
Images are displayed in Media source. The display pixel of the
Resolution
application is marked as 960 x 540 pixels, but that of the displaying
image in media source is marked as 1920 x 1080 pixels.
Supported file format JPEG only
Designate the area where an image should be displayed and play it, the
image is scaled in observance of the area you set. At this stage,
Scaling range
resolution should be set over 300 pixels. If it is less than 30 pixels,
images can be distorted or flicking.
Total 10 modes are provided.
(NONE, FADE1, FADE2, BLIND, SPIRAL, CHECKER, LINEAR, STAIRS, WIPE,
Transition Effects
RANDOM)
Refer to 5.6.4. Transition Effect for more information.
57
Application Development Guide for Internet@TV
② Create instance
Create ImageViewer instance.
var ImageViewer = new CImageViewer('Common ImageViewer');
③ Initialize ImageViewer
Set the area where images are displayed and functions which will execute each event. show() method
shows the area managed by ImageViewer on screen.
Area designation via setFrameArea() method is executed based on basic resolution (960x540 pixel). The
appointed area operates at 1920x1080 pixel.
④ Play images
Play images. Images remain original proportion at the designated areas and they are indicated by scaling.
The function to give special effects. The effect applies to the whole screen not to the image area.
Following describes the process to transfer page 1 to page 2. There are 10 modes available.
58
Application Development Guide for Internet@TV
Effect Description
NONE Transition without effects.
FADE1 Page 1 is faded out and page 2 is faded in.
FADE2 Page 1 is white faded out and page2 is faded in.
BLIND Page 2 appears with blind effect.
SPIRAL Page 2 appears spinning clockwise from the center.
CHECKER Page 2 appears gradually in a grid pattern.
LINEAR Each line of Page 1 is replaced with the lines of page 2 from left to right.
STAIRS The page is transformed to page 2 gradually in the shape of steps from upper left
to lower right.
WIPE Page transition happens when the central is spread up and down, or upper and
down sides are reached to the center.
RANDOM Effects above except for NONE are operated randomly.
Display the first image Prepare the second image Display the second image Prepare the third
image …
Play the first image through .play(). Buffering complete event occurs while playing, afterward,
Rendering complete event which informs that the image are thoroughly scattered on screen takes
place. Then, call prepareNext() to prepare next image. The screen has not been changed because
preparation is proceeded on background. When the image is ready to show, Buffering complete event
informs that. Since this point, Transition Effect is available to see by calling .showNow(). After the
Effect is completed, Rendering complete event occurs again to proceed next image.
59
Application Development Guide for Internet@TV
① ImageViewer Setup
Full screen is designated as area of use for ImageViewer. Register a function to find out the points an
image started to be loaded and playing is over.
ImageViewer.startSlideshow();
60
Application Development Guide for Internet@TV
⑤ Start Effect
Transition effect starts to play once showNow() is called. When Effect animation is completed, Rendering
Complete event, which indicates completion of image display, takes place. Successive Transition effect
can be realized by reiterating process ④. Be sure to remember that calling showNow() should be made
after Buffering Complete event.
ImageViewer.endSlideshow();
Images are displayed at the center of screen in original size. If the size of original image is larger than
width 1920 pixels and height 1080 pixels, the image will be downscaled in accordance with aspect ratio,
and displayed in the center screen.
61
Application Development Guide for Internet@TV
Hardware restrictions
SAMSUNG DTV has several models, but some of them could not support Transition effect due to hardware
restrictions. CImageViewer provides isEffectAvailable() method to check the availability.
5.6.5. Events
ImageViewer loads various events in order to control image display more precisely. You can operate events
after registering a function to the necessary Event.
ImageViewer displays images in application or USB as well as on the Internet. A special path starting with
„$‟ is necessary to display images in application or USB.
62
Application Development Guide for Internet@TV
Your TV has more than two USB ports. If you need to control more than two USBs or use USB with divided
partitions, other functions in Storage plugin are required.
63
Application Development Guide for Internet@TV
else {
files.push(data[i].name);
}
}
The whole path of image files in USB is created by the file information figured above.
…
var USBImageFile = USBRootPath +'/'+ directory +'/'+ file;
'$USB_DIR/sda1/myphotos/picture_2.jpg'
ImageViewer.play(USBImageFile);
5.6.7. Reference
5.6.7.1. CImageViewer
CImageViewer
64
Application Development Guide for Internet@TV
5.6.7.2. Effect
Effect
65
Application Development Guide for Internet@TV
ImageViewer.Effect.FADE1;
NONE
FADE1
FADE2
BLIND
SPIRAL
Members
CHECKER
LINEAR
STAIRS
WIPE
RANDOM
Methods None
5.6.7.3. clearScreen()
clearScreen
Syntax ImageViewer.clearScreen()
Parameter None
Return Value None
stop() is not able to remove the playing image. To delete the image, call clearScreen.
Remarks
(Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
Example
ImageViewer.clearScreen();
Enumeration None
5.6.7.4. destroy()
destroy
Syntax ImageViewer.destroy()
Parameter None
Return Value None
If you have used ImageViewer, this function should be called when closing the
application. It is recommended that the function registered onunload function of
Remarks
<body> element call this method. The function is called when the application ends.
(Since Application Manager 2.269)
66
Application Development Guide for Internet@TV
5.6.7.5. endSlideshow()
endSlideshow
Syntax ImageViewer.endSlideshow()
Parameter None
Return Value None
Call startSlideshow() to enter slideshow mode which includes transition effect.
Remarks prepareNext() and showNow() work only in slideshow mode.
(Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
ImageViewer.startSlideshow();
Example
… // Use transition effect
ImageViewer.endSlideshow();
Enumeration None
5.6.7.6. getStopFlag()
getStopFlag
Syntax ImageViewer.getStopFlag();
Parameter None
Boolean
Return Value
If the ImageViewer is stopped, return „true‟, if it is operating, return „false‟.
Remarks (Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
Example
ImageViewer. getStopFlag();
Enumeration None
67
Application Development Guide for Internet@TV
5.6.7.7. hide()
hide
Syntax ImageViewer.hide();
Parameter None
Return Value None
Remarks (Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
ImageViewer.show();
5.6.7.8. isEffectAvailable()
isEffectAvailable
Syntax ImageViewer.isEffectAvailable();
Parameter None
Boolean
Return Value If user settings are feasible for Transition effect, return „true‟, if not, return „false‟.
(Since Application Manager 2.269)
Some models do not support Transition effect due to hardware restrictions. In these
Remarks
models, Effect animation is not workable even in slideshow mode.
var ImageViewer = new CImageViewer('Common ImageViewer');
Example
ImageViewer.isEffectAvailable();
Enumeration None
5.6.7.9. play()
Play
Plays images
68
Application Development Guide for Internet@TV
5.6.7.10. prepareNext()
prepareNext
Method to load the next image to execute Transition effect in slideshow mode
69
Application Development Guide for Internet@TV
5.6.7.11. setFrameArea()
setFrameArea
Sets the area where images are marked. Images are displayed within the area.
70
Application Development Guide for Internet@TV
5.6.7.12. setOnBufferingComplete()
setOnBufferingComplete
Registers a function executed in case of Buffering complete event while loading an image
Syntax ImageViewer.setOnBufferingComplete(callback:function);
callback:function
Parameter
The function executed in the event of Buffering complete event
Return Value None
Buffering complete event occurs after image loading. If this event takes places after
calling prepareNext(), it means that the image is ready for Transition effect. At this
Remarks
stage, calling showNow() begins effect animation.
(Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
ImageViewer.setOnBufferingComplete(function(){
Example
// blah blah
});
Enumeration None
5.6.7.13. setOnBufferingStart()
setOnBufferingStart
Syntax ImageViewer.setOnBufferingStart(callback:function);
callback:function
Parameter
The function executed in the event of Buffering start event
Return Value None
If the image you intend to play is on the Internet, this event happens when starting to
Remarks load actual image data after connecting to the server successfully.
(Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
ImageViewer.setOnBufferingStart(function(){
Example
// blah blah
});
Enumeration None
71
Application Development Guide for Internet@TV
5.6.7.14. setOnNetworkError()
setOnNetworkError
Syntax ImageViewer.setOnNetworkError(callback:function);
callback:function
Parameter
The function executed in the event of Network error event
Return Value None
This event occurs in case of network errors while loading images.
Remarks
(Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
ImageViewer.setOnNetworkError(function(){
Example
// blah blah
});
Enumeration None
5.6.7.15. setOnRenderError()
setOnRenderError
Syntax ImageViewer.setOnRenderError(callback:function);
callback:function
Parameter
The function executed in case of Decoding or Rendering error
Return Value None
This event takes place when an error occurs while decoding and rendering after
buffering and when trying playing a format not basically supported.
Remarks
(Image files except for JPEG)
(Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
ImageViewer.setOnRenderError(function(){
Example
// blah blah
});
Enumeration None
72
Application Development Guide for Internet@TV
5.6.7.16. setOnRenderingComplete ()
setOnRenderingComplete
Syntax ImageViewer.setOnRenderingComplete(callback:function);
callback:function
Parameter
The function executed in the event of Rendering complete event
Return Value None
This event occurs when the image displays completely on the screen. If Transition
Remarks effect is used, the event occurs at the point when Effect animation is ended.
(Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
ImageViewer.setOnRenderingComplete(function(){
Example
// blah blah
});
Enumeration None
5.6.7.17. show()
Show
Syntax ImageViewer.show();
Parameter None
Return Value None
Remarks (Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
ImageViewer.show();
5.6.7.18. showNow ()
showNow
73
Application Development Guide for Internet@TV
Transition effect is begun to play. Loading the image should be ended via prepareNext().
Syntax ImageViewer.showNow();
Parameter None
Return Value None
Transition effect is not provided in several models owing to hardware restrictions.
Refer to isEffectAvailable().
Remarks Calling prepareNext() starts to load a image. Effect animation is shown by calling
showNow() after Buffering complete event.
(Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
ImageViewer.setFrameArea(0,0,960,540);
ImageViewer.startSlideshow();
ImageViewer.play(firstImage, 300, 400);
// after Rendering complete event
ImageViewer.prepareNext(NextImage, ImageViewer.Effect.FADE1);
Example
// after Buffering complete event
ImageViewer.shwoNow();
…
// after finishing slideshow
ImageViewer.endSlideshow();
Enumeration None
5.6.7.19. startSlideshow ()
startSlideshow
Syntax ImageViewer.startSlideshow()
Parameter None
Return Value None
If you want to close slideshow mode, call endSlideshow().
Remarks Methods such as prepareNext() and showNow() are available only in slideshow mode.
(Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
Example ImageViewer.startSlideshow();
… // Use transition effect
74
Application Development Guide for Internet@TV
ImageViewer.endSlideshow();
Enumeration None
5.6.7.20. stop ()
stop
Syntax ImageViewer.stop();
Parameter None
Return Value None
This does not get rid of playing images on screen. It stops image processing such as
image loading and Transition effect animation. If you want to remove playing images
Remarks
from the screen, refer to clearScreen().
(Since Application Manager 2.269)
var ImageViewer = new CImageViewer('Common ImageViewer');
ImageViewer.setFrameArea(50,50,480,320);
Example
ImageViewer.play(image_url, image_width, image_height);
ImageViewer.stop();
Enumeration None
75
Application Development Guide for Internet@TV
This section describes several pieces of information that are useful for application developers.
<body onload="Main.onLoad();">
You should note that an element that is supposed to respond to the „keydown‟ event should be receiving
focus. If there‟s no element receiving focus, there will be no relation on the TV screen even though you
press a remote control button.
All the remote control keys have been defined by member variables of the tvKeyValue object.
76
Application Development Guide for Internet@TV
Look at the example below. Insert an element that will have focus in index.html.
switch (keyCode) {
case tvKey.KEY_LEFT:
/**
* Code for Left key event!
*/
break;
case tvKey.KEY_RIGHT:
break;
case tvKey.KEY_UP:
break;
case tvKey.KEY_DOWN:
break;
case tvKey.KEY_ENTER:
break;
case tvKey.KEY_RETURN:
break;
}
}
Application Manager registers key sets as stated below in order for the application to use keys. When tag
value of <fullwidget> in config.xml is „y‟ and the Full-screen Application keyset is „n‟, Single-wide
Application is registered.
77
Application Development Guide for Internet@TV
The keys registered/unregistered after window.onshow event are normally processed, but those before
window.onshow event could be ignored. Register a function executed in window.onshow prior to calling
this method because window.onshow event happens after calling sendReadyEvent() of common module,
„Widget‟. Below is an example.
Main.onLoad = function(){
window.onshow = function(){ // register function will be run onshow event
PLUGIN.registKey(TVKEY.KEY_VOL_UP);
PLUGIN.registKey(TVKEY.KEY_VOL_DOWN);
78
Application Development Guide for Internet@TV
WIDGET.sendReadyEvent();
/**
* code
*/
}
The time of key registration/unregistration after window.onshow event does not matter.
?country=US&language=1&modelid=Valencia&server=development&remocon=2_35_259&area=USA&product
=1&mgrver=3.000&[email protected]&pw=pxxxx&payload={key1:value2,key2:value2}
79
Application Development Guide for Internet@TV
body {
margin: 0;
padding: 0;
background-color: transparent;
}
80
Application Development Guide for Internet@TV
them. By doing this, you can save the time for image decoding.
By doing the above work, you can make the Maple browser decode images. For images that have been
decoded once by the browser, they don‟t have to be decoded again later when they are used elsewhere,
so that your TV can display them faster.
81
Application Development Guide for Internet@TV
*{
letter-spacing: 0px;
}
If you create and use XHR objects repeatedly in Samsung TVs, you will be faced with a problem of your
applications working in a wrong way. The solution to this problem is set forth in Ch. 4.5 Example for XHR
communication.
If the content in the tag is replaced with the innerHTML property, the corresponding node in the DOM tree
is closed and a new one is created and connected. The closed node remains in the memory. If this
procedure occurs repeatedly, you could face memory full. The solution to this problem is to use the
putInnerHTML() method of the Widget object in the common module. For more information on this
method, refer to Ch. Common modules.
In application, Network related operation and big data parsing(ex. Stock ) take more than 20 sec, and this
82
Application Development Guide for Internet@TV
will let the Watch dog be forced to close. It is recommended that you turn off Watch dog prior to these
actions. After the actions have been completed, turn on the watch dog again. If you keep Watch dog off,
TV might stop working.
You can save javascript loading time by minimizing javascript in the initial page. On-Demand Javascript
Loading is that Download Javascript when it required, instead of downloading it all in the initial page.
Divide a big javascript file into several javascript file. And then only some Javascript files needed to
generate the initial page amog others. Therefore you can include javascript files minimally in the initial
page. And you can load other javascript files by inserting script element as following.
Main.onLoad = function(){
83
Application Development Guide for Internet@TV
Maple Browser loads an image for an element‟s background style when its background style matching is
invoked. Because deleting background style of some elements not nessasary in initial page can speed the
application loading up. You can apply element‟s background style when it required as follows.
If you using setTimeout function properly, a background of initial page can be shown more quikly. Separate
Main.onLoad function into two steps. The first step is to generate background of initial page. The second
step is to do other works not necessary to generate the background of initial page. Following shows this
technique.
Main.onLoad = function(){
84
Application Development Guide for Internet@TV
…generate background
var Main = {
}
var WIDGET = new Common.API.Widget(); // For sendReadyEvent()
Main.onLoad = function() { // The first function
alert("Main : onLoad()");
WIDGET.sendReadyEvent();
includeCSS ('red_box.css');
setTimeout("insertHTML()", 3000);
// insertHTML();
// setTimeout("includeCSS ('red_box.css')", 3000);
}
function includeCSS(path) {
85
Application Development Guide for Internet@TV
* red_box.css
#red_box {
position : absolute;
left: 100px;
top: 100px;
width: 100px;
height: 100px;
insertHTML();
setTimeout("includeCSS ('red_box.css')", 3000);
86
Application Development Guide for Internet@TV
7. Maple browser
This section sets forth the browser for running applications provided with Samsung Internet@TV, Maple.
7.1. Maple?
Stands for Markup engine Platform for Embedded Systems
Browser engine for Consumer Electronics (CE) devices
Controls devices using markup tags and script classes
When an application is displayed and behaves on the screen, its image and text generation should be
controlled and managed. For Samsung TVs with Internet@TV installed, it is Maple that performs such work.
An application‟s behaviors and displays are made by Maple. While Internet Explorer and Firefox are PC-
based browsers, Maple is Samsung TV-based browser.
87
Application Development Guide for Internet@TV
8. File API
This section introduces the file input/output operation system which the Samsung TV application engine
supports.
File input/output operations are performed by creating a file system object and calling the interface of
the object.
8.2. API
The following is a list of interfaces that are provided by the Samsung TV application engine. You can use
them in JavaScript.
8.2.1. FileSystem()
FileSystem
88
Application Development Guide for Internet@TV
openCommonFile
closeCommonFile
deleteCommonFile
createCommonDir
deleteCommonDir
isValidCommonPath
Methods
readLine
writeLine
readlAll
writeAll
readDir
openFile
8.2.2. openCommonFile()
openCommonFile
89
Application Development Guide for Internet@TV
With this method, all the applications operate to input and output files in the same
area. Due to this feature, the case that files used in other applications have the same
Remarks
name happens. It is required to create directories using application ID via
curWidget.id and execute file operations in the directory.
var fileSystemObj = new FileSystem();
var fileObj = fileSystemObj.openCommonFile(curWidget.id + '/testFile.data', 'w');
Example
fileObj.writeAll('something to write.');
fileSystemObj.closeCommonFile(fileObj);
Enumeration None
8.2.3. closeCommonFile()
closeCommonFile
8.2.4. deleteCommonFile()
deleteCommonFile
Syntax fileSystemObj.deleteCommonFile(filePath:String)
filePath:String
Parameter
path including the name of a file to delete
90
Application Development Guide for Internet@TV
8.2.5. createCommonDir()
createCommonDir
Syntax fileSystemObj.createCommonDir(directoryPath:String)
directoryPath:String
Parameter
path including the name of a directory to create
Return Value Boolean
Creating a directory named curWidget.id to avoid crash between file names in other
Remarks
applications.
var fileSystemObj = new FileSystem();
Example
var bResult = fileSystemObj.createCommonDir(curWidget.id);
Enumeration None
8.2.6. deleteCommonDir()
deleteCommonDir
Syntax fileSystemObj.deleteCommonDir(directoryPath:String)
directoryPath:String
Parameter
path including a name of directory to delete
Return Value Boolean
Remarks None
var fileSystemObj = new FileSystem();
Example
var bResult = fileSystemObj.deleteCommonDir(curWidget.id);
Enumeration None
91
Application Development Guide for Internet@TV
8.2.7. isValidCommonPath()
isValidCommonPath
Syntax fileSystemObj.isValidCommonPath(directoryPath:String)
directoryPath:String
Parameter
path including a name of directory to confirm its existence
Int
0 : JS function failed
Return Value
1 : valid
2 : invalid
Remarks None
var fileSystemObj = new FileSystem();
var bValid = fileSystemObj.isValidCommonPath(curWidget.id);
Example if (!bValid) {
fileSystemObj.createCommonDir(curWidget.id);
}
Enumeration None
8.2.8. readLine()
readLine
Syntax fileObj.readLine()
Parameter None
String
Return Value Returns a line ranging to line feed character as a result. If there is nothing to read,
return „null‟.
Remarks None
var fileSystemObj = new FileSystem();
var fileObj = fileSystemObj.openCommonFile(curWidget.id + '/testFile.data', 'r');
Example
var strLine = '';
var arrResult = new Array();
92
Application Development Guide for Internet@TV
while((strLine=fileObj.readLine())) {
arrResult.push(strLine);
}
Enumeration None
8.2.9. writeLine()
writeLine
Syntax fileObj.writeLine(text:String)
text:String
Parameter
text to write in a file
Return Value Boolean
Remarks None
var fileSystemObj = new FileSystem();
var fileObj = fileSystemObj.openCommonFile(curWidget.id + '/testFile.data', 'w');
Example
fileObj.writeLine('something to write.');
fileSystemObj.closeCommonFile(fileObj);
Enumeration None
8.2.10. readlAll()
readAll
Syntax fileObj.readAll()
Parameter None
String
Return Value
Whole contents of the file
Remarks None
var fileSystemObj = new FileSystem();
var fileObj = fileSystemObj.openCommonFile(curWidget.id + '/testFile.data', 'r');
Example
var strResult = fileObj.readAll();
alert(strResult);
93
Application Development Guide for Internet@TV
Enumeration None
8.2.11. writeAll()
writeAll
Syntax fileObj.writeAll(text:String)
text:String
Parameter
test to write in a file
Return Value Boolean
Remarks None
var fileSystemObj = new FileSystem();
var fileObj = fileSystemObj.openCommonFile(curWidget.id + '/testFile.data', 'w');
Example
fileObj.writeAll('something to write.');
fileSystemObj.closeCommonFile(fileObj);
Enumeration None
8.2.12. readDir()
readDir
Syntax fileSystemObj.readDir(directoryPath:String)
directoryPath:String
Parameter
Path of a directory that you want to see. Wors only for USB directory
Array
The Array containing file information. Each element has file information in a
directory. Able to get information by referring to variables below.
name : file name
Return Value isDir : If a file is a directory, „true‟, if not, „false‟
size : File Size (byte)
atime : The time when to open a file or access time to a directory with cd command
mtime : The time when file contents are changed
ctime : The time when file information is changed
94
Application Development Guide for Internet@TV
8.2.13. openFile()
openFile
95
Application Development Guide for Internet@TV
Enumeration None
96
Application Development Guide for Internet@TV
9. Appendix
97
Application Development Guide for Internet@TV
98
Application Development Guide for Internet@TV
The table stated below shows the codes delivered from „language‟ attribute. „language‟ attribute is
replaced with „lang‟. „language‟ attribute is planned to be erased. Do not use it further.
Code Region
KOR Korea
99
Application Development Guide for Internet@TV
USA USA/Canada/Mexico
BRA Brazil, Paraguay, Uruguay, Argentine
PANEURO Europe
CHI China
HKG Hong Kong
ARB Arab
PANNORDIG Nordic
SOUTHEASTASIA South-East Asia (Vietnam, Thailand, India, China, Iran, Israel, Central Asia,
East Asia, Africa)
ASIA_ATV South-East Asia (Vietnam, Thailand, India, China, Iran, Israel, Central Asia,
East Asia, Africa)
ASIA_DTV Australia , New Zealand, Singapore
TW Taiwan, Columbia
NORTHAFRICA TURKEY, MOROCCO, TUNISIA
EA_DTV Indonesia, Malaysia, Republic of South Africa, Vietnam
CIS CIS
PHI Philippine
S_AFR_DTV South Africa DTV
Code Region
0 TV
1 Monitor
2 Blue-ray Disk
100