Search code examples
javascripthtmlsamsung-smart-tv

'null' is not an object - samsung smart tv 3d


I have the bellow code for switch samsung smart tv to 3d mode.but it shows an error on the console .

TypeError : 'null' is not an object (Evaluating 'SefPlugin.Open')

Main.onLoad = function()
{

    this.enableKeys();
    widgetAPI.sendReadyEvent();
    var SefPlugin = document.getElementById("plugin");
    SefPlugin.Open('Screen', '1.003', 'Screen');
    console.log(SefPlugin.Execute("Get3DEffectMode"));
    SefPlugin.Execute("Set3DEffectMode", MODE_3D_EFFECT_FROM_2D_TO_3D);


};

HTML CODE

         <html> 
         ----------------------- 
         <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>
          <script type="text/javascript" src="$MANAGER_WIDGET/Common/webapi/1.0/webapis.js"></script>

         </head>
     <body onload="Main.onLoad();" onunload="Main.onUnload();">
  <object id="plugin" classid="clsid:SAMSUNG-INFOLINK-SEF" style="width:0px; height:0px;"></object>
    </body>
    </html>

Dcoumentation links http://developer.samsung.com/tv/develop/legacy-platform-library/API00003/Screen_163


Solution

  • Use name attribute to access the object element.

    ...
     <object id="plugin" name="kekolama" classid="clsid:SAMSUNG-INFOLINK-SEF" style="width:0px; height:0px;"></object>
    ...
    

    and

    var SefPlugin = document.kekolama;