ImportantDue to NaCl deprecation by the Chromium project, Tizen TV will continue its support for NaCl only until 2021-year products. Meanwhile, Tizen TV will start focusing on high-performance, cross-browser WebAssembly from 2020-year products.
This topic describes how to embed an existing Native Client module in a Smart TV application.
The Native Client (NaCl) technology and the Tizen Studio allow you to embed an existing NaCl module in your application. A previously-compiled Native Client module can be needed in a project for various reasons, for example due to security requirements, when the module's source code is already compiled and cannot be modified.
Prerequisites
To embed an existing NaCl module, you need the following files:
Compiled NaCl modules (".nexe" files) for the desired architectures
Manifest file pointing to the ".nexe" files
You also need information on the module's functionality and API.
Embedding a Module
To embed a module, you must implement the following parts in the JavaScript/HTML5 component of the application:
HTML embed element on the Web page
JavaScript listeners for handling load, crash, and message events
Path to the manifest file
The following steps use the Hello World in C++ tutorial module. When the module is successfully loaded, it waits for incoming messages and, when it receives one, sends back the text "Echo from NaCl:" along with the original message text.
In the Tizen Studio, create an empty NaCl project.
Build the project to create the makefile definitions needed to package the application.
When implementing an existing NaCl module, the source files and build result from the empty project are not needed. Delete the built ".nexe", ".pexe", and ".nmf" files from the "CurrentBin" folder, and the existing C++ source files from the "src" folder.
NoteYou must build the project once before removing the empty project source files. The files are needed by the builder to generate the correct building targets and folders.
Copy the ".nexe" file you want to implement to the project's "CurrentBin" folder.
In the "CurrentBin" folder, create a ".nmf" manifest file pointing to the module location.
NoteThe manifest file name must be the same as the project name.
Implement communication with the NaCl module in the "project.js" file.
In the exampleSpecificActionAfterNaclLoad() method, send a message to the module using the postMessage() method:
document.getElementById("nacl_module").postMessage("Hello World from JS");
To see the message returned by the module, unlock the logs area:
var uses_logging = true;
To print the received message in the logs area and scroll the log, in the "communication.js" file, at the end of the handleNaClMessage() method, add the following code:
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
.samsungdeveloperconference.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.