This topic describes how to implement a public preview for the Smart Hub Preview feature. A public preview shows the same preview content to all users.
Public preview content is defined by a remotely-hosted JSON file. You can configure the JSON file to expire and refresh at a specific time. The public preview generation process is shown in the following figure.
To enable your application to use the public preview functionality:
Define the remote JSON file URL in the "config.xml" file:
<tizen:metadata key='http://samsung.com/tv/metadata/use.preview' value='endpoint_URL=http://yourServer/JSONfile.json'></tizen:metadata>
Disable reloading the application main page when it receives an application control request. This allows your application, if it is already running, to receive the "action_data" information without reloading.
<tizen:app-control> <tizen:src name='index.html' reload='disable'></tizen:src> <tizen:operation name='http://samsung.com/appcontrol/operation/eden_resume'></tizen:operation> </tizen:app-control>
If you want the application to support 2015 TV models, set the required_version attribute to "2.3" and the development API version meta data attribute to "2.4" in the "config.xml" file:
required_version
<tizen:application ... required_version='2.3'></tizen:application> <tizen:metadata key='http://samsung.com/tv/metadata/devel.api.version' value='2.4'></tizen:metadata>
The preview content is defined in JSON format. The application can only use 1 preview content JSON file at a time.
The following table lists the structure and parameters for the preview content JSON data.
Table 1. Preview JSON parameters
For an example of a preview content JSON file, see sampleJSON. The JSON parameters “title_display_mode” and “subtitle_display_mode” for displaying title and subtitle of tiles, respectively, support the following options:
Voice Guide (Text-to-Speech feature) is supported by all the three options detailed above, if the accessibility setting for Voice Guide is turned on by the user. Please note that this behavior is an accessibility feature to assist users, and it should comply with the policies of the countries the application is released in. If only the preview tile image is to be shown to user, and the title and subtitle are required to be hidden, add the title and subtitle values to the JSON file, and set the "AccessibilityOnly" value for both properties. This ensures that the title and subtitle will not be visible to user, but are read out loud when the tile is in focus.
When the preview system requests JSON data from your server, TV information is sent in the HTTP header. You can serve different preview content depending on TV information, such as the language, and application version.
The following table lists the HTTP header fields that contain TV information.
Table 2. HTTP header fields
When a tile is clicked, its associated "action_data" value is converted to an ApplicationControlData object with the "PAYLOAD" key:
ApplicationControlData
{ "key": "PAYLOAD", "value": ["{\"values\": \"{\\\"videoIdx\\\": 1}\"}"] }
For more information on ApplicationControlData objects, see the Application API.
To implement deep-linking:
To receive "action_data" information when the application is already running, add an event listener for the appcontrol event to the onload property:
appcontrol
onload
window.addEventListener('appcontrol', deepLink);
In the onload property, receive and parse the "PAYLOAD" key value, using the getCurrentApplication().getRequestedAppControl() method:
getCurrentApplication().getRequestedAppControl()
function deepLink() { var requestedAppControl = tizen.application.getCurrentApplication().getRequestedAppControl(); var appControlData; var actionData; var videoIdx; var pictureIdx; if (requestedAppControl) { appControlData = requestedAppControl.appControl.data; for (var i = 0; i < appControlData.length; i++) { if (appControlData[i].key == 'PAYLOAD') { actionData = JSON.parse(appControlData[i].value[0]).values; if (JSON.parse(actionData).videoIdx) { videoIdx = JSON.parse(actionData).videoIdx; console.log(videoIdx); } else if (JSON.parse(actionData).pictureIdx) { pictureIdx = JSON.parse(actionData).pictureIdx; console.log(pictureIdx); } } } } else { console.log("no req app control"); } }