Advertisement
Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Exception Handling in Samsung SmartTV Application Development

The SmartTV application development needs to handle more exceptions than other platforms. However, understanding characteristics of the remote controlled TV and SDF provides guides that will help handling the exceptions.

Exception handling for the focus

A SmartTV uses a remote controller to move the focus to control an application. The focus must be controlled during the entire time that an application runs. Losing the focus means that a user lost the only control tool to use the application. This can cause erroneous feedback to remote control inputs, or simply no feedback at all.

When the focus is lost while running an application, due to inadequate exception handling, the only solution is ending and restarting the application.

image0.jpg

The preceding code uses the IME to get user data for the login form, empty the Main.login.elem element, and enter the received data on there.

Deleting a subelement of the login element using the jQuery empty() function causes the currently focused anchor to also be deleted. Unless the focus was already moved to another element, the application loses the focus. To solve this problem, set an anchor and move the focus to the anchor.

image1.jpg

The focus can also be lost when the opposite blur() function is used.

Main.anchor.blur();

The blur() function is often used when calling the AVPlayer or manually ending an IME session. Just remember to move the focus whenever using the blur() function.

Main.anchor.blur();
Main.Element.anchor.focus();

There are other situations that can lose the focus — loading or ending a module, changing screens, using a pop-up event, etc. The focus will be lost unless proper exception handling is added. The focus is the connection point between a user and an application. Always be careful not to lose it.

Exception handling for the Return/Exit key

Unless programmed otherwise, pressing the Return or Exit key ends a running Samsung SmartTV application. However, a common multiple application with multiple screens needs to reprogram the Return key to show the parent screen, instead of ending the application. Since a user habitually presses the Return key to control a SmartTV, a well-designed application will ask the user if she really wants to end the application.

image2.png

The preceding function prevents the Return key event's default action of ending the application. See the following for how it is used.

image3.jpg

Note that the event.preventDefault() function was added in the Return key's event handling. This exception handling is also used to show a confirmation window when the Exit key is pressed. In this case, add the above function and a confirmation pop-up window to the Exit key's event handling code to design a refined application.

Exception handling for the player exit event

When a VOD playback is complete, the AV Player object's Stop function must be manually called to prevent a system error caused by multiple player modules being called. A second VOD may not play or the application may crash if this step is neglected. Do not forget this exception handling.

Main.AVPlayer.Stop();

The onstreamcompleted call function should be registered for the AV Player, so that it will be called when a playback is complete. Add the Stop function in it.

image4.jpg

This exception handling is combined with the previous Return key exception handling, as shown in the following. The AV Player module is declared as a scene and receives key events through its anchor. If the Return key is pressed for the anchor, it should call the Stop() function as well.

image5.jpg

The AV Player may end for various reasons. The preceding Stop() function must be used for all possible situations. And an application must check if there is any open player object during its exit.

Exception handling for the IME

IME is an internal Samsung SmartTV module for collecting user data input. Like the AV Player module, the IME module also uses callback functions for various situations. The IME module requires careful handing for the callback functions; in addition to that, it is called with a <form> element. The following exception handlings are necessary.

Maximum input length
IME onClose

An <input> element must have a maximum length for the IME module. The SDF allows a maximum of 256 letters. An application may crash after that. Set the maxlength as shown here.

image6.jpg

The second exception handling is for the IME module's exit. The IME module is opened with the onShow() function and closed with the onClose() function.

If an application suddenly ends without properly ending an open IME module first, the IME module will be forced to close as well. However, this may fail if the system resource was busy closing the application, causing a system error.

To prevent the above situation, the following code must be included in the onUnload function that handles the application exit event.

image7.png
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win an iPad Mini. Enter to win now!