桌面捕获铬插件 [英] Desktop capture chrome plugin

查看:162
本文介绍了桌面捕获铬插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个可以捕获桌面屏幕的chrome插件。我使用这里给出的示例插件示例...
https: //developer.chrome.com/extensions/samples#desktop-capture-example
但在这个例子中,当我们点击开始按钮时会弹出一个对话框,询问用户要分享哪个屏幕或窗口,但我想分享我的当前屏幕我在
这段代码中做了哪些修改

  //版权所有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]) ,onAccessApproved);
});

document.querySelector('#cancel')。addEventListener('click',function(e){
if(pending_request_id!= null){
chrome.desktopCapture.cancelChooseDesktopMedia (pending_request_id);
}
});

chromeMediaSourceId应该是什么值,以便默认选择是当前屏幕;



基本上我想避免这个屏幕..



Plz help ...
Regards

解决方案你不能这样做。清单许可允许您提供此功能,但用户仍然必须选择屏幕并点击共享。



与其他人一样,这是一项防止您的扩展的安全功能从触发这个而不通知用户。

I was developing a chrome plugin in which captures desktop screen. I am using the sample plugin example given here... https://developer.chrome.com/extensions/samples#desktop-capture-example But in this example as we click the start button a dialog pop ups which asks the user which screen or window to share but I want to share my current screen what changes do I make in this code

// 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"], onAccessApproved); 
 });

document.querySelector('#cancel').addEventListener('click', function(e) {
 if (pending_request_id != null) {
 chrome.desktopCapture.cancelChooseDesktopMedia(pending_request_id);
}
});

what should be the value of the chromeMediaSourceId so that the default selection is the current screen;

basically i want to avoid this screen ..

Plz help... Regards

解决方案

You can't do this. The manifest permission allows you to provide this feature but the user still has to select the screen and hit share.

Like others said, this is a security feature to prevent your extension from triggering this without informing the user.

这篇关于桌面捕获铬插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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