{"id":36836,"date":"2016-06-27T20:57:36","date_gmt":"2016-06-27T15:27:36","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=36836"},"modified":"2016-06-28T10:52:17","modified_gmt":"2016-06-28T05:22:17","slug":"building-samsung-smart-tv-application","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/building-samsung-smart-tv-application\/","title":{"rendered":"Building Samsung Smart TV Application"},"content":{"rendered":"<p>Samsung Smart TV allows developers to <a title=\"smart tv application development\" href=\"http:\/\/www.tothenew.com\/mobile-smart-tv-application-development\">develop TV-oriented applications<\/a> with extended functions using plugins. Smart TV applications are web-based software application that run on digital TVs connected to the Internet.<\/p>\n<p>With <a href=\"http:\/\/www.tothenew.com\/blog\/guidelines-and-solution-of-top-most-problems-regarding-video-application-in-samsung-smart-tv\/\">Samsung Smart TV applications<\/a>, TV users can access web content via their TV screens. Unlike general web pages, applications for Samsung Smart TV allow users to employ TV-specific features.<\/p>\n<p><strong>Installation Guide:<\/strong><\/p>\n<ol>\n<li>Install Java Runtime Environment (JRE)<\/li>\n<li>Download <a title=\"Samsung Smart TV SDK\" href=\"https:\/\/www.samsungdforum.com\/Devtools\/SdkDownload\" target=\"_blank\">Samsung Smart TV SDK<\/a><\/li>\n<li>Extract \u201cSamsung_Smart_TV_SDK_Windows_32\/64.zip\u201d<\/li>\n<li>Open \u201ceclipse.exe\u201d, choose your workspace. Check \u201cUse this as the default and do not ask again\u201d.<\/li>\n<\/ol>\n<p><strong>Installing Emulator:<\/strong><\/p>\n<ol>\n<li>Install Virtual Box<\/li>\n<li>Select File -&gt;Import Appliance<\/li>\n<li>Select Open Application and select the 2014_Smart_TV_Emulator_5_1.ova<\/li>\n<li>At import appliance settings, modify CPU to \u201c1\u201d<\/li>\n<li>After the Emulator is imported, a share folder must be set. Select the 2014_Smart_TV_Emulator and choose Setting -&gt; Shared Folders.<\/li>\n<\/ol>\n<p><strong>Basic Project Structure:<\/strong><br \/>\n<img decoding=\"async\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/06\/project.png\" alt=\"Project Structure\" \/><\/p>\n<p>A Samsung Smart TV JavaScript application consists of the following items:<\/p>\n<ul>\n<li><strong>HTML pages:<\/strong> Shows the application\u2019s structure.<\/li>\n<li><strong>CSS files:<\/strong> Defines the application\u2019s style.<\/li>\n<li><strong>JavaScript files:<\/strong> Controls the application\u2019s behavior.<\/li>\n<li><strong>Config.xml file:<\/strong> A simple configuration file defining various settings and deployment information. Contains information on the operating environment and the application version.<\/li>\n<li><strong>Widget.info file:<\/strong> A very small file with a few lines used to define the opacity of the application&#8217;s body. This may not be required for full-screen applications.<\/li>\n<li><strong>Index.html:<\/strong> The main HTML file for your application.<\/li>\n<li><strong>Images, sounds and other resources.<\/strong><\/li>\n<\/ul>\n<p><strong>Making a Basic Application:<\/strong><\/p>\n<ol>\n<ol>\n<li>Select the \u201cCreate Samsung SmartTV JavaScript App Project\u201d<\/li>\n<\/ol>\n<\/ol>\n<p><img decoding=\"async\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/06\/xyz.png\" alt=\"Add Project\" \/><\/p>\n<ol>\n<ol>\n<li>Select the menu to open the next window, here enter project name, path and application resolution.<\/li>\n<\/ol>\n<\/ol>\n<p><img decoding=\"async\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/06\/xyz1.png\" alt=\"HelloTV\" \/><\/p>\n<ol>\n<li>Click the \u201cFinish\u201d button to finish creating a new project.<\/li>\n<\/ol>\n<p>Now make changes in Index.html, Main.js and Main.css as follows:<\/p>\n<p><strong>Index.html<\/strong><\/p>\n<p>[java]<br \/>\n&lt;!DOCTYPE html&gt;<br \/>\n&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text\/html; charset=utf-8&quot;&gt;<br \/>\n&lt;title&gt;Hello World&lt;\/title&gt;<\/p>\n<p>&lt;!&#8211; TODO : Common API &#8211;&gt;<br \/>\n&lt;script type=&quot;text\/javascript&quot; language=&quot;javascript&quot; src=&quot;$MANAGER_WIDGET\/Common\/API\/Widget.js&quot;&gt;&lt;\/script&gt;<br \/>\n&lt;script type=&quot;text\/javascript&quot; language=&quot;javascript&quot; src=&quot;$MANAGER_WIDGET\/Common\/API\/TVKeyValue.js&quot;&gt;&lt;\/script&gt;<\/p>\n<p>&lt;!&#8211; TODO : Javascript code &#8211;&gt;<br \/>\n&lt;script language=&quot;javascript&quot; type=&quot;text\/javascript&quot; src=&quot;app\/javascript\/Main.js&quot;&gt;&lt;\/script&gt;<\/p>\n<p>&lt;!&#8211; TODO : Style sheets code &#8211;&gt;<br \/>\n&lt;link rel=&quot;stylesheet&quot; href=&quot;app\/stylesheets\/Main.css&quot; type=&quot;text\/css&quot;&gt;<br \/>\n&lt;\/head&gt;<\/p>\n<p>&lt;body onload=&quot;Main.onLoad();&quot; onunload=&quot;Main.onUnload();&quot;&gt;<br \/>\n\t&lt;!&#8211; Dummy anchor as focus for key events &#8211;&gt;<br \/>\n\u00a0\u00a0\u00a0 &lt;a href=&quot;javascript:void(0);&quot; id=&quot;anchor&quot; onkeydown=&quot;Main.keyDown();&quot;&gt; &lt;\/a&gt;<\/p>\n<p>\u00a0\u00a0\u00a0 &lt;!&#8211; TODO: your code here &#8211;&gt;<br \/>\n\u00a0\u00a0\u00a0 &lt;label id=&quot;LabelId&quot;&gt;Samsung Smart TV&lt;\/label&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<br \/>\n[\/java]<\/p>\n<p><strong>Main.js<\/strong><\/p>\n<p>[java]<br \/>\nvar widgetAPI = new Common.API.Widget();<br \/>\nvar tvKey = new Common.API.TVKeyValue();<\/p>\n<p>var Main ={};<\/p>\n<p>Main.onLoad = function()<br \/>\n{<br \/>\n\t\/\/ Enable key event processing<br \/>\n\tthis.enableKeys();<br \/>\n\twidgetAPI.sendReadyEvent();<br \/>\n};<\/p>\n<p>Main.onUnload = function()<br \/>\n{<br \/>\n};<\/p>\n<p>Main.enableKeys = function()<br \/>\n{<br \/>\n\tdocument.getElementById(&quot;anchor&quot;).focus();<br \/>\n};<\/p>\n<p>Main.keyDown = function()<br \/>\n{<br \/>\n\tvar keyCode = event.keyCode;<br \/>\n\talert(&quot;Key pressed: &quot; + keyCode);<\/p>\n<p>switch(keyCode)<br \/>\n{<br \/>\n\tcase tvKey.KEY_RETURN:<br \/>\n\tcase tvKey.KEY_PANEL_RETURN:<br \/>\n\t\talert(&quot;RETURN&quot;);<br \/>\n\t\twidgetAPI.sendReturnEvent();<br \/>\n\t\tbreak;<br \/>\n\tcase tvKey.KEY_LEFT:<br \/>\n\t\talert(&quot;LEFT&quot;);<br \/>\n\t\tdocument.getElementById(&quot;LabelId&quot;).innerHTML = &quot;Smart TV &#8211; LEFT&quot;;<br \/>\n\t\tbreak;<br \/>\n\tcase tvKey.KEY_RIGHT:<br \/>\n\t\talert(&quot;RIGHT&quot;);<br \/>\n\t\tdocument.getElementById(&quot;LabelId&quot;).innerHTML = &quot;Smart TV &#8211; RIGHT&quot;;<br \/>\n\t\tbreak;<br \/>\n\tcase tvKey.KEY_UP:<br \/>\n\t\talert(&quot;UP&quot;);<br \/>\n\t\tbreak;<br \/>\n\tcase tvKey.KEY_DOWN:<br \/>\n\t\talert(&quot;DOWN&quot;);<br \/>\n\t\tbreak;<br \/>\n\tcase tvKey.KEY_ENTER:<br \/>\n\t\tdocument.getElementById(&quot;LabelId&quot;).innerHTML = &quot;Smart TV &#8211; Center&quot;;<br \/>\n\t\tbreak;<br \/>\n\tcase tvKey.KEY_PANEL_ENTER:<br \/>\n\t\talert(&quot;ENTER&quot;);<br \/>\n\t\tbreak;<br \/>\n\tdefault:<br \/>\n\t\talert(&quot;Unhandled key&quot;);<br \/>\n\tbreak;<br \/>\n}<br \/>\n};<br \/>\n[\/java]<\/p>\n<p><strong>Main.css<\/strong><\/p>\n<p>[code language=&#8221;css&#8221;]<br \/>\n*<br \/>\n{<br \/>\n\tpadding: 0;<br \/>\n\tmargin: 0;<br \/>\n\tborder: 0;<br \/>\n}<\/p>\n<p>\/* Layout *\/<br \/>\nbody<br \/>\n{<br \/>\n\twidth: 960px;<br \/>\n\theight: 540px;<br \/>\n\tbackground-color: #FFF;<br \/>\n}<\/p>\n<p>#LabelId<br \/>\n{<br \/>\n\tfont-size: 250px;<br \/>\n}<br \/>\n[\/code]<\/p>\n<p>A successful run of this sample application result into a fullscreen application with a text written on the screen <strong>Samsung Smart TV<\/strong>. When user press left, right, center or enter button on the remote the text is changing simultaneously. Run this application and enjoy coding with Samsung Smart TV.<\/p>\n<p>Hope this was useful to the readers.<\/p>\n<p>Happy Coding \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Samsung Smart TV allows developers to develop TV-oriented applications with extended functions using plugins. Smart TV applications are web-based software application that run on digital TVs connected to the Internet. With Samsung Smart TV applications, TV users can access web content via their TV screens. Unlike general web pages, applications for Samsung Smart TV allow [&hellip;]<\/p>\n","protected":false},"author":167,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":25},"categories":[3479,3477,1772],"tags":[3519,3628,3629,3632],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/36836"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/167"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=36836"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/36836\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=36836"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=36836"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=36836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}