top

Preview API

To use Samsung Product API, 

<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>

Should be loaded in index.html

The module defines the functionalities of Preview that are provides as the Samsung TV for Tizen Platform Product API.

Since : 1.0

Table of Contents

  1. 1. Interfaces
    1. 1.1. PreviewManagerObject
    2. 1.2. PreviewManager
  2. 2. Full WebIDL

Summary of Interfaces and Methods

Interface Method
PreviewManagerObject  
PreviewManager

void setPreviewData (DOMString previewData_JSON, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback)
DOMString getVersion ()

1. Interfaces

1.1. PreviewManagerObject

The interface defines what is instantiated by the WebApi object of Tizen-based Samsung TV Product API.
There will be a webapis.preview object that allows access to the functionality of the Preview API

  [NoInterfaceObject]interface PreviewManagerObject {
      readonly attribute PreviewManager preview;
  };

  WebApi implements PreviewManagerObject;

Since : 1.0

Attributes

  • readonly PreviewManager preview
    Namespace for Preview API.

    Since : 1.0

1.2. PreviewManager

This interface provides methods to use the Preview functionalities.

[NoInterfaceObject] interface PreviewManager {   
    void setPreviewData(DOMString previewData_JSON, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
    DOMString getVersion();
};

Since : 1.0

Methods

getVersion
This method is get Preview version

  DOMString getVersion();

Since : 1.0

Return value:

DOMString

Exceptions:

  • WebAPIException
    • with error type UnknownError in any other error case.

Code example:


try {
   var result = webapis.preview.getVersion();
   console.log(result);
} catch(ex) {
   console.log(ex.message);
}
setPreviewData

This method is set preview data, Only a single Preview is allowed per application. Each Preview contains a list of one or more Sections. Each Section contains one or more Tiles

Pre-condition
- using <metadata> tag in config.xml
ex) <tizen:metadata key="http://samsung.com/metadata/use.accelerator" value="bg_service"/>


  void setPreviewData(DOMString previewData_JSON, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);

Since : 1.0

Parameters:

  • previewData_JSON: DOMString
    Preview properties
      - sections [Array][mandatory]
        ** sections array has object properties which is title / tiles / position.
        - title[string][optional] Title to be displayed at the top of the section. E.g., “Popular Now”
        - position[number][optional] Position of the Section within the Accelerator. Sections will be ordered by position, ascending.
        - tiles[Array][mandatory] The list of Tiles in this Section
         ** tiles array has object properties. Refer below,
         - title[string][optional] Title to be displayed over a highlighted Tile. Typically this would be the show name. E.g. “Seinfeld”.
         - subtitle[string][optional] Subtitle to be displayed below the title.
         - image_url[string][mandatory] Link to the Tile image. Supported Formats: PNG, JPG
         - image_ratio[string][mandatory] The image aspect ratio as one of the following strings: “16by9”, “4by3”, “1by1” or “2by3”. Default value is “1by1”.
    Applications not using any of those aspect ratios may specify the display width in pixels instead (Height is fixed at 250px). For example, applications using 1.42 aspect ratio can specify “355”. Samsung recommends one of the standard aspect ratios for best performance. Minimum width is 167px.
    Maximum width is 444px.
         - action_data[string][mandatory] Data to be passed to the application when it is launched from this tile
        - is_playable[boolean][mandatory] Whether selecting the Tile will start playback of content. When set to true, a Play button will be rendered over the image.
         - display_from[Timestamp][optional] If set, Tile will only be presented to the user from the specified time.
         - display_until[Timestamp][optional] If set, Tile will only be presented until the specified time.
         - position[number][optional] Tiles will be ordered by position, ascending.
  • successCallback [optional]: SuccessCallback
  • errorCallback [optional]: ErrorCallback

Exceptions:

  • WebAPIException
    • with error type InvalidValuesError, if any of the input parameters contain an invalid value.

    • with error type UnknownError in any other error case.

Code example:


var previewData = {
    "sections": [{
        "title": "Popular Now",
        "tiles": [{
            "title": "Parks and Recreation",
            "subtitle": "Pawnee Pony",
            "display_from": 1422766800, 
            "display_until": 1441937400,
            "image_url": "http://yourserver.com/image.jpg",
            "action_url": "myapp://playVideo?videoId=185595-0324",
            "is_playable": true
        }]
   }]
}

function successCallback() {
    console.log("success");
}

function errorCallback(error) {
    console.log(error.message);
}
 
try {
    webapis.preview.setPreviewData(JSON.stringify(previewData), successCallback, errorCallback);
} catch(ex) {
    console.log(ex.message);
}

3. Full WebIDL


module Preview {
    [NoInterfaceObject] interface PreviewManagerObject {
        readonly attribute PreviewManager preview;
    };    

    WebApi implements PreviewManagerObject;

    [NoInterfaceObject] interface PreviewManager {   
        void setPreviewData(DOMString previewData_JSON, optional SuccessCallback? successCallback, optional ErrorCallback? errorCallback);
        DOMString getVersion();
     };
};