以编程方式捕获LG WebOS TV中当前的屏幕截图

时间:2017-03-09 08:47:04

标签: websocket webos java-websocket lg smart-tv

我正在尝试LG电视的屏幕截图。运行nmap会给我以下输出。

Discovered open port 18181/tcp on xx.xx.xx.xxx
Increased max_successful_tryno for xx.xx.xx.xxx to 1 (packet drop)
Discovered open port 9998/tcp on xx.xx.xx.xxx
Discovered open port 9955/tcp on xx.xx.xx.xxx
Discovered open port 1998/tcp on xx.xx.xx.xxx
Discovered open port 3001/tcp on xx.xx.xx.xxx
Discovered open port 1267/tcp on xx.xx.xx.xxx
Discovered open port 1512/tcp on xx.xx.xx.xxx
Discovered open port 3000/tcp on xx.xx.xx.xxx
Discovered open port 1812/tcp on xx.xx.xx.xxx
Discovered open port 1552/tcp on xx.xx.xx.xxx
Discovered open port 36866/tcp on xx.xx.xx.xxx

现在,我如何获得当前节目在电视中播放的截屏。

谢谢

想知道如何,我可以获得电视的截图?

此代码用于通过WebSocket

关闭电视发送消息
public static void turnOff(WebSocketClient ws) throws JSONException
{
    JSONObject headers = new JSONObject();
    JSONObject payload = new JSONObject();

    try {
        headers.put("type", "request");
        headers.put("id", 10001);
        headers.put("uri",  "ssap://system/turnOff");

    } catch (JSONException e) {

    }

    headers.put("payload", payload);
    ws.send(headers.toString());

    System.out.println(headers.toString());
} 

这是连接到电视中的WebSocket的代码

      ws = new WebSocketClient(URI.create("ws://10.10.10.111:3000")) {

        @Override
        public void onOpen(ServerHandshake arg0) {
             System.out.println("Connected ws://10.10.10.111:9000");
  try {
      // sendPin(ws);
       register(ws);
  } catch (JSONException ex) {
      Logger.getLogger(LGWebTVClient.class.getName()).log(Level.SEVERE, null, ex);
  }                 
        }

        @Override
        public void onMessage(String arg0) {
            try {
                System.out.println(arg0);
                JSONObject  message = new JSONObject();
                try {
                    message = new JSONObject(arg0);
                } catch (JSONException ex) {
                    Logger.getLogger(LGWebTVClient.class.getName()).log(Level.SEVERE, null, ex);
                }
                String type = message.optString("type");                    


                try
                {
                    String pin ="";
                    for (int i = 0; i < 9; i++)
                    {

                       if(type.equals("response"))
                       {
                        String id = message.optString("id");    
                        if(id.equals("152463"))
                        {
                Scanner scanner = new Scanner(new InputStreamReader(System.in));

                System.out.println("Enter the PIN: ");
                int number = scanner.nextInt();
                System.out.println("Integer input: " + number);                               



                pin = number+"";

                                if(number < 10)
                                    pin ="00"+pin;

                                if(number < 99 && number > 9)
                                    pin ="0"+pin;

                                if(i > 99)
                                    pin =""+pin;
                System.out.println("Sending PIN");
                sendPin(ws,pin);
                break;                                    
                        }
                       }
                    }
                }
                catch (JSONException ex) 
                {

                }


                if(type.equals("registered"))
                {
                      System.out.println("Registerd");
                      secondScreen(ws);
                }

1 个答案:

答案 0 :(得分:0)

You could convert the HTML content into a canvas,然后将其另存为文件。

但是,这只会直接呈现HTML和CSS。它无法捕获任何东西。

或者,可以将getUserMedia()用于take a screenshot of everything, and save that as a file