三星智能电视sdk 4.1应用程序无法在sdk 5.1上工作

时间:2015-04-05 06:03:54

标签: html5 jsp samsung-smart-tv smart-tv

我已在Samsung Smart TV SDK 4.1上申请了该应用程序,但该应用程序无法在Samsung Smart TV SDK 5.1上运行。

任何人都可以帮助我在sdk 5.1中远程工作

我尝试了samsungdforum的一些演示应用,但它没有帮助我。

代码: 代码是:

Main.js

var widgetAPI = new Common.API.Widget();
var tvKey = new Common.API.TVKeyValue();

var current_selected_index=0;
var menu_count=5;

var Main =
{

};

Main.onLoad = function()
{
    // Enable key event processing
    this.enableKeys();
    widgetAPI.sendReadyEvent();
};

Main.onUnload = function()
{

};

Main.enableKeys = function()
{
    document.getElementById("menu").focus();
    $('.menu').eq(current_selected_index).addClass('selected');
    $('.menu a').eq(current_selected_index).focus();
};

Main.keyDown = function()
{
    var keyCode = event.keyCode;
    alert("Key pressed: " + keyCode);

    switch(keyCode)
    {
      case tvKey.KEY_UP:
        alert("UP");
        $('.menu').eq(current_selected_index).removeClass("selected");
        if(current_selected_index==0){
            current_selected_index=3;
        }
        else{
            current_selected_index--;
        }
        $('.menu').eq(current_selected_index).addClass("selected");
        break;
       case tvKey.KEY_DOWN:
            alert("DOWN");
            $('.menu').eq(current_selected_index).removeClass("selected");
            if(current_selected_index==3){
                current_selected_index=0;
            }
            else{
                current_selected_index--;
            }
            $('.menu').eq(current_selected_index).addClass("selected");
       break;   
       case tvKey.KEY_LEFT:
            alert("LEFT");
            $('.menu').eq(current_selected_index).removeClass("selected");
            if(current_selected_index==0){
                current_selected_index=4;
            }
            else{
                current_selected_index--;
            }
            $('.menu').eq(current_selected_index).addClass("selected");
            $('.menu a').eq(current_selected_index).focus();
            break;
        case tvKey.KEY_RIGHT:
            alert("RIGHT");
            $('.menu').eq(current_selected_index).removeClass("selected");
            if(current_selected_index==4){
                current_selected_index=0;
            }
            else{
                current_selected_index++;
            }
            $('.menu').eq(current_selected_index).addClass("selected");
            $('.menu a').eq(current_selected_index).focus();
            break;
        case tvKey.KEY_ENTER:



            var $j;
            $('#display').html($('.menu a').eq(current_selected_index).html());
            $j=$('.menu a').eq(current_selected_index).html();
            window.location=$j+".html";
            alert($(this).html());
            break;

        case tvKey.KEY_PANEL_ENTER:
            $('#display').html($('.menu a').eq(current_selected_index).html());
            alert($(this).html());
            break;
        default:
            alert("Unhandled key");
            break;
    }
};

Main.mouseclick=function()
{
    $('#display').html($('.menu a').eq(current_selected_index).html());
    window.location="hyderabad.html";
}; 

**Main.css**

*
{
    padding: 0;
    margin: 0;
    border: 0;
}

body
{
    width: 960px;
    height: 540px;
}

#container
    {
    width:800px;
    height:400px;
    position:absolute;
    left:50%;
    margin-left:-250px;
    top:50%;
    margin-top:-150px;
    border:1pxsolid#fff;
    border-radius:5px;

    }

.retunbtn
    {
    position:absolute;
    left:80%;
    margin-left:-150px;
    top:80%;
    margin-top:-180px;
    border:1pxsolid#fff;
    border-radius:5px;
    }

    .menu
    {
    float:left;
    width:100px;
    height:100px;
    margin-top:20px;
    margin-left:20px;
    text-align:center;
    line-height:6em;
    background-image: -webkit-linear-gradient(bottom,rgb(135,135,135) 7%, rgb(184,184,184) 54%);
    border-radius:5px;

    }

    .menu a{
    color:#8B0000;
    text-decoration:none;
    text-transform:uppercase;

    }   

    #display{
    clear:both;
    width:400px;
    height:100px;
    margin-left:50px;
    position:absolute;
    bottom:50px;
    border:1pxsolid#fff;
    border-radius:5px;
    text-align:center;
    color:blue;
    font-weight:bold;
    line-weight:3em;

    }

    .selected
    {
    background-image:-webkit-linear-gradient(bottom,rgb(135,135,135)7%,rgb(184,184,184)54%);
    color:black;
    }

    #content{
    color:#800000;
    font:bold;
    align-text:center;
    position:absolute;
    left:50%;
    margin-left:-250px;
    top:30%;
    margin-top:-150px;

    }

    .menu1 {
      float:left;
      width:20%;
      height:100%;
    }
    .mainContent {
      float:left;
      width:80%;
      height:100%;
    }

    a:link, a:visited {
    color: (internal value);
    text-decoration: underline;
    cursor: auto;
}

