var id = //Chrome Extension ID;
var port = chrome.runtime.connect(id);
port.onMessage.addListener(function(msg) {
if (msg.stream) {
var video = document.querySelector("video");
video.src = window.URL.createObjectURL(msg.stream);
}
});
port.postMessage({video: video});
});
chrome.runtime.onConnectExternal.addListener(function(port) {
port.onMessage.addListener(function(msg) {
pending_request_id = chrome.desktopCapture.chooseDesktopMedia(["screen", "window"], function(id) {
if (!id) {
return;
}
navigator.webkitGetUserMedia({
audio:false,
video: { mandatory: { chromeMediaSource: "desktop", chromeMediaSourceId: id } }
}, function(stream) {
port.postMessage({stream: stream});
}, function() {
port.postMessage({stream: null});
});
});
});
});
--
---
You received this message because you are subscribed to a topic in the Google Groups "discuss-webrtc" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/discuss-webrtc/pHaZqLtDGY8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
chrome.tabs.query({
title: 'Example'
}, function(tabs){
if(!tabs.length){
response({error: "Need a tab open"});
}else{
var tab = tabs[0];
var pending_id = chrome.desktopCapture.chooseDesktopMedia(['screen'], tab, function(stream){
if(chrome.runtime.lastError){
console.log(chrome.runtime.lastError);
response({error: chrome.runtime.lastError});
}else if(!stream){
console.log('unkown error. no stream id');
response({error: 'No stream id'});
}else{
navigator.webkitGetUserMedia({
audio: false,
video: {
mandatory: {
chromeMediaSource: "desktop",
chromeMediaSourceId: stream,
maxWidth: window.screen.width,
maxHeight: window.screen.height
}
}
}, function(stream){
var src = URL.createObjectURL(stream);
response({error: false, src: src});
}, function(error){
console.log(error, chrome.runtime.lastError);
response({error: 'Could not get screen shot'});
});
}
});
}
});
...
&n