PageRenderTime 27ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/doc/content/adapters/samsungtv.html

https://github.com/codelahoma/joshfire-framework
HTML | 219 lines | 216 code | 3 blank | 0 comment | 0 complexity | 27e7555e94cf20e3bcd190d2b5d9d096 MD5 | raw file
  1. <h1>Samsung TV adapter</h1>
  2. <p>This adapter has been made for the Samsung SDK framework, and tested with the 2.3 version.</p>
  3. <h2>Environment setup</h2>
  4. <h3>Requirements</h3>
  5. <ul>
  6. <li>Windows (works fine on a virtual machine, but not on bootcamp)
  7. <li>the 2.3 SDK or later : get the latest version on <a href="http://www.samsungdforum.com/Board/AppsGuideToolSDKList">samsungdforum / apps guide / download SDK and tools</a> (Account required)
  8. <li>You're strongly adviced to work with an actual device. Do not rely on the emulators alone!
  9. </ul>
  10. <h3>Installation</h3>
  11. <ul>
  12. <li>Install the SDK and the emulator. You also need to install Apache, as you'll need it package your application.</li>
  13. <li>The visual editor is only useful if you plan to develop Samsung TV-only apps. It's not suitable to use it for multi-devices applications development, as it creates specific Samsung UI components.</li>
  14. <li>Check that the emulator is up and running: Clicking on the Home button, you should see a version of the SmartHub&copy; and can navigate with the fake remote control.
  15. <figure>
  16. <img src="./screenshot-samsungtv-smarthub.jpg">
  17. <figcaption>The Samsung App Store</figcaption>
  18. </figure>
  19. </li>
  20. </ul>
  21. <h3>Hello World with the Editor</h3>
  22. <p>The SDK editor is a modified Eclipse IDE, you can create a new Hello World project by right-clicking on the <code>Apps</code> directory in the left panel and selecting New Javascript project. Once done, right click on the project and select Run emulator.
  23. <figure>
  24. <img src="./screenshot-samsungtv-emulator.jpg">
  25. <figcaption>The emulator running an application</figcaption>
  26. </figure>
  27. </p>
  28. <p><em>Note 1 : Your files <b>must</b> remain in <code>C:\Program Files\Samsung\Samsung TV Apps SDK\Apps\</code>, or the emulator won't work.</em></p>
  29. <p><em>Note 2 : SDK tends to use 100% of the CPU, making it difficult to use the emulator in the same time. If so, you will use the SDK editor only to create a new project or package it. Use the Open App button in the Emulator to execute your project.</em></p>
  30. <p>For those reasons, and because you are probably doing an application for more than one device, we made several things to help you.</p>
  31. <h3>Hello World with Joshfire</h3>
  32. <p>If you prefer to use your development tools or have to write the same application for other platforms, Joshfire provides you the right tools.
  33. <ol>
  34. <li>We will use the Hello World example (<code>examples/helloworld</code>) and the build tools so that it can be executed in the Samsung emulator
  35. <figure>
  36. <img src="./samsungtv-helloworld.png">
  37. <figcaption>Starting point : just 2 files and a symlink</figcaption>
  38. </figure>
  39. Simply edit <code>app.js</code> and in the dependencies list, replace <code>joshfire/app</code> by <code>joshfire/adapters/samsungtv/app</code>. This Web Application is now a Samsung TV application.
  40. </li>
  41. <li>Enable the build tools by creating
  42. <ol>
  43. <li>a <a href="/doc/develop/buildtools#fabfilepy"><code>fabfile.py</code></a> file </li>
  44. <li>the <code>build/build.js</code> descriptor file</li>
  45. <li>the <code>export</code> folder</li>
  46. </ol>
  47. </li>
  48. <li>run the generic <code>fab <a href="/doc/develop/buildtools#optimize">optimize</a></code> method to generate the compiled files in the <code>export</code> directory
  49. <figure>
  50. <img src="./samsungtv-helloworld2.png">
  51. <figcaption>Check point : build configuration and result</figcaption>
  52. </figure>
  53. </li>
  54. <li>run the special <code>fab <a href="/doc/develop/buildtools#exportAdapterSamsungTV">exportAdapterSamsungTV</a></code> method to obtain the Samsung TV version
  55. <figure>
  56. <img src="./samsungtv-helloworld3.png">
  57. <figcaption>Ending point : the Samsung files</figcaption>
  58. </figure>
  59. </li>
  60. </ol>
  61. </p>
  62. <p>Now you obtained the files needed to run an application in the Samsung world. The last two files (<code>videolist-example.zip</code> and <code>widgetlist.xml</code>) are useful if you have a <a href="#tv">physical device</a> or when you will submit your application to the Samsung validation process.</p>
  63. <p>The emulator needs you to copy the first files and directories in a subdirectory of <code>C:\Program Files\Samsung\Samsung TV Apps SDK\Apps\</code> directory. Once done, open the emulator and click Open App, you should see your app running"</p>
  64. <h3>Support and documentation</h3>
  65. There is two known forums :
  66. <ul>
  67. <li>The official forum, mandatory anyway if you want to submit your app : <a href="http://www.samsungdforum.com/">www.samsungdforum.com/</a>
  68. <li>An independant forum : <a href="http://www.connectedtvforum.com/viewforum.php?f=3">www.connectedtvforum.com</a>, where you will sometimes find more answers
  69. </ul>
  70. <h2>Known limitation you should be aware of</h2>
  71. <h3>Browser</h3>
  72. <ul>
  73. <li>The Maple browser is based on an old Gecko engine, test carefully all of your CSS
  74. <li>CPU is limited, especially on bluray players. You should avoid too much DOM manipulation like the animations on those devices. You can detect the type of device with the static method <code>samsungJoshfire.TVInfoAPI.GetProductType()</code>
  75. <li>the <code>.innerHTML</code> property works but Samsung recommends <strong>not</strong> using it, because of potential memory saturation. The Joshfire Framework patched for your <code>jQuery $.html()</code> to follow the recommanded alternative method.
  76. <li>The app will always be displayed in <code>960*540</code> resolution, whatever the TV resolution. Medias like videos or photos using the Samsung APIs will however be displayed at the TV resolution.
  77. <li><code>z-index</code> above 99 are ignored
  78. <li>communication with an <code>iframe</code> is possible with some hacks (monitoring the URL dash value of the iframe), but the communication is lost when frame is reloaded. If we find a workaround, we will include it in a next release.
  79. <li><code>console.log</code> does not work, use <code>J.log()</code> instead
  80. <li>the HTML5 <code>video</code> element does not work as expected, use the <code>adapters/samsungtv/uielements/video.mediaelement</code> class
  81. </ul>
  82. <h3>Forms</h3>
  83. <h4>bugs</h4>
  84. <p>some input types can not be rendered normaly :
  85. <ul>
  86. <li>checkboxes are white squares, Joshfire provides you a default styling, however it would be pretier to replace them by images (background images do not work)
  87. <li><code>radio</code> buttons are white squares, not even stylable : avoid them or reprogram them entirely
  88. <li><code>select</code> fields are not usable : avoid them or reprogram them entirely
  89. </ul>
  90. In a future release, the adapter will do this for you.
  91. </p>
  92. <h4>focus</h4>
  93. How do you navigate in a form and fill in text fields in a Samsung TV ? Well you cant. Or you have to manage the focus and the virtual keyboard yourself. But dont worry, we got you covered with a small utility.
  94. <pre><code class="javascript">
  95. Joshfire.define(
  96. ['joshfire/adapters/samsungtv/utils/navigationhelper'],
  97. function(NavigationHelper) {
  98. // ask the NavigationHelper utility to search in the DOM the input elements
  99. NavigationHelper.autoDiscoverForms();
  100. // enable up and down keys to go from one textfield to another
  101. NavigationHelper.listenToNavigation();
  102. // autofocus on the first element
  103. NavigationHelper.focus(0);
  104. // events fired when the visibility of the Samsung virtual keyboard changes
  105. // in order to update the UI accordingly
  106. NavigationHelper.subscribe('virtualkeyboard', function(name, event) {
  107. if(event === 'show') {
  108. // move the form to the left
  109. } else if(event === 'hide') {
  110. // center the form
  111. }
  112. });
  113. // when the form disappears, you should run this method
  114. NavigationHelper.reset();
  115. }
  116. );
  117. </code></pre>
  118. <h3>Other things Joshfire does for you</h3>
  119. <h4>XHR (AJAX)</h4>
  120. <p>Even if the application is executed on the local file system the native <code>XMLHTTPRequest</code> object works fine because cross-domain calls are allowed. However the the <code>$.ajax()</code> jQuery method had to be fixed. We still recomend using the <a href="/doc/api/symbols/utils_datasource.html"><code>Utils.DataSource.request()</code></a> method, so that your application is cross-device compatible
  121. <h4>Shortcuts to TV APIs</h4>
  122. <p>If you know what you are doing, you can have a direct access to the TV APIs :
  123. <ul>
  124. <li><code>samsungJoshfire.widgetAPI</code>, instance of <code>new Common.API.Widget()</code>
  125. <li><code>samsungJoshfire.pluginAPI</code>, instance of <code>new Common.API.Plugin()</code>
  126. <li><code>samsungJoshfire.oKeys</code>, contains all remote control key values as returned by <code>new Common.API.TVKeyValue()</code>
  127. <li><code>samsungJoshfire.TVNavigationAPI</code> is the <code>clsid:SAMSUNG-INFOLINK-NNAVI</code> plugin
  128. <li><code>samsungJoshfire.TVInfoAPI</code> is the <code>clsid:SAMSUNG-INFOLINK-TV</code> plugin
  129. </ul>
  130. Do not forget to <a href="https://github.com/joshfire/joshlib">contribute</a> to this adapter if you think we missed something important that could be used by other people.
  131. </p>
  132. <h4>Local storage</h4>
  133. <p>There will be Joshfire Framework methods to do it in a cross-device way, but in the meantime we made two shortcut methods to save content locally on the Samsung TV
  134. <ul>
  135. <li><code>samsungJoshfire.writeToFileID(sFileID, sContent )</code>
  136. <li><code>samsungJoshfire.readFromFileID(sFileID )</code>
  137. </ul>
  138. However be careful :
  139. <ul>
  140. <li>there is no way to know if you reached the limit : plan for failure
  141. <li>the total available space is unknown : plan for failure
  142. <li>all applications share the same space : store as litle as possible
  143. <li>it seems that there is no sandbox so any application can access to the files of the other : provide a non-guessable <code>sFileID</code>
  144. </ul>
  145. </p>
  146. <h4>Volume control, TV tuner, navigation keys</h4>
  147. <p>The applications on Samsung TV are a bit too powerful, and that includes preventing the user to leave your application, watching another TV show or even to control his own volume ! Samsung is aware of this and will reject your application if you do such things so Joshfire got you covered too:
  148. <ul>
  149. <li>the <code>config.xml</code> file is already configured with correct settings for <code>srcctl</code>, <code>audiomute</code>, <code>videomute</code>, <code>flashplayer</code> and <code>movie</code>. That means that when running your application, the current video chanel is stopped, but when exiting, it will get back.
  150. <li>we let the user manage the volume with the standard OSD
  151. <li>we binded the remote control multimedia buttons to the <code>play / pause / stop / forward / rewind</code> global events
  152. <li>we require the TV to display the app when it is inserted. If you need to modify this behaviour, overwrite <code>App.insert()</code> and call <code>samsungJoshfire.widgetAPI.sendReadyEvent();</code> when you think your application can be displayed.
  153. </ul>
  154. </p>
  155. <h4>Playing videos</h4>
  156. <p>You should use <code>uielements/video.mediaelement</code> who will work as expected.
  157. <pre><code class="javascript">
  158. Joshfire.define(
  159. ['src/uielements/video.mediaelement'],
  160. function(Video) {
  161. // plays a non protect H.264 file
  162. Video.play('http://example.org/video/file.mp4')
  163. // plays a video with DRM management
  164. Video.play( {
  165. DRMType:'HLS', // could be HLA
  166. url:'http://example.org/video/fileWithToken.m3u8'
  167. });
  168. // listen to download or play events
  169. Video.subscribe('error', function() {
  170. });
  171. Video.subscribe('loading', function() {
  172. // buffering, should display an indicator
  173. });
  174. Video.subscribe('playing', function() {
  175. // update the play/pause button state
  176. });
  177. Video.subscribe('timeupdate', function(args) {
  178. console.log(args.currentTime, args.totalTime);
  179. })
  180. }
  181. );
  182. </code></pre>
  183. Be aware of the fact that by default the video is played fullscreen, behind the web interface. That means you have to let transparent <code>background-color</code> to see it.
  184. </p>
  185. <h2><a name="tv">Testing on the TV</a></h2>
  186. <ol>
  187. <li>Run the <code>fab <a href="/doc/develop/buildtools#exportAdapterSamsungTV">exportAdapterSamsungTV</a></code> command
  188. <li>copy <code>videolist-example.zip</code> and <code>widgetlist.xml</code> to the root of an HTTP server like Apache
  189. <ul>
  190. <li>On the TV use the provided browser to check you can reach that server via its IP
  191. <li>the port must be 80
  192. </ul>
  193. <li>Start the TV, start SmartHub&copy;
  194. <li>Login (red button) with special account "develop". Follow the Samsung instructions on samsungforum.com to create an account if you dont have one
  195. <li>Once logued in, Parameters menu (blue button)
  196. <li>Development sub-menu, configure the IP if needed
  197. <li>Then synchronize user application. If the application never downloads, check the following things :
  198. <ul>
  199. <li>check <code>widgetlist.xml</code> is present on the server root
  200. <li>check that there is only one zip file referenced
  201. <li>check the size and the availability of the zip file
  202. <li>reboot TV
  203. </ul>
  204. <li>Close and reopen SmartHub&copy;, the app should be visible
  205. </ol>
  206. <p><em>Note : to empty cache or erase cookies, there is only one action : reboot TV</em></p>