Is this a BUG in Mac or Canary?
I need to use the screen-capture via Google Canary, which was working before in past old versions.
But since they release Canary M37 or M39 its not working anymore. Is my --enable-usermedia-screen-capturing command invalid the way i am executing it?
$ alias canary="open /Applications/Google\ Chrome\ Canary.app/ --args --enable-usermedia-screen-capturing"
$ canary
Now when i try to start screen capture (which was working in old versions) its giving me error failing:
getUserMedia error: NavigatorUserMediaError {constraintName: "", message: "", name: "InvalidStateError"}
code:
function start() {
console.log("Requesting local stream");
btn1.disabled = true;
var video_constraints = {
audio: false,
video: {
mandatory: {
chromeMediaSource: 'screen',
maxWidth: 1024,
maxHeight: 768,
minWidth:800,
minHeight:400,
minFrameRate: 1,
maxFrameRate: 2,
//minAspectRatio: 1.333, maxAspectRatio: 1.334,
}
}
};
navigator.webkitGetUserMedia(video_constraints, function(stream){
console.log("Received local stream");
vid1.src = webkitURL.createObjectURL(stream);
localstream = stream;
}, function(e){
console.log("getUserMedia error: ", e);
});
}
EDIT:
<html>
<head>
<style>
body {
background: white;
display: -webkit-flex;
-webkit-justify-content: center;
-webkit-align-items: center;
-webkit-flex-direction: column;
}
video {
width: 640px;
height: 480px;
border: 1px solid #e2e2e2;
box-shadow: 0 1px 1px rgba(0,0,0,0.2);
}
</style>
</head>
<body>
<video id="video" autoplay></video>
<p><button id="start">Start</button><button id="cancel">Cancel</button></p>
<script>
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function gotStream(stream) {
console.log("Received local stream");
var video = document.querySelector("video");
video.src = URL.createObjectURL(stream);
localstream = stream;
stream.onended = function() { console.log("Ended"); };
}
function getUserMediaError() {
console.log("getUserMedia() failed.");
}
function onAccessApproved(id) {
if (!id) {
console.log("Access rejected.");
return;
}
navigator.webkitGetUserMedia({
audio:false,
video: { mandatory: { chromeMediaSource: "desktop",
chromeMediaSourceId: id } }
}, gotStream, getUserMediaError);
}
var pending_request_id = null;
document.querySelector('#start').addEventListener('click', function(e) {
pending_request_id = chrome.desktopCapture.chooseDesktopMedia(
["screen", "window"], onAccessApproved);
});
document.querySelector('#cancel').addEventListener('click', function(e) {
if (pending_request_id != null) {
chrome.desktopCapture.cancelChooseDesktopMedia(pending_request_id);
}
});
</script>
</body>
</html>