Registering/Unregistering Remote Control Keys for Samsung SmartTV Applications

Registering a remote control key means that a Samsung SmartTV application will have its own functions to handle the key input. Unregistering a key means using a SmartTV’s default OSD (On Screen Display) functions to handle it.

When an application is executed, basic remote control keys (directional keys and the OK key) are automatically registered for the application to use. To return control of a registered key to the basic OSD, the key can be unregistered. See the following remote control volume key example to help understand this concept.

If an application is a FullWidget app, volume keys are automatically registered when the application is executed. To allow users to use volume keys’ original TV OSD function of controlling volume, those keys need to be unregistered by the application.

To use the volume up key for another function (such as controlling an application’s internal gage), the KEY_VOL_UP key event needs to be registered in the application and controlled by a custom event handling for the KEY_VOL_UP event.

Commonly used keys are automatically registered when an app is executed to relieve developers. Just remember to unregister a key event if you want to return control of the key to the original OSD functions of a TV.

The SDF provides various APIs for registering and unregistering the keys.

Here is a sample source code that registers the KEY_TOOLS key.

// Create a plug-in instance of the Common Module API.
var pluginAPI = new Common.API.Plugin();
Main.onLoad = function() {
    window.onShow = onShowEvent;
    widgetAPI.sendReadyEvent();
};
onShowEvent = function() {
    // Register TOOLS key.
    pluginAPI.registKey(tvKey.KEY_TOOLS);
};

The SDF also provides an API that registers multiple keys simultaneously. See the following example that registers multiple keys that are used by a FullWidget type application.

// Create a plug-in instance of the Common Module API.
var pluginAPI = new Common.API.Plugin();
Main.onLoad = function() {
    window.onShow = onShowEvent;
    widgetAPI.sendReadyEvent();
};
onShowEvent = function() {
    // Register all keys that are used by a FullWidget type application.
    pluginAPI.registFullWidgetKey();
};

Now check out how unregistering is implemented. The next example unregisters volume up/down keys and mute keys so that the original TV OSD function can be used.

// Create a plug-in instance of the Common Module API.
var pluginAPI = new Common.API.Plugin();
Main.onLoad = function() {
    window.onShow = onShowEvent;
    widgetAPI.sendReadyEvent();
};
onShowEvent = function() {
    var nnaviPlugin = document.getElementById('pluginObjectNNavi');
    naviPlugin.SetBannerState(1);
    // Unregister keys for volume OSD.
    pluginAPI.unregistKey(tvKey.KEY_VOL_UP);
    pluginAPI.unregistKey(tvKey.KEY_VOL_DOWN);
    pluginAPI.unregistKey(tvKey.KEY_MUTE);
};

It is more logical to register and unregister remote control keys during application initialization by placing them within the body.onload function. But the example source code shows that they are placed within the window.onShow function that is called after the body.onload function.

This is to avoid any conflict that may occur when key registering and unregistering for the Smart Hub and for the application execution. Using the window.onShow function guarantees that the Smart Hub’s processes are already completed.

Note that only a few keys are automatically registered except on a full-screen application. All the necessary keys need to be manually registered.

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

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.