-
Notifications
You must be signed in to change notification settings - Fork 22.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editorial review: Add documentation for Screen Capture extensions, element capture and region capture #36939
Editorial review: Add documentation for Screen Capture extensions, element capture and region capture #36939
Conversation
mdn/mdn#580 could be close with this PR |
Cool, thanks for the heads-up @skyclouds2001. I'll update the description to mention it. |
…ls/content into region-and-element-capture
files/en-us/web/api/browsercapturemediastreamtrack/cropto/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/browsercapturemediastreamtrack/clone/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/screen_capture_extensions/element_region_capture/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/screen_capture_extensions/element_region_capture/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/screen_capture_extensions/element_region_capture/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/screen_capture_extensions/element_region_capture/index.md
Outdated
Show resolved
Hide resolved
files/en-us/web/api/screen_capture_extensions/element_region_capture/index.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % comment
files/en-us/web/api/screen_capture_extensions/element_region_capture/index.md
Outdated
Show resolved
Hide resolved
One kind of overall comment on this is that I think it would be better to present this as part of the Screen Capture API, not as an additional separate API. It's a similar case to https://github.com/orgs/mdn/discussions/683 and similar considerations apply. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are just comments on the guide, because I started there.
## Background | ||
|
||
The [Screen Capture API](/en-US/docs/Web/API/Screen_Capture_API) was created specifically to allow apps to capture the user's screen — or a particular window or tab — and then do something with the resulting stream (such as transmit it to multiple peers via [WebRTC](/en-US/docs/Web/API/WebRTC_API)). The main use case is video conferencing apps, where a user might wish to share a demo running on their local machine with other participants. | ||
|
||
The problem with the Screen Capture API is that, by default, it only allows you to broadcast the entire window, screen, or tab selected by the user. Often it would be preferrable to share only a limited region to cut down on unnecessary bandwidth or screen space required to show the capture, or for privacy reasons (you might not want to show other participants your message notifications, or background settings required to run the demo you are sharing). In addition, such apps generally capture your web cam output, meaning that you will likely end up with one of those undesirable "infinite wormhole" or "hall of mirrors" type effects. | ||
|
||
To solve such problems, extensions to the Screen Capture API were invented to allow you to restrict the captured stream to a particular subsection of the screen, window, or tab. | ||
|
||
In the next section we'll start with a basic Screen Capture API demo to illustrate the issues described above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section presents these features in a kind of temporal way:
- the SC API was invented
- it has some problems
- to solve them, some new extensions were added
I think this kind of story works for say a blog post about the new stuff but not so well for reference docs - in 2 years time noone is going to care about the story. It's better just to present the new features as features, and use the present tense, e.g.: "By default, the Screen Capture API captures an entire screen, window, or tab. The element capture and region capture extensions to the API enable you to restrict the captured stream to a specific rendered DOM tree, or to the part of the screen defined by a specific DOM tree's bounding box. This is useful when..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note also that if we do merge these APIs into the main SC API, I think we should stop capitalizing them, because they're not a title, they're not reified. They're more a part of another API, like we might talk about "how to stream requests", not "how to use the Request Streaming API".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call; I have cut down the background section as advised.
However, I'm not sure I should stop capitalizing "Region Capture API" and "Element Capture API" — they are defined in their own specs; they are standalone things. Those things just so happen to extend another API?
|
||
## Screen Capture API demo | ||
|
||
This demo uses the Screen Capture API to capture a window, screen, or tab, and broadcast the stream via a {{htmlelement("video")}} element on the same page. It also logs the track settings and constraints to a log container below the main app. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does logging the settings add anything to the tutorial? If not we should omit it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think you've probably got a point here. I just blindly copied it over when I made these demos based on the original demo on the Screen Capture API usage guide. It doesn't add anything; it just makes the demos more complicated than necessary.
I've removed the demo code in mdn/dom-examples#294. I'll remove it from these code blocks as well.
page-type: guide | ||
--- | ||
|
||
{{SeeCompatTable}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not appear in a guide page (there is no compat table to link)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D'oh! Good point; removed.
|
||
{{SeeCompatTable}} | ||
|
||
{{DefaultAPISidebar("Screen Capture extensions")}}{{securecontext_header}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{securecontext_header}} I think should also be omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
<pre id="log"></pre> | ||
``` | ||
|
||
### CSS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to go into the CSS. Apart from the video
rule, I don't think it is relevant, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've hidden most of it now, so the section is a lot shorter than it was. I still think it is worth talking about the couple of bits I'm showing here. They are relevant to the usage of the APIs themselves.
### Stopping the cropping | ||
|
||
You can stop the cropping by making a call to `cropTo()` on the same track, passing an argument of `null` to it: | ||
|
||
```js | ||
// Stop cropping | ||
await track.cropTo(null); | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again I'd consider excluding this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made into a note, as per previous comment.
await track.cropTo(null); | ||
``` | ||
|
||
### Issues with the Region Capture API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again "restrictions" feels better than "issues".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
- The element will not be cropped to if it is off-screen. | ||
- The element will not be cropped to if the track being cropped has clones or is not a track captured from the user's screen. | ||
- The element will not be captured if the `cropTarget` was created in a tab other than the one being captured. | ||
- Because Region Capture crops to an area of the current browser tab rather than capturing a specific element, any content drawn on top of the cropped area will be shown in the stream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider:
- The element will not be cropped to if it is off-screen. | |
- The element will not be cropped to if the track being cropped has clones or is not a track captured from the user's screen. | |
- The element will not be captured if the `cropTarget` was created in a tab other than the one being captured. | |
- Because Region Capture crops to an area of the current browser tab rather than capturing a specific element, any content drawn on top of the cropped area will be shown in the stream. | |
The element will not be cropped if any of the following conditions apply: | |
- It is off-screen. | |
- The track being cropped has clones or is not a track captured from the user's screen. | |
- The `cropTarget` was created in a tab other than the one being captured. | |
Because Region Capture crops to an area of the current browser tab rather than capturing a specific element, any content drawn on top of the cropped area will be shown in the stream. |
The fourth is not a condition. Same question about restriction 3 though - how is this possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There are legitimate use cases for both: | ||
|
||
- If you need to keep the capture specific to one DOM tree, and exclude anything outside it, then the Element Capture API is a better choice. For example, you don't want private content such as a set of message notifications or a speaker notes UI showing up in the capture. | ||
- However, if you really do want to capture a region of the browser tab, regardless of what is shown in it, the Region Capture API will serve you well. The [Region Capture Demo](https://region-capture-demo.glitch.me/) shows a useful possibility — zooming in on a particular area of the tab as you show multiple users an interactive walkthrough of some kind. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish I could see the source code for this example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source code link added
|
||
- [Screen Capture extensions](/en-US/docs/Web/API/Screen_Capture_extensions) | ||
- [Screen Capture API](/en-US/docs/Web/API/Screen_Capture_API) | ||
- [Element Capture Demo](https://element-capture-demo.glitch.me/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include the region capture demo here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments on the rest :).
|
||
The **`clone()`** method of the {{domxref("BrowserCaptureMediaStreamTrack")}} interface returns a clone of the original `BrowserCaptureMediaStreamTrack`. | ||
|
||
This method is functionally identical to {{domxref("MediaStreamTrack.clone()")}}, except that it handles cases where cropping or restriction have been applied to the track. The returned clone is identical to the original `BrowserCaptureMediaStreamTrack`, but with any cropping or restriction removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The guide page says:
The element will not be cropped to if the track being cropped has clones or is not a track captured from the user's screen.
Is there anything we should capture in this API page about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note added
- The track [`kind`](/en-US/docs/Web/API/MediaStreamTrack/kind) is not `"video"`, or its [`readyState`](/en-US/docs/Web/API/MediaStreamTrack/readyState) is not `"live"`. | ||
- The crop target element no longer exists. | ||
- The track being cropped has clones or is not a track captured from the user's screen. | ||
- `CropTarget` is not one of the values specified above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, that was really vague. I rewrote it to
CropTarget
is not a {{domxref("CropTarget")}} instance,null
, orundefined
.
- The crop target element no longer exists. | ||
- The track being cropped has clones or is not a track captured from the user's screen. | ||
- `CropTarget` is not one of the values specified above. | ||
- `CropTarget` was created in a tab other than the one being captured. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as in the guide page, how is this possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as other page; deleted!
- {{domxref("BrowserCaptureMediaStreamTrack.cropTo", "cropTo()")}} {{Experimental_Inline}} | ||
- : Crops a self-capture stream to the area in which a specified crop target element is rendered. | ||
- {{domxref("BrowserCaptureMediaStreamTrack.restrictTo", "restrictTo()")}} {{Experimental_Inline}} | ||
- : Restricts a self-capture stream to a specific rendered restriction target element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"a specific rendered restriction target element" is a mouthful. What do we lose if we just say "a specific part of the DOM"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing. Updated!
- The track [`kind`](/en-US/docs/Web/API/MediaStreamTrack/kind) is not `"video"`, or its [`readyState`](/en-US/docs/Web/API/MediaStreamTrack/readyState) is not `"live"`. | ||
- The restriction target element no longer exists. | ||
- The track being restricted has clones or is not a track captured from the user's screen. | ||
- `RestrictionTarget` is not one of the values specified above. | ||
- `RestrictionTarget` was created in a tab other than the one being captured. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar questions as for cropTo().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same updates made
- Be rendered (for example, not be off-screen or hidden via `display: none`). | ||
- Contain only one box fragment (for example, not be broken across multiple lines). | ||
|
||
If it does not meet the above criteria, it is considered to be **not eligible for restriction**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the element initially meets the requirements and then doesn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested it — when the capture is underway and the element that is being captured suddenly can no longer be captured (e.g. display: none
is set), no error is thrown, and the capture just freezes - it continues to show the last captured frame.
I guess this behavior might differ depending on how it became ineligible.
Do you think I need to mention this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I guess not. Weird though.
|
||
{{APIRef("Screen Capture extensions")}}{{SeeCompatTable}} | ||
|
||
The **`RestrictionTarget`** interface of the {{domxref("Screen Capture extensions", "Screen Capture extensions", "", "nocode")}} provides a static method, {{domxref("RestrictionTarget.fromElement_static", "fromElement()")}}, which returns a `RestrictionTarget` instance that can be used to restrict a captured video track to a specified DOM element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The **`RestrictionTarget`** interface of the {{domxref("Screen Capture extensions", "Screen Capture extensions", "", "nocode")}} provides a static method, {{domxref("RestrictionTarget.fromElement_static", "fromElement()")}}, which returns a `RestrictionTarget` instance that can be used to restrict a captured video track to a specified DOM element. | |
The **`RestrictionTarget`** interface of the {{domxref("Screen Capture extensions", "Screen Capture extensions", "", "nocode")}} provides a static method, {{domxref("RestrictionTarget.fromElement_static", "fromElement()")}}, which returns a `RestrictionTarget` instance that can be used to restrict a captured video track to a specified DOM element. |
The **`RestrictionTarget`** interface of the {{domxref("Screen Capture extensions", "Screen Capture extensions", "", "nocode")}} provides a static method, {{domxref("RestrictionTarget.fromElement_static", "fromElement()")}}, which returns a `RestrictionTarget` instance that can be used to restrict a captured video track to a specified DOM element. | |
The **`RestrictionTarget`** interface of the {{domxref("Screen Capture extensions", "Screen Capture extensions", "", "nocode")}} API provides a static method, {{domxref("RestrictionTarget.fromElement_static", "fromElement()")}}, which returns a `RestrictionTarget` instance that can be used to restrict a captured video track to a specified DOM element. |
(although of course see my other comment about not making this a standalone API...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved it all over to the Screen Capture, so this is all good now.
## Static methods | ||
|
||
- {{domxref("RestrictionTarget.fromElement_static", "fromElement()")}} {{Experimental_Inline}} | ||
- : Returns a `RestrictionTarget` instance that can be used to crop a captured video track to a specified DOM element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- : Returns a `RestrictionTarget` instance that can be used to crop a captured video track to a specified DOM element. | |
- : Returns a `RestrictionTarget` instance that can be used to restrict a captured video track to a specified DOM element. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
The Screen Capture API was created specifically to allow apps to capture the user's screen — or a particular window or tab — and then do something with the resulting stream (such as transmit it to multiple peers via [WebRTC](/en-US/docs/Web/API/WebRTC_API)). The main use case is video conferencing apps, where a user might wish to share a demo running on their local machine with other participants. | ||
|
||
The problem with the Screen Capture API is that, by default, it only allows you to broadcast the entire window, screen or tab selected by the user. Often it would be preferrable to share only a limited region to cut down on unnecessary bandwidth or screen space required to show the capture, or for privacy reasons (you might not want to show other participants your message notifications, or background settings required to run the demo you are sharing). | ||
|
||
The following Screen Capture API extensions provide mechanisms to limit the region captured in the stream: | ||
|
||
- The **Element Capture API** restricts the captured region to a specified rendered DOM element. | ||
- The **Region Capture API** crops the captured region to the area of the screen in which a specified DOM element is rendered. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comments to those about the "Background" bit of the guide, as this is similar content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This page no longer exists.
files/jsondata/GroupData.json
Outdated
"CropTarget", | ||
"RestrictionTarget" | ||
], | ||
"methods": ["MediaDevices.getDisplayMedia()"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is weird I think (and might cause weird problems) to include an item in two different APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this API entry no longer exists.
Thank you for the updates, Chris! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for those updates Chris! I just had a few more little bits.
} | ||
``` | ||
|
||
1. Here, we start by grabbing the media stream as before, using, `mediaDevices.getDisplayMedia()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Here, we start by grabbing the media stream as before, using, `mediaDevices.getDisplayMedia()`. | |
1. Here, we start by grabbing the media stream as before, using `mediaDevices.getDisplayMedia()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
|
||
A {{jsxref("Promise")}} that resolves to a {{domxref("CropTarget")}} object instance, which can then be passed to {{domxref("BrowserCaptureMediaStreamTrack.CropTo()")}} to crop the video captured in the track to just the area the specified DOM element is rendered in. | ||
|
||
`CropTarget` objects are serializable. They can be passed to another document using {{domxref("Window.postMessage()")}}, for example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry about this! But please see also #36939 (comment).
|
||
- The element will not be cropped to if the track being cropped has clones or is not a track captured from the user's screen. | ||
- The element will not be captured if the `cropTarget` was created in a tab other than the one being captured. | ||
- Because Region Capture crops to an area of the current browser tab rather than capturing a specific element, any content drawn on top of the cropped area will be shown in the stream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a restriction, so doesn't belong in the list. It's actually the key fact about the RC API, and I feel it is a little buried here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved these details to the CropTarget: fromElement() static method page, and put it as a standalone point in the page intro.
|
||
## When to use each API | ||
|
||
As explained above, Element Capture captures the element itself (and its descendants), whereas Region Capture captures the area of the browser tab defined by the bounding box of the target element. Element Capture will always show just the captured element, even if other DOM content overlaps it, whereas Region Capture can result in overlapping content being shown over the top of the content you intended to share. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As explained above, Element Capture captures the element itself (and its descendants), whereas Region Capture captures the area of the browser tab defined by the bounding box of the target element. Element Capture will always show just the captured element, even if other DOM content overlaps it, whereas Region Capture can result in overlapping content being shown over the top of the content you intended to share. | |
Element Capture captures the element itself (and its descendants), whereas Region Capture captures the area of the browser tab defined by the bounding box of the target element. Element Capture will always show just the captured element, even if other DOM content overlaps it, whereas Region Capture can result in overlapping content being shown over the top of the content you intended to share. |
(I don't think that phrase really adds anything, and it's a bit vague - where is it explained? It's fine to repeat key messages and we don't need to apologize for that :))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree. This bit got removed anyway, when I moved this section up to the top of the article. It really didn't make sense up there ;-)
|
||
## See also | ||
|
||
- [Screen Capture API](/en-US/docs/Web/API/Screen_Capture_API) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [Screen Capture API](/en-US/docs/Web/API/Screen_Capture_API) |
(don't need this link any more, we are already here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
|
||
## Screen Capture extension interfaces | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Screen Capture extension interfaces |
I think it is better just to present these as interfaces. I don't think anyone really cares that they are defined in a separate specification, at least not to the extent that it merits a separate top-level heading here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I've deleted the heading, and put the interfaces in a single list.
@@ -24,11 +31,29 @@ The {{jsxref("Promise")}} returned by `getDisplayMedia()` resolves to a {{domxre | |||
|
|||
See the article [Using the Screen Capture API](/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capture) for a more in-depth look at how to use the API to capture screen contents as a stream. | |||
|
|||
## Screen Capture extensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again I would not have this as a separate section. I think the developers this is just part of the SC API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, updated
> [!NOTE] | ||
> When attempting to crop a captured stream using {{domxref("BrowserCaptureMediaStreamTrack.cropTo", "cropTo()")}} or restrict it using {{domxref("BrowserCaptureMediaStreamTrack.restrictTo", "restrictTo()")}}, elements will not be cropped or restricted to if the track being captured has clones. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we instead say something like: "If a track has clones, its cropTo() and restrictTo() will reject with an error." I think this is clearer than "elements will not be cropped or restricted to".
Also I couldn't see a source for this in the specification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://developer.chrome.com/docs/web-platform/element-capture#restricting and https://developer.chrome.com/docs/web-platform/region-capture#cropping. I don't think it is in the spec, rather it is a current technical limitation they are trying to work around. But I'm not sure if it is helpful to separate this information out as a result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info! It's usually our practice to distinguish between restrictions that are intentional per spec and browser bugs, and I think we ought to do that here, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, done!
- Be rendered (for example, not be off-screen or hidden via `display: none`). | ||
- Contain only one box fragment (for example, not be broken across multiple lines). | ||
|
||
If it does not meet the above criteria, it is considered to be **not eligible for restriction**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I guess not. Weird though.
|
||
## The Region Capture API | ||
|
||
The Region Capture API has a very similar effect to the Element Capture API, except that rather than restricting the captured region to a specific rendered DOM tree, it crops the stream to the area of the current browser tab defined by the bounding box of the target element. Let's look at a demo and then explore the differences between the two in more detail later on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I'm suggesting this is that it's easier, cognitively, on the reader. Otherwise I'm thinking: here are 2 similar APIs, that have some unknown difference, and I have to keep that unanswered question in my head while I'm reading all the demo, until the "reveal" at the end. It's like a puzzle, where I have to work out what the difference is, then I get the answer at the end.
If I get the reveal at the start, then I know what the difference is, and the analysis/walkthrough is all just confirmation, I just nod as I read through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Chris for your patience as always! I'm approving this because it's 99% there and I don't want to block on another round of timezones. I do think it is worth separating out the "clones" limitation from those that are per-spec - for instance having a note like "Note than in Chromium, ... " and linking to the bug. But I don't think it's a blocker, and happy for you to merge either way.
Thanks so much @wbamberg for the thorough review. You've helped make this much better. I've moved the clone restriction info into notes in appropriate places as suggested. Time to merge! |
Description
Motivation
Chrome supports extensions to the Screen Capture API that allow developers to limit the region of the capture. Namely, these are:
This PR adds documentation for these APIs.
Additional details
Related issues and pull requests
Fixes mdn/mdn#580
dom-examples
addition: Add DOM examples for Screen Capture API dom-examples#285. The linked demos won't work until this PR is merged.