我遇到这段代码的问题,似乎传递给chroma.tabCapture.capture的回调的流是空的
var receiver = null;
chrome.tabs.getSelected(null,function(tab) {
chrome.tabCapture.capture({
video: true,
audio: false,
videoConstraints: {
mandatory: {
minWidth: 16,
minHeight: 9,
maxWidth: 1280,
maxHeight: 720,
maxFrameRate: 25, // Note: Frame rate is variable (0 <= x <= 60).
},
},
},
function(stream) {
alert(stream);
if (!stream) {
console.log('Error starting tab capture: ' + (chrome.runtime.lastError.message || 'UNKNOWN'));
return;
}
if (receiver != null) {
receiver.close();
}
receiver = window.open('receiver.html');
receiver.currentStream = stream;
}
);
});
警报(流);为null,因此代码在打开新选项卡之前返回,并传递流。非常感谢帮助