Samsung Smart TV Development With HaXe

haxesamsung

You have propably already heard about smart TVs can run applications. However, the app market is very fragmented, some vendors support AIR apps or Flash Player but the runtime versions are just too old, so HTML apps seems to be a better solution these days. Decision has been made and my next project is going to be HTML/JavaScript based Samsung smart TV app and I need to prepare comfort environment to work in (click and run just like Flash Builder does). I have doubts that language like JavaScript by its nature can be easily used on enterprise projects, where multiple team members cooperate and it seems like numbers of apps already struggled to see a daylight. Luckily, there are languages like HaXe, that compiles into clean JavaScript while still offering advanced features like strong typing. In this article, I would like to share my initial steps and successes with Samsung project on HaXe.

Samsung SDK

First steps led me to download and install Samsung SDK. I was prompted to install DirectX End-User Runtime (search on google) during the SDK installation. Both installs went smooth. At the end I was requested to install apache server but I already had one http service installed so I skipped. Local server is necessary just in order to install the app into TV device. Samsung SDK contains TV emulator and an Eclipse with some custom plugins allowing you to run and debug TV app on emulator or package the app for release to a device. The catch with emulator is, the real TV device works a bit different than emulator and some sdk APIs would just not work.

Samsung does a good job with docummentation, you just have to get used with the navigation. E.g. as of today they list 263 guide documents (Resource / API reference / SEF Plugin API / Player) and tutorials usualy with examples (Resource / Tutorial). Also a lot of APIs is being discussed on forum.

What I was interested was, what APIs my dev device (UE55D7000) supports. Here is a nice platform features table, but in order to find out what type (year) my device was I had to deserialize the model info:

Device model usually like this ==> UA 55 ES 8000
– ‘U’ more likely device type (LED/LCD/Plasma) Plasma use ‘P’
– ‘A’ more likely the region of device, mine is ‘A’ (Asia i think) and some in Europe and USA use ‘E’
– 55 is the TV Inch, in BD player you won’t see this code above, only E5900 for example
– ‘E’ is the device release year, E = 2012, D = 2011, C = 2010, and latest F = 2013
– ‘S’ is just the flag to show this is Slim model
– 8000 is the device series and if in the market, Series 8 means the leading number there ‘8’000, ES7500 is Series 7

According to this, my device should be able to play PlayReady protected media (no smooth streaming though), but after spending 3 days failing to play any video with PlayReady DRM, even those examples on forum or creating it according to official tutorial, I started to think the device is just not capable. If you have any idea why I am failing, please let me know.

Working with Eclipse is pretty much smooth:

  1. create samsung project from top menu Samsung: Smart TV SDK / Create …
  2. select project folder in package explorer and click run or debug app on emulator icons …
  3. once you want to test your app on a real device, you have to follow some cofig steps, then click package icon, and install the app on the TV.

HaXe

I have already used HaXe some time ago, so I was able to catch faster with this. Also installing it is pretty smooth, just downloaded HaXe 3.0 RC and followed the instructions. Previously I used HaXe with FlashDevelop, where it has better support. But now I was interested to integrate it with Samsung Eclipse using eclihx (HaXe plugin). Its not perfect and seems to be a bit outdated, however it still seems to work for some code completion and compilation.

Merging

So I was able to create Samsung Smart TV project with fancy run, debug, package buttons or HaXe project with compile button, but I wanted both at the same time! No problem for eclipse. My plan was to stick with HaXe / eclihx project (so I have autocompletion) while creating some external build configuration for running, debugging and packaging the project for emulator and device. As the Samsung Eclipse seems to be a port of some basic Eclipse and misses Ant I needed for some automation, I had to install it first:

  1. click Help / Install New Software
  2. chose work with “Indigo – http://download.eclipse.org/releases/indigo”
  3. expand “Web, XML, Java EE…” option
  4. select “Eclipse Java EE Developer Tools”
  5. and finish the install process
  6. Ant is now installed in eclipse

I have created a Sample eclihx project while switched back to “Samsung Smart TV Perspective” as this one contains “run” button I need for my one-click operations.

runbutton

In order to compile HaXe with ant, I have installed AntHX using command line:

haxelib install anthx

I have created a build.xml file that would compile the HaXe sources, using AntHX taskdef. Then created external build:

  1. clicked Run / External Tools / External Tools Configuration
  2. created new Ant Build
  3. added AntHX.jar into classpath

anthxclasspath

Thing I was still missing was the ability to run Samsung emulator with my app from ant. Emulator is an .exe-cutable installed with Samsung SDK, but while Samsung doccumentation says nothing about emulator command line arguments, the dark magic windows-fu came handy especialy command WMIC. I used the original Samsung project and clicked run-in-emulator button to make the emulator open, then executed WMIC:

WMIC /OUTPUT:C:\ProcessList.txt PROCESS get Caption,Commandline,Processid

to find out that emulator was executed with following arguments:

"C:\Program Files (x86)\Samsung\Samsung TV SDK 4\Emulator\Emulator2013_v4\bin\Emulator2.exe" kEclipse "_temp_20100108_"
"C:\Program Files (x86)\Samsung\Samsung TV SDK 4\Emulator\Emulator2013_v4\bin\Emulator2.exe" kEclipseWI "_temp_20100108_"

Now I was able to finish the ant script with targets for running and debugging in emulator and I have also implemented package target for one-click packaging (nothing else then zipping sources), instad of using the original packaging button. At the end of the day, Ant script is able to:

  • compile HaXe sources
  • run the project in emulator
  • debug the project in emulator
  • package the app
  • depploy the app (to http server, to be installed on device)

I have commited my Sample project with build.xml on github for my future reference and for anyone who is interested using HaXe for Samsung Smart TV development. I have also started to create some HaXe externs for samsung SDK APIs, and I will add more when needed.

Where to go from here

4 comments so far

  1. […] I continued to progress on my Samsung Smart TV project with unit test implementation. My aim is to prepare smooth process for automated builds. […]

  2. brad March 27, 2013 22:32

    Hey! Did you get visual debugging working for Haxe using echlix ? I’m working on a mac and would love to work to know how you got it working if you did!

  3. Jozef Chúťka March 28, 2013 10:17

    hi Brad,
    I just had to fix misspelled “echlix” to “eclihx” through the whole article. For debugging, run emulator with kEclipseWI (web inspetor) – it launches console enabling javascript debugging. HaXe provides source maps for javascript projects when compiled with “-debug”, and web inspector should be able to use it and point you out to a specific .hx source file (exceptions tracking etc.). I havent worked with it myself yet. Have a look at http://haxe.org/doc/js/source_debugging

  4. sid August 3, 2015 03:57

    hi one question i play comercial apps in samsung sdk tv emulator

Leave a comment

Please be polite and on topic. Your e-mail will never be published.