Samsung Electronics logo

Access TV Information

While creating applications, you may need to access TV-specific information. Using the TV Info API capabilities, Samsung Web APIs allow you to access TV information, such as model name, firmware version, broadcasting time, and so on.

Using the TV information API capabilities, your applications can:


Prerequisites

The TV Info API provides the system information for TV-associated devices. When the application is launched, an info object is instantiated automatically in the webapis object. The webapis.tv.info object is an instance of the TVInfoManager interface, which retrieves information about DTV properties.

Adding the webapis JavaScript file in your application is required to invoke this API properly. Please refer to the script code below to add the webapis file:

 
<html><head>
    <!-- including the JavaScript file which supports Samsung Web API -->
    <script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/webapi/1.0/webapis.js"></script>
</head></html>

Obtain TV Device Information

You can use the Samsung Web APIs to access the status of various device information, such as name, firmware version, and broadcasting time.

The Info API provides the TVInfoManager interface, which enables you to obtain information about DTV properties.

Determine product type

An application must determine the type of device on which it is running. For this purpose, use the getProduct method to get the product.

This method returns the current product type (TV or BD or Monitor) on success.

The valid values for product type are:

  • TV
  • BD
  • MONITOR
 
var product = webapis.tv.info.getProduct();

switch (product) {
     case webapis.tv.info.PRODUCT_TYPE_TV : 
         alert("product is a TV");
         break;
         
     case webapis.tv.info.PRODUCT_TYPE_BD : 
         alert("product is a blue-ray player");
         break;
         
     case webapis.tv.info.PRODUCT_TYPE_MONITOR : 
         alert("product is a monitor");
         break;
 }

Determine model name

An application must determine the model name of the device on which it is running. For this purpose, use the getModel method to get the model.

This method returns the model name of the product.

 
alert("model name is " + webapis.tv.info.getModel());

Determine firmware version

An application must determine the firmware version of the device on which it is running. For this purpose, use the getVersion method to get the firmware number.

This method returns the current firmware version.

 
alert("firmware version is " + webapis.tv.info.getFirmware());

Determine SMART HUB version

An application must determine the smart hub of the device on which it is running. For this purpose, use the getModel method to get the version.

This method returns the model name of the product.

 
alert("Smart Hub version is " + webapis.tv.info.getVersion());

Determine country code

If an application is dependent on the country code of the country where the device is being used in order to expose related application functionality, use the getCountry method to get the country code.

This function returns the country code for where the device is located.

 
alert("country code is " + webapis.tv.info.getCountry());

Determine language code

If an application must determine the language interface the device is displaying so that a related application language is enabled, use the getLanguage method to get the language code.

This function returns the language code in which the User Interface is displayed.

 
alert("current language is " + webapis.tv.info.getLanguage());

Determine unique device identification

The device ID should be unique across all devices for a given product. It is useful for unique device identification.

An application must determine the unique device identification of the device in which application is running. For this purpose, you must use the getDeviceID method to get the deviceID.

This function returns the unique device ID value.

 
alert("Device ID is " + webapis.tv.info.getDeviceID());

Determine tick count

If an application must determine the tick count of the device, it must invoke the getTick method.

This function returns the current tick count.

 
alert("current tick time is " + webapis.tv.info.getTick());

Determine epoch time

If an application must determine the number of seconds that have elapsed since midnight (UTC), January 1, 1970, for the device, it must invoke the getEpochTime method.

 This function returns the current epoch time.

 
alert("current epoch time is " + webapis.tv.info.getEpochTime());

Convert current date time of the device

If an application must convert the current epoch time to Date format current time, invoke the convertEpochToTime method.

This function converts the epoch time given in the parameter to local time and returns it in the form of a Date object.

 
var epochTime = webapis.tv.info.getEpochTime();
var date = webapis.tv.info.covertEpochToTIme(epochTime);

alert(date.toUTC());

Convert epoch time from current time

If an application must convert the current time into epoch time, invoke the convertTimeToEpoch method. This method takes the Date object as an input parameter.

The function converts the Date Object in the parameter into epoch time.

 
var time = new Date();
var epochTime = deviceapis.tv.info.covertTimeToEpoch(time);

alert("EpochTime : " + epochTime);

Determine time zone information

If an application must determine the time zone information of the device at its location, use the getTimeZone method to get the timeZone value.

 This function returns the time zone information.

 
var timeZoneObj = webapis.tv.info.getTimeZone();

switch (timeZoneObj.timezone) {
     case webapis.tv.info.TIMEZONE_USA_ATLANTIC: 
     
         alert("current time zone is atlantic, USA.");
         break;
     
     case webapis.tv.info.TIMEZONE_KOR_SEOUL: 
     
         alert("current time zone is seoul, Korea.");
         break;
 }

Obtain Detailed Information on Time Zone Properties

The tvinfo APIs enable you to determine the detailed information of the time zone properties supported by the device.
It is important to understand the time zone information of the device for applications that deal with real time values and for informational reasons.

The Info API provides the TimeZone interface, which enables you to obtain information about time zone properties. Neither of these attributes can be modified.

[NoInterfaceObject] interface TimeZone
{
    readonly attribute unsigned short timezone;  

    readonly attribute long offset;

    readonly attribute unsigned short dst;
};

Below is sample code for working with TimeZone:

var timeZoneObj = webapis.tv.info.getTimeZone();

switch (timeZoneObj.timezone) {

     case webapis.tv.info.TIMEZONE_USA_ATLANTIC : 
         alert("current time zone is atlantic, USA.");
         break;
     
     case webapis.tv.info.TIMEZONE_KOR_SEOUL : 
         alert("current time zone is seoul, Korea.");
         break;
 }

 alert("time zone offset is " + timeZoneObj.offset);

 switch (timeZoneObj.dst) {
 
     case webapis.tv.info.TIMEZONE_DST_ON : 
         alert("current daylight saving time is on.");
         break;
     
     case webapis.tv.info.TIMEZONE_DST_OFF : 
         alert("current daylight saving time is off.");
         break;
     
     case webapis.tv.info.TIMEZONE_DST_AUTO : 
         alert("current daylight saving time is auto.");
         break;
 }