2015-04-05 3 views
1

Я сделал заявку на Samsung Smart TV SDK 4.1, но это приложение не работает на Samsung Smart TV 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? –

+0

Код приложения приведен ниже в ответах –

ответ

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); 

чем пытаться запустить приложение через ПДУ.

Смежные вопросы