gpt4 book ai didi

javascript - Google Canary - 在 Macbook Air OSX 10.9.4 上出现错误

转载 作者:行者123 更新时间:2023-11-29 16:11:45 25 4
gpt4 key购买 nike

这是 Mac 或 Canary 中的 BUG 吗?

我需要通过 Google Canary 使用屏幕捕获,这在过去的旧版本中是有效的。

但是自从他们发布 Canary M37 或 M39 后,它就不再工作了。我执行的 --enable-usermedia-screen-capturing 命令是否无效?

$ alias canary="open /Applications/Google\ Chrome\ Canary.app/ --args --enable-usermedia-screen-capturing"
$ canary

现在,当我尝试开始屏幕捕获(在旧版本中工作)时,它给我错误失败:

getUserMedia error:  NavigatorUserMediaError {constraintName: "", message: "", name: "InvalidStateError"}

代码:

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);
});
}

编辑:

<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>

最佳答案

在较新版本的 Chrome 中,这种类型的屏幕捕获已被弃用,我相信已将其删除。

This started with Chrome M36+ .

The new DesktopCapture API更好,并提供了更大范围的选择。

编辑:

新 API 仅在通过扩展使用时可用。 Chrome 团队表示,出于安全原因,这已被更改。可能在未来,它会被移回不需要构建扩展,但截至目前,它不能直接在页面中使用。

关于javascript - Google Canary - 在 Macbook Air OSX 10.9.4 上出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25763088/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com