Google Canary - 在Macbook Air OSX 10.9.4上出现错误 [英] Google Canary - on Macbook Air OSX 10.9.4 is giving error

查看:308
本文介绍了Google Canary - 在Macbook Air OSX 10.9.4上出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是Mac或Canary的BUG吗?



我需要通过Google Canary使用屏幕截图,Google Canary在之前的旧版本中使用过。 然而,自从发布Canary M37或M39后,它再也无法工作。我的--enable-usermedia-screen-capture命令无效,执行它的方式是什么?

  $ alias canary =open / Applications /谷歌Chrome浏览器Canary.app / --args --enable-usermedia屏幕截图
$ canary

现在,当我尝试开始屏幕截图(这是在旧版本中工作),它给了我错误失败:

  getUserMedia错误:NavigatorUserMediaError {constraintName:,message:,name:InvalidStateError} 

code:

 函数start(){
console.log(请求本地流);
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;


},函数(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 =videoautoplay>< / video>
< p>< button id =start>开始< / button>< button id =cancel>取消< / button>< / p>
< script>
//版权所有2013 The Chromium作者。版权所有。
//使用此源代码由BSD样式的许可证管理,该许可证可以是LICENSE文件中的
//。

函数gotStream(流){
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。);


函数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;
$ b 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>


解决方案

第1步 - 下载准备好的蛋糕,开始





https://stackoverflow.com/a/17098011



https://stackoverflow.com/a/17120647


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>

解决方案

Step 1 - download Ready made cake, to get started

https://developer.chrome.com/extensions/examples/api/desktopCapture.zip

Step 2 - RTFM

Load the extension
Extensions that you download from the Chrome Web Store are packaged up as .crx files, which is great for distribution, but not so great for development. Recognizing this, Chrome gives you a quick way of loading up your working directory for testing. Let's do that now.

Visit chrome://extensions in your browser (or open up the Chrome menu by clicking the icon to the far right of the Omnibox:  The menu's icon is three horizontal bars.. and select Extensions under the Tools menu to get to the same place).

Ensure that the Developer mode checkbox in the top right-hand corner is checked.

Click Load unpacked extension… to pop up a file-selection dialog.

Navigate to the directory in which your extension files live, and select it.

Alternatively, you can drag and drop the directory where your extension files live onto chrome://extensions in your browser to load it.

If the extension is valid, it'll be loaded up and active right away! If it's invalid, an error message will be displayed at the top of the page. Correct the error, and try again.

Step 3 - Launch the app

EDIT: References:

https://developer.chrome.com/extensions/manifest#web_accessible_resources

https://stackoverflow.com/a/17098011

https://stackoverflow.com/a/17120647

这篇关于Google Canary - 在Macbook Air OSX 10.9.4上出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