I am writing an app with a "picture in picture" object showing what the TV is currently tuned to. The JS used to trigger this is :
webapis.tv.window.setRect({
left:108, top:0, width : 714, height: 420
});
however I am not sure how to handle the key bindings for changing channels. Are there any examples available for this?
You have a two way, if you want use native channel switch like "tuneUp" and "tuneDown" buttons, you can unregister buttons in your app and they will work as native:
function init() {
var pluginAPI,
tvKey;
try {
var nnaviPlugin = document.getElementById('pluginObjectNNavi');
if (nnaviPlugin) {
nnaviPlugin.SetBannerState(2);
}
pluginAPI = new Common.API.Plugin();
tvKey = new Common.API.TVKeyValue();
pluginAPI.setOffScreenSaver();
pluginAPI.unregistKey(tvKey.KEY_CH_UP);
pluginAPI.unregistKey(tvKey.KEY_CH_DOWN);
pluginAPI.unregistKey(tvKey.KEY_VOL_UP);
pluginAPI.unregistKey(tvKey.KEY_VOL_DOWN);
pluginAPI.unregistKey(tvKey.KEY_MUTE);
webapis.tv.window.getAvailableWindow(successCB, errorCB);
} catch (e) {
console.log(e);
}
}
Don't forget add plugins to html:
<object id="pluginPlayer" classid="clsid:SAMSUNG-INFOLINK-PLAYER" style="width: 0; height: 0; opacity: 0;"></object>
<object id="pluginObjectTVMW"classid="clsid:SAMSUNG-INFOLINK-TVMW" style="width: 0; height: 0; opacity: 0;"></object>
<object id="pluginObjectNNavi" classid="clsid:SAMSUNG-INFOLINK-NNAVI" style="width: 0; height: 0; opacity: 0;"></object>
Second way, catch keyDown events and use sdk methods:
webapis.tv.channel.tuneUp(successCB, errorCB, webapis.tv.channel.NAVIGATOR_MODE_ALL);
webapis.tv.channel.tuneDown(successCB, errorCB, webapis.tv.channel.NAVIGATOR_MODE_ALL);
and if you want go to chosen channel:
webapis.tv.channel.tune(channelObjFromEpg, successCB, errorCB);