admin管理员组文章数量:1391951
I'm trying to capture the active YouTube tab using chrome.tabCapture.getMediaStreamId, but I'm getting an error saying:
chrome.tabCapture.getMediaStreamId error: Error: Extension has not been invoked for the current page (see activeTab permission). Chrome pages cannot be captured.
Here is the relevant part of my code in popup.js:
document.getElementById("captureButton").addEventListener("click", async () => {
console.log("Capture button clicked");
const [activeTab] = await chrome.tabs.query({ active: true, currentWindow: true });
if (!activeTab?.id) {
console.error("No active tab found");
return;
}
console.log("Active tab:", activeTab.url);
try {
const streamId = await chrome.tabCapture.getMediaStreamId({
targetTabId: activeTab.id,
});
if (!streamId) {
console.warn("No streamId was returned.");
return;
} else {
console.log("Got MediaStreamId:", streamId);
}
} catch (err) {
console.error("chrome.tabCapture.getMediaStreamId error:", err);
}
});
The log shows that the active tab URL is /, but I still get the error:
chrome.tabCapture.getMediaStreamId error: Error: Extension has not been invoked for the current page (see activeTab permission). Chrome pages cannot be captured.
I have already added the following permissions in my manifest.json:
{
"manifest_version": 3,
"name": "TabCapture Test",
"version": "1.0",
"permissions": [
"tabCapture",
"activeTab",
"tabs"
],
"action": {
"default_popup": "popup.html"
}
}
But it doesn’t seem to solve the problem. The error message mentions that "Chrome pages cannot be captured," but in this case, the active tab is YouTube, which is not a Chrome internal page.
Question: Why am I still getting this error even though the active tab is YouTube and how can I successfully get the streamId for a YouTube page using chrome.tabCapture? Are there additional permissions or settings required to make this work?
Any help or guidance is appreciated!
本文标签:
版权声明:本文标题:Why does chrome.tabCapture.getMediaStreamId return an error for an active YouTube tab stating "Chrome pages cannot be c 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744723403a2621830.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论