a:link:active, a:visited:active {
    color: (internal value);
} 


**index.html**

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>tourism</title>
        <script type="text/javascript" src="app/javascript/jquery-1.9.1.js"></script>  
        <!-- TODO : Common API -->
        <script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/API/Widget.js"></script>
        <script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/API/TVKeyValue.js"></script>
        <!-- TODO : Javascript code -->
        <script language="javascript" type="text/javascript" src="app/javascript/Main.js"></script>
        <!-- TODO : Style sheets code -->
        <link rel="stylesheet" href="app/stylesheets/Main.css" type="text/css">
        <!-- TODO: Plugins -->
    </head>
    <body onload="Main.onLoad();" onunload="Main.onUnload();">
        <!-- Dummy anchor as focus for key events -->
        <a href="javascript:void(0);" id="menu" onkeydown="Main.keyDown();"></a>
        <div id="content">
        <h1>INDIA TOURISM APPLICATION</h1>

        </div>

         <div id="container">
             <div class="menu">


             <a href="javascript.void(0);" onkeydown="Main.keyDown();" >HYDERABAD</a>

              </div>
              <div class="menu">
             <a href="javascript.void(0);" onkeydown="Main.keyDown();">Delhi</a>
              </div>
              <div class="menu">

             <a href="javascript.void(0);" onkeydown="Main.keyDown();">Jaipur</a>
             </div>

              <div class="menu">

             <a href="javascript.void(0);" onkeydown="Main.keyDown();">Jaipurs</a>
             </div>

              <div class="menu">

             <a href="javascript.void(0);" onkeydown="Main.keyDown();">Jaipur1</a>
             </div>

         </div> 

    enter code here

        <img src="images/wallpaper.jpg" style="width:960px;height:540px" >
        <!-- TODO: your code here -->
    </body>
</html>

2 个答案:

答案 0 :(得分:2)

首先,在main.enableKeys函数中,您必须启用密钥代码。

  

var pluginAPI = new Common.API.Plugin();

> pluginAPI.registKey(tvKey.KEY_RETURN);
>     pluginAPI.registKey(tvKey.KEY_EXIT);

尝试通过远程运行应用程序。

答案 1 :(得分:0)

The code is: 

**Main.js**

var widgetAPI = new Common.API.Widget();
var tvKey = new Common.API.TVKeyValue();

var current_selected_index=0;
var menu_count=5;

var Main =
{

};

Main.onLoad = function()
{
    // Enable key event processing
    this.enableKeys();
    widgetAPI.sendReadyEvent();
};

Main.onUnload = function()
{

};

Main.enableKeys = function()
{
    document.getElementById("menu").focus();
    $('.menu').eq(current_selected_index).addClass('selected');
    $('.menu a').eq(current_selected_index).focus();
};

Main.keyDown = function()
{
    var keyCode = event.keyCode;
    alert("Key pressed: " + keyCode);

    switch(keyCode)
    {
      case tvKey.KEY_UP:
        alert("UP");
        $('.menu').eq(current_selected_index).removeClass("selected");
        if(current_selected_index==0){
            current_selected_index=3;
        }
        else{
            current_selected_index--;
        }
        $('.menu').eq(current_selected_index).addClass("selected");
        break;
       case tvKey.KEY_DOWN:
            alert("DOWN");
            $('.menu').eq(current_selected_index).removeClass("selected");
            if(current_selected_index==3){
                current_selected_index=0;
            }
            else{
                current_selected_index--;
            }
            $('.menu').eq(current_selected_index).addClass("selected");
       break;   
       case tvKey.KEY_LEFT:
            alert("LEFT");
            $('.menu').eq(current_selected_index).removeClass("selected");
            if(current_selected_index==0){
                current_selected_index=4;
            }
            else{
                current_selected_index--;
            }
            $('.menu').eq(current_selected_index).addClass("selected");
            $('.menu a').eq(current_selected_index).focus();
            break;
        case tvKey.KEY_RIGHT:
            alert("RIGHT");
            $('.menu').eq(current_selected_index).removeClass("selected");
            if(current_selected_index==4){
                current_selected_index=0;
            }
            else{
                current_selected_index++;
            }
            $('.menu').eq(current_selected_index).addClass("selected");
            $('.menu a').eq(current_selected_index).focus();
            break;
        case tvKey.KEY_ENTER:



            var $j;
            $('#display').html($('.menu a').eq(current_selected_index).html());
            $j=$('.menu a').eq(current_selected_index).html();
            window.location=$j+".html";
            alert($(this).html());
            break;

        case tvKey.KEY_PANEL_ENTER:
            $('#display').html($('.menu a').eq(current_selected_index).html());
            alert($(this).html());
            break;
        default:
            alert("Unhandled key");
            break;
    }
};

