I have been searching around a bit, but didn't find any solution to this issue.
I'm not sure why but the stream which I'm getting is null.
As you can see in the code bellow, I'm not using browserAction but instead I'm sending a message to the extension and then calling requestCurrentTabCapture
chrome.runtime.onConnect.addListener(function(port) {
port.onMessage.addListener(function(msg) {
switch(msg.type){
case 'SS_TAB_REQUEST':
alert("SS_TAB_REQUEST");
requestCurrentTabCapture(port, msg);
break;
case 'SS_TAB_CANCEL':
break;
default:
}
});
});
function requestCurrentTabCapture(port, msg){
//chrome.tabs.getCurrent(function(tab) {
//chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.query({active: true}, function(tab) {
alert(tab);
chrome.tabCapture.capture(
{
video: true, audio: true,
videoConstraints: {
mandatory: {
chromeMediaSource: 'tab',
minWidth: 16,
minHeight: 9,
maxWidth: 1280,
maxHeight: 720,
maxFrameRate: 60, // Note: Frame rate is variable (0 <= x <= 60).
},
},
},
function(stream) {
alert(stream); //<-- NULL
if (!stream) {
console.error('Error starting tab capture: ' + chrome.runtime.lastError.message || 'UNKNOWN'));
}
}
);
});
chrome.tabCapture.onStatusChanged.addListener(function (info){
alert("status: "+info.status); //<-- not shown
alert("tabId: "+info.tabId); //<-- not shown
alert("fullscreen: "+info.fullscreen); //<-- not shown
});
}
Permissions are as follows:
"permissions": [
"desktopCapture",
"<all_urls>",
"tabs",
"activeTab",
"tabCapture"
]