2015-04-05 25 views
1

我已經在三星智能電視SDK 4.1上做了一個應用程序,但該應用程序不能在三星智能電視SDK 5.1上工作。samsung smart tv sdk 4.1應用程序不工作在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> 
+0

你能告訴我4.1代碼嗎?5.1代碼不能代碼嗎? – 2015-04-05 06:12:19

+0

應用程序代碼在答案中給出如下 – 2015-04-05 13:55:23

回答

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> 
2

在main.enableKeys首先的功能,您必須啓用鍵碼。

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

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

不是嘗試通過遠程運行應用程序。

相關問題