2016-04-06 32 views
0

即時通訊做一個小的應用程序,我想知道是否有觀看屏幕上您是「捕獲」屏幕chrome.desktopCapture記錄後,選擇什麼卡住捕捉

的問題是,現在的方式當我選擇一個屏幕捕捉它不顯示「停止共享」白色欄或類似的東西,它只是隱藏選擇框捕捉。這對我來說是個問題,因爲我不能記錄任何東西。

這是代碼的一部分,其中代碼:

chrome.runtime.onConnect.addListener(function(port){ 
    // listen for messages from the port 

    port.onMessage.addListener(function(message){ 
     // send back a "pending" answer on the port 
     port.postMessage({ 
      "answer": 1, 
      "state": "pending", 
      "requestId": message.requestId 
     }); 

     chrome.desktopCapture.chooseDesktopMedia(["screen", "window"], port.sender.tab, function(id){ 


      var response = { 
       "answer": 1, 
       "state": "completed", 
       "requestId": message.requestId, 
       "streamId": id 
      }; 

      // send back a "completed" answer on the port 
      port.postMessage(response); 
     }); 
    }); 
}); 

是有辦法調試這樣我就可以知道爲什麼就是共享桌面部件卡住?

謝謝!

回答

0

您可以通過inspecting it or using the debugger查看擴展名。

Inspect the popup

As long as your browser is in Developer mode, it's easy to inspect popups.

  1. Go to the Extensions page (chrome://extensions), and make sure Developer mode is still enabled. The Extensions page doesn't need to be open for the following to work. The browser remembers the setting, even when the page isn't shown.
  2. Right-click the extension and choose the Inspect popup menu item. The popup appears, and a Developer Tools window like the following should display the code for popup.html.
  3. If the Scripts button isn't already selected, click it.
  4. Click the console button (second from left, at the bottom of the Developer Tools window) so that you can see both the code and the console.

Use the debugger

  1. Set a breakpoint inside the code code for chrome.desktopCapture.chooseDesktopMedia
  2. Refresh the page and check the debugger.

另請嘗試在擴展程序的JavaScript代碼中使用廣泛可用的調試API,例如console.log()和console.error()。

+0

我看到即時沒有得到任何錯誤或任何,但檢查了幾次後,我意識到該擴展是有一個錯誤:錯誤:試圖使用斷開的端口對象,但沒有顯示控制檯上的任何東西大部分時間 – AbdulHamid

+0

這個問題可能會在談話中花費更長的時間。嘗試閱讀[長期連接](http://stackoverflow.com/questions/22943988/one-more-time-about-error-attempting-to-use-a-disconnected-port-object-how-to)和[重新建立連接](http://stackoverflow.com/questions/22943988/one-more-time-about-error-attempting-to-use-a-disconnected-port-object-how-to)到檢查有關此錯誤的解決方法。 –