Introduction to TOAST (Part 4): Using TOAST for Smart TV

540

Precondition

Now that we know how our TOAST plug-in works, we can see how to implement in our Smart TV development environment.

Before using TOAST, we need to make sure we have installed:

  • Node.JS
  • Git
  • Chrome Browser
  • Samsung Tizen SDK
  • And npm modules cordova and grunt
$ npm install -g cordova
$ npm install -g grunt-cli

 

Getting started

Git clone

So to establish the environment for TOAST in Cordova, we need to generate a git clone in the root directory with all of these repositories:

$ git clone https://github.com/apache/cordova-js.git
$ git clone https://github.com/apache/cordova-browser.git
$ git clone https://github.com/Samsung/cordova-plugin-toast.git
$ git clone https://github.com/Samsung/cordova-sectv-orsay.git
$ git clone https://github.com/Samsung/cordova-sectv-tizen.git
$ git clone https://github.com/Samsung/cordova-tv-webos.git
$ git clone https://github.com/Samsung/grunt-cordova-sectv.git

 

Install

You will need to npm install dependency modules in cordova-jscordova-plugin-toastcordova-sectv-orsaycordova-sectv-tizengrunt-cordova-sectv

In cordova-js/Gruntfile.js, please add compile tasks.

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        compile: {
     ...
      "sectv-orsay": {},
      "sectv-tizen": {},
      "tv-webos": {}
 },

 

Configuration

Also, don’t forget to add these two to the list for cordova platforms in the package.json file under the cordova-js folder.

 "cordova-platforms" : {
  ...
     "cordova-sectv-orsay" : "../cordova-sectv-orsay",
     "cordova-sectv-tizen" : "../cordova-sectv-tizen“,
     “cordova-tv-webos”    : “../cordova-tv-webos”
 }

 

Compile

And just before we can start, we just need to compile for packaging in the cordova-js and cordova-plug-in folders.

In cordova-js, please grunt compile for packaging.

$ grunt compile:sectv-orsay compile:sectv-tizen compile:tv-webos

 

In cordova-plugin-toast, please grunt compile for packaging.

$ grunt compile:sectv-orsay compile:sectv-tizen compile:tv-webos

 

Creating a empty project

Now we can create our first empty project with the following lines of code:

Create cordova project:

$ cordova create TestApp
$ cd TestApp

 

Beware of the hidden file:

$ cp -rf ../grunt-cordova-sectv/sample/. ./
$ npm install ../grunt-cordova-sectv
# Grunt task for build and package

Install dependency modules

$ npm install

 

For TOAST browser simulator

$ cordova platform add browser

 

Mandatory plugins for using the browser simulator

$ cordova plugin add cordova-plugin-device
$ cordova plugin add cordova-plugin-network-information
$ cordova plugin add cordova-plugin-globalization

Add TOAST plugin

$ cordova plugin add ../cordova-plugin-toast

Let’s prepare the project

$ cordova build browser
$ grunt sectv-prepare:sectv-orsay
$ grunt sectv-prepare:sectv-tizen
$ grunt sectv-prepare:tv-webos

 

Now, build the project for testing

$ cordova emulate browser
$ grunt sectv-build:sectv-orsay
$ grunt sectv-build:sectv-tizen
$ grunt sectv-build:tv-webos

 

Conclusion

As you can see, using the TOAST plug-in in our development environment is very easy and can help us a lot.

TOAST was developed as an open source project for the following strategic reasons:

  • Easy access to the project for all developers.
  • Contribution of external developers to help the project grow.
  • And with the source code in our hands we can expand the project to support other TV platforms.

As for the technical reasons:

  • We can have prompt update.release
  • And make use of public technologies, like Cordova.
    So we are open and ready to make the Smart TV community grow.

You can start getting to know this project with the TOAST wiki hosted in github where all the information on how to install and start using TOAST is available with full details.

Also there is a complete documentation for all the libraries used in the TOAST project as well as the API reference.

https://github.com/Samsung/cordova-sectv-tizen
https://github.com/Samsung/cordova-sectv-orsay
https://github.com/Samsung/cordova-tv-webos
https://github.com/Samsung/grunt-cordova-sectv

And don’t forget that TOAST is an open project is hosted in Github, so any developer can join and contribute to the effort of making Smart TV development easier and available for everyone.

Also there is the TOAST portal as a main feature in the home of our Samsung D Forum where you can find all the latest news about this interesting open source project.

That’s all for my part, everyone! Hope you enjoyed this brief tutorial, and happy TOAST!

NO COMMENTS

LEAVE A REPLY

nineteen − 16 =