三星智能电视应用程序& Brightcove示例应用程序远程控制问题

时间:2012-09-14 09:09:35

标签: javascript samsung-smart-tv remote-control brightcove

我遇到了Bightcove(https://github.com/BrightcoveOS/Samsung-Smart-TV-Sample-App)为Samsung Smart TV提供的示例应用程序的问题。遥控器不适用于最新(2012)型号。这似乎是一个已知的错误(https://github.com/BrightcoveOS/Samsung-Smart-TV-Sample-App/issues/3),并且是关于github的报告和在brightcove的支持论坛上。不幸的是,他们停止维护源代码,没有人回答这个问题。

在2010/2011模型上,一切正常。

我认为问题出在enginelite.keyhandler.js的某处:

/**
 * 
 *  Simple TV App Engine KeyHandler
 *  
 *  author: A Different Engine LLC.
 *  http://adifferentengine.com
 *  contact@adifferentengine.com
 *
 */
// This is pretty straightforward.
TVEngine.KeyHandler = {

    keyActions:  {
        KEY_UP:             'onUp',
        KEY_DOWN:           'onDown',
        KEY_LEFT:           'onLeft',
        KEY_RIGHT:          'onRight',
        KEY_ENTER:          'onSelect',
        KEY_RETURN:         'onReturn',
        KEY_STOP:           'onStop',
        KEY_FF:             'onFF',
        KEY_RW:             'onRew',
        KEY_PLAY:           'onPlay',
        KEY_PAUSE:          'onPause',
        KEY_YELLOW:         'onYellow',
        KEY_RED:            'onRed',
        KEY_BLUE:           'onBlue',
        KEY_GREEN:          'onGreen',
        KEY_EXIT:           'onExit',
        KEY_MENU:           'onMenu',
        KEY_BACK:           'onReturn',
        KEY_SKIPFFORWARD:   'onSkipForward',
        KEY_SKIPBACK:       'onSkipBack',
    },
    enabled: true,
    keyMap: {},

    init: function() {
        // Maps system key list to ours
        $KEYS = TVEngine.getPlatform().keys();
        // Transforming Samsung keymap into something we like slightly better.
        for(key in $KEYS) {
            this.keyMap[$KEYS[key]] = key;
        }
        this._initializeKeyHandler();
    },
    _cleared: true,
    _initializeKeyHandler: function() {
        var _this = this; var clear;
        $(document).bind("keydown", function(event) {
            var action = _this.keyActions[_this.keyMap[event.keyCode]];
            // $log("<<< GOT KEY ACTION: "+action+">>>");
            if ( action && _this.enabled ) _this.trigger("keyhandler:"+action);
            return false;
        });
        $(document).bind("keyup", function(event) {
            var action = _this.keyActions[_this.keyMap[event.keyCode]]+"Release";
            // $log("<<< GOT KEY ACTION: "+action+" >>>");
            if ( action ) _this.trigger("keyhandler:"+action);
            return false;
        })
    },

    enable: function(){
        this.enabled = true;
    },
    disable: function() {
        this.enabled = false;
    }
};
// Now we can subscribe to the keyhandler from anywhere. 
_.extend(TVEngine.KeyHandler, Backbone.Events);

有人能够解决这个问题吗?

干杯

2 个答案:

答案 0 :(得分:2)

您需要重写_keys文件中的enginelite.platforms.js对象:

this._keys = {
    KEY_RETURN:     88,     //36, //8
    KEY_UP:         29460,  //38,
    KEY_DOWN:       29461,  //40,
    KEY_LEFT:       4,      //37,
    KEY_RIGHT:      5,      //39,
    KEY_ENTER:      29443,  //13,
    KEY_RED:        108,    //65,
    KEY_GREEN:      20,     //66,
    KEY_YELLOW:     21,     //67,
    KEY_BLUE:       22,     //68,
    KEY_BACK:       8,      //I don't know what button on remote it is :)
    KEY_PLAY:       71,     //80,
}

它可以在三星的所有平台上运行。

正如我的回答为您提供了直接的解决方案,@ brimil01解决方案为您提供了调试问题的方法。

答案 1 :(得分:1)

我建议检查生成的keymap,看看在init期间密钥处理程序中存储了哪些密钥:

for(key in $KEYS) {
  alert(key+": "+$KEYS[key]);
  this.keyMap[$KEYS[key]] = key;
}

然后捕获keydown事件中发送的密钥代码:

$(document).bind("keydown", function(event) {
  alert("keyCode: "+event.keyCode);
  alert("keyMap: "+_this.keyMap[event.keyCode]);
  var action = _this.keyActions[_this.keyMap[event.keyCode]];
  // $log("<<< GOT KEY ACTION: "+action+">>>");
  if ( action && _this.enabled ) _this.trigger("keyhandler:"+action);
  return false;
});

这可以让您了解密钥处理程序中发生了什么。