docs: Improve docs of desktopCapturer
This commit is contained in:
parent
51368952a2
commit
b517b0c598
1 changed files with 22 additions and 31 deletions
|
@ -1,11 +1,11 @@
|
||||||
# desktop-capturer
|
# desktopCapturer
|
||||||
|
|
||||||
The `desktop-capturer` is a renderer module used to capture the content of
|
The `desktopCapturer` module can be used to get available sources that can be
|
||||||
screen and individual app windows.
|
used to be captured with `getUserMedia`.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// In the renderer process.
|
// In the renderer process.
|
||||||
var desktopCapturer = require('desktop-capturer');
|
var desktopCapturer = require('electron').desktopCapturer;
|
||||||
|
|
||||||
desktopCapturer.getSources({types: ['window', 'screen']}, function(error, sources) {
|
desktopCapturer.getSources({types: ['window', 'screen']}, function(error, sources) {
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
@ -44,35 +44,26 @@ The `desktopCapturer` module has the following methods:
|
||||||
|
|
||||||
### `desktopCapturer.getSources(options, callback)`
|
### `desktopCapturer.getSources(options, callback)`
|
||||||
|
|
||||||
`options` Object, properties:
|
* `options` Object
|
||||||
* `types` Array - An array of String that enums the types of desktop sources.
|
* `types` Array - An array of String that lists the types of desktop sources
|
||||||
* `screen` String - Screen
|
to be captured, available types are `screen` and `window`.
|
||||||
* `window` String - Individual window
|
* `thumbnailSize` Object (optional) - The suggested size that thumbnail should
|
||||||
* `thumbnailSize` Object (optional) - The suggested size that thumbnail should
|
be scaled, it is `{width: 150, height: 150}` by default.
|
||||||
be scaled.
|
* `callback` Function
|
||||||
* `width` Integer - The width of thumbnail. By default, it is 150px.
|
|
||||||
* `height` Integer - The height of thumbnail. By default, it is 150px.
|
|
||||||
|
|
||||||
`callback` Function - `function(error, sources) {}`
|
Starts a request to get all desktop sources, `callback` will be called with
|
||||||
|
`callback(error, sources)` when the request is completed.
|
||||||
* `error` Error
|
|
||||||
* `sources` Array - An array of Source
|
|
||||||
|
|
||||||
Gets all desktop sources.
|
|
||||||
|
|
||||||
**Note:** There is no garuantee that the size of `source.thumbnail` is always
|
|
||||||
the same as the `thumnbailSize` in `options`. It also depends on the scale of
|
|
||||||
the screen or window.
|
|
||||||
|
|
||||||
## Source
|
|
||||||
|
|
||||||
`Source` is an object represents a captured screen or individual window. It has
|
|
||||||
following properties:
|
|
||||||
|
|
||||||
|
The `sources` is an array of `Source` objects, each `Source` represents a
|
||||||
|
captured screen or individual window, and has following properties:
|
||||||
* `id` String - The id of the captured window or screen used in
|
* `id` String - The id of the captured window or screen used in
|
||||||
`navigator.webkitGetUserMedia`. The format looks like 'window:XX' or
|
`navigator.webkitGetUserMedia`. The format looks like `window:XX` or
|
||||||
'screen:XX' where XX is a random generated number.
|
`screen:XX` where `XX` is a random generated number.
|
||||||
* `name` String - The descriped name of the capturing screen or window. If the
|
* `name` String - The described name of the capturing screen or window. If the
|
||||||
source is a screen, the name will be 'Entire Screen' or 'Screen <index>'; if
|
source is a screen, the name will be `Entire Screen` or `Screen <index>`; if
|
||||||
it is a window, the name will be the window's title.
|
it is a window, the name will be the window's title.
|
||||||
* `thumbnail` [NativeImage](NativeImage.md) - A thumbnail image.
|
* `thumbnail` [NativeImage](NativeImage.md) - A thumbnail image.
|
||||||
|
|
||||||
|
**Note:** There is no guarantee that the size of `source.thumbnail` is always
|
||||||
|
the same as the `thumnbailSize` in `options`. It also depends on the scale of
|
||||||
|
the screen or window.
|
||||||
|
|
Loading…
Reference in a new issue