Main.mouseclick=function()
{
    $('#display').html($('.menu a').eq(current_selected_index).html());
    window.location="hyderabad.html";
}; 

**Main.css**

*
{
    padding: 0;
    margin: 0;
    border: 0;
}

body
{
    width: 960px;
    height: 540px;
}

#container
    {
    width:800px;
    height:400px;
    position:absolute;
    left:50%;
    margin-left:-250px;
    top:50%;
    margin-top:-150px;
    border:1pxsolid#fff;
    border-radius:5px;

    }

.retunbtn
    {
    position:absolute;
    left:80%;
    margin-left:-150px;
    top:80%;
    margin-top:-180px;
    border:1pxsolid#fff;
    border-radius:5px;
    }

    .menu
    {
    float:left;
    width:100px;
    height:100px;
    margin-top:20px;
    margin-left:20px;
    text-align:center;
    line-height:6em;
    background-image: -webkit-linear-gradient(bottom,rgb(135,135,135) 7%, rgb(184,184,184) 54%);
    border-radius:5px;

    }

    .menu a{
    color:#8B0000;
    text-decoration:none;
    text-transform:uppercase;

    }   

    #display{
    clear:both;
    width:400px;
    height:100px;
    margin-left:50px;
    position:absolute;
    bottom:50px;
    border:1pxsolid#fff;
    border-radius:5px;
    text-align:center;
    color:blue;
    font-weight:bold;
    line-weight:3em;

    }

    .selected
    {
    background-image:-webkit-linear-gradient(bottom,rgb(135,135,135)7%,rgb(184,184,184)54%);
    color:black;
    }

    #content{
    color:#800000;
    font:bold;
    align-text:center;
    position:absolute;
    left:50%;
    margin-left:-250px;
    top:30%;
    margin-top:-150px;

    }

    .menu1 {
      float:left;
      width:20%;
      height:100%;
    }
    .mainContent {
      float:left;
      width:80%;
      height:100%;
    }

    a:link, a:visited {
    color: (internal value);
    text-decoration: underline;
    cursor: auto;
}

a:link:active, a:visited:active {
    color: (internal value);
} 


**index.html**

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>tourism</title>
        <script type="text/javascript" src="app/javascript/jquery-1.9.1.js"></script>  
        <!-- TODO : Common API -->
        <script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/API/Widget.js"></script>
        <script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/API/TVKeyValue.js"></script>
        <!-- TODO : Javascript code -->
        <script language="javascript" type="text/javascript" src="app/javascript/Main.js"></script>
        <!-- TODO : Style sheets code -->
        <link rel="stylesheet" href="app/stylesheets/Main.css" type="text/css">
        <!-- TODO: Plugins -->
    </head>
    <body onload="Main.onLoad();" onunload="Main.onUnload();">
        <!-- Dummy anchor as focus for key events -->
        <a href="javascript:void(0);" id="menu" onkeydown="Main.keyDown();"></a>
        <div id="content">
        <h1>INDIA TOURISM APPLICATION</h1>

        </div>

         <div id="container">
             <div class="menu">


             <a href="javascript.void(0);" onkeydown="Main.keyDown();" >HYDERABAD</a>

              </div>
              <div class="menu">
             <a href="javascript.void(0);" onkeydown="Main.keyDown();">Delhi</a>
              </div>
              <div class="menu">

             <a href="javascript.void(0);" onkeydown="Main.keyDown();">Jaipur</a>
             </div>

              <div class="menu">

             <a href="javascript.void(0);" onkeydown="Main.keyDown();">Jaipurs</a>
             </div>

              <div class="menu">

             <a href="javascript.void(0);" onkeydown="Main.keyDown();">Jaipur1</a>
             </div>

         </div> 

    enter code here

        <img src="images/wallpaper.jpg" style="width:960px;height:540px" >
        <!-- TODO: your code here -->
    </body>
</html>