Re: [mediacapture-region] Why expose produceCropTarget at MediaDevices level? (#11)

> * (Window/MessagePort-from-Window object, element ID string): does not work in full generality, but is nice and simple and reuses existing primitives

Thanks @domenic, this is my winner. Avoids a new API & gets the id from iframe B to iframe A, which is all we need. KISS

const channel = new MessageChannel();
iframeA.contentWindow.postMessage(channel.port1, '*', [channel.port1]);
iframeB.contentWindow.postMessage(channel.port2, '*', [channel.port2]);

const element = document.getElementById("foo");
const {data: port} = await new Promise(r => window.onmessage = r);

const {data: port} = await new Promise(r => window.onmessage = r);
port.onmessage = async e => await track.cropTo(, {source: e.source});
postMessage here is a means to an end, so solving full generality feels like scope-creep.

> Another thing to consider is that the ID can refer to one element at a given point in time and to another one later on. This might make dynamic cropping easier ...

@youennf a live id feels like feature creep. Having `await cropTo(id)` resolve to a specific element seems POLA.

GitHub Notification of comment by jan-ivar
Please view or discuss this issue at using your GitHub account

Sent via github-notify-ml as configured in

Received on Thursday, 5 May 2022 23:26:07 UTC