Search code examples
samsung-smart-tv

Samsung Smart TV -Get Device ID in Emulator


Im totaly new to the Samsung Smart TV App Development.Im trying to get Device Serial (MAC Address or any unique String) when the app is running.Here is what i have done so far.

    <!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Test2</title>

    <!-- 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 -->
    <script type="text/javascript">
    <script>
    function myFunction() {
       var networkPlugin = document.getElementById('pluginNetwork');
       var nnaviPlugin = document.getElementById('pluginObjectNNavi');
       var deviceId = nnaviPlugin.GetDUID(networkPlugin.GetHWaddr());

       document.getElementById('ss').innerHTML = nnaviPlugin;
    }
    </script>

    </script>

</head>

<body onload="lycaload();" bgcolor="#FFF" style="background:#FFF">

fgujhdfughufdghudfhgufghufhgfc
<object id='pluginNetwork' border=0 classid='clsid:SAMSUNG-INFOLINK-  NETWORK'></object>
<object id='pluginObjectNNavi' border=0 classid='clsid:SAMSUNG-INFOLINK-NNAVI'>  </object>
    <!-- Dummy anchor as focus for key events -->
      <a href="javascript:void(0);" id="anchor" onkeydown="Main.keyDown();">   </a>

    <div id="ss">
    </div>
   </body>
 </html>

This application is testing on 2014 Samsung Smart TV Emulator 5.1 and receiving nothing when app is running. Please don't mark this as duplicate. I have followed previous Stackoverflow post and didnt get any luck..


Solution

  • from network plugin you get MAC address like this:

    var mac = networkPlugin.GetMAC(0) || networkPlugin.GetMAC(1); // wired or wireless MAC address
    
    if (!mac) {
        mac = 0;
    }
    
    console.log(String(mac).toUpperCase());
    

    But I should recommend that better solution is using unique identifier from player (there is unique ID for playing DRM content)

    <object id='EXTERNALWIDGET' border=0 classid='clsid:SAMSUNG-INFOLINK-EXTERNALWIDGETINTERFACE'>  </object>
    try {
    var externalPlugin= document.getElementById('EXTERNALWIDGET');
    
    console.log(externalPlugin.GetESN("WIDEVINE"));
    } catch (e) {
        return false;
    }