私の画面を共有して記録しようとしていますが、ストリームのソースを選択するとストリーミングが開始されず、画面とウィンドウ私はChromeMediaSourceとChromeMediaSourceIDを取得することを確認しましたが、私が言ったように、共有は表示されず、このために何も記録できないというダイアログが表示されます。自分の画面を自分のクロム拡張子と共有できません
" at chrome-extension://mnoggiilghljimfhpghalhngdciecafi/background.js:16:31"
背景ファイル
に「chrome.desktopCapture.chooseDesktopMedia」である、これは私の背景ファイル
さ:これは、コンソールにログインしていない私は、デバッグを発見したエラーがあります
background.js
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 || undefined
};
// send back a "completed" answer on the port
port.postMessage(response);
});
});
});
これはファイル番目です拡張機能を使用して
bridge.js
// open a port to communicate with background
var port = chrome.runtime.connect();
// create node
var node = document.createElement('div');
// listen for messages from webpage and forward them to the background, through the previously opened port
window.addEventListener('message', function (event){
if (event.source != window || !event.data){
return;
}
// prevent to return answer to the background
if(event.data.answer){
return;
}
port.postMessage(event.data);
});
// listen for messages from background and forward them to the webpage
port.onMessage.addListener(function(data){
window.postMessage(data, '*');
});
// insert tag into parent page
node.id = 'extension-screensharing-installed';
document.body.appendChild(node);
ウェブサイトへのロードされた時にmanifest.js
{
"name": "extension name",
"description": "This extension allows you to share your screen",
"version": "0.1",
"manifest_version": 2,
"minimum_chrome_version": "34",
"icons": {
"16": "img16.png",
"48": "img48.png",
"128": "img128.png"
},
"background": {
"scripts": ["background.js"]
},
"content_scripts": [ {
"js": [ "bridge.js" ],
"matches": [
"https://*/tester"
]
} ],
"permissions": [
"desktopCapture",
"https://*/tester"
]
}
は、それは私のコードで何か間違っだろうか? デバッグで見つかったエラーを完全に理解していません
ありがとう!
編集:added manifest.jsonファイル!
'manifest.json'のような他の関連ファイルも用意してください。私たちが拡張機能を作成してデバッグを開始するのに役立ちますか? –
おっと!それを忘れてしまった! 唯一関連するファイルが見つからなかったのはmanifest.json – AbdulHamid
でした。実際には、ユーザーが共有ボタンをクリックした後、上記のコードを使用したいものについて明確ではありません。私は 'chrome.desktopCapture'の使用経験はありませんが、[this](https://github.com/wpp/ScreenStream)は役に立ちますか? –