我正在做一个小应用程序,我想知道是否有办法查看你正在“捕捉”的屏幕
现在的问题是,在我选择要捕获的屏幕后,它没有显示“停止共享”白条或类似的东西,它只是隐藏了选择帧来捕获。这对我来说是个问题,因为我无法记录任何内容。
这是代码中代码的一部分:
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 :(得分:0)
You can view extension by inspecting it or using the debugger.
Inspect the popup
As long as your browser is in Developer mode, it's easy to inspect popups.
- 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.
- 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.
- If the Scripts button isn't already selected, click it.
- 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
- Set a breakpoint inside the code code for chrome.desktopCapture.chooseDesktopMedia
- Refresh the page and check the debugger.
Also try using widely available debugging APIs such as console.log() and console.error() in your extension's JavaScript code.