简体   繁体   English

在Samsung Smart Tv应用程序中通过Remote导航

[英]Navigation through Remote in Samsung Smart Tv application

I am creating a samsung smart Tv javascript application, the HTML page is finished and now its time to integrate remote control options in it. 我正在创建一个三星智能电视javascript应用程序,HTML页面已完成,现在是时候集成远程控制选项了。

My application contains tabs/images for different chanells etc which when the user selects through remote, he will be redirected to. 我的应用程序包含不同chanells等的标签/图像,当用户通过遥控器选择时,他将被重定向到。 Now the the problem is that how this navigation will work?? 现在的问题是这个导航将如何工作? how the user can go left right or up and down on these channel tabs using the remote control? 用户如何使用遥控器在这些通道选项卡上左右或上下左右?

In the samsung smart tv documentation they have given info about their keys library but how can i use it in my application to move to different elements? 在三星智能电视文档中,他们已经提供了有关其密钥库的信息,但我如何在我的应用程序中使用它来移动到不同的元素?

can not give you a fully working solution, but at least some practices from how we did this. 不能给你一个完全有效的解决方案,但至少有一些我们这样做的做法。

You can organize your HTML into different navigations zones and types. 您可以将HTML组织到不同的导航区域和类型中。 A navigation zone has a navigation type, typically list or a grid . 导航区域具有导航类型,通常是列表网格

A JavaScript navigation controller keeps track of what zone you are in. It also handles keypress (up/down/left/right/enter), and figure out what is next item to highlight based on navigation type. JavaScript导航控制器会跟踪您所在的区域。它还可以处理按键(向上/向下/向左/向右/输入),并根据导航类型确定要突出显示的下一个项目。

Lets say you have a list of tabs: 假设您有一个标签列表:

<div id="maintabs" class="tabs nav-current-zone" data-nav-type="list">
    <span class="tab nav-current-item">Tab 1</span>
    <span class="tab">Tab 2</span>
    <span class="tab">Tab 3</span>
</div>

The JavaScript would typically look like this: JavaScript通常如下所示:

if($(".nav-current-zone").data("nav-type") === "list"){
    if(key === "down"){
       var currentItem = $(currentZone).find("nav-current-item");
       var nextItem =  $(currentItem).next();
       $(currentItem).removeClass("nav-current-item");
       $(nextItem).addClass("nav-current-item");
    } else if(key === "up"){
    ...
}

What if you are at the top/bottom of list and navigate out of list? 如果您位于列表的顶部/底部并从列表中导航,该怎么办? In this case you can either do nothing or define an other zone to enter. 在这种情况下,您可以不执行任何操作或定义要输入的其他区域。

<div id="maintabs" data-nav-type="list" data-nav-leave-down="anotherZone">
    ...
</div>

<div id="anotherZone" data-nav-type="list" data-nav-leave-up="maintabs">
    ...
</div>

So lets handled this: 所以我们处理这个:

if(key === "down"){
   var nextItem =  $(currentZone).find("nav-current").next();
   if($(next).size() === 0){
        var nextZone = $(currentZone).data("nav-leave-down");
        //navigate to the other zone
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM