On a website I have an iframe that loads my game (from another domain), I would like to capture and stream it. How can I achieve this? just the contents of this iframe as the user interact with it, not the entire screen or page.
Here's what I tried:
using getDisplayMedia()
from Chromium/Mozilla browser api,
adding feature-policy:
to the HTTP header and allow
attribute is what I thought would do the trick but what happened is that it just allows you to use the Screen Capture API which does not seem to support capturing the iframe contents as video.
second, I tried using iframe has allow='displaycapture'
but when I call getDisplayUserMedia()
the iframe does not show up.
My last ditched desperate attempt is a browser extension that can capture the iframe contents somehow as video stream but that seems tough since its not like the iframe screen output is being streamed as a binary somewhere deep inside the chromium engine.
viewportOffsetX
& co. constraints you could use to hack something around in order to capture only your iframe, if the user selects the correct tab, and the iframe is shown in screen... But if your game is made on a canvas, maybe it would be good enough to only stream this canvas content? This can be done easily. – Mangosteenawait navigator.mediaDevices.getSupportedConstraints()
. – MangosteengetDisplayMedia()
... if it could be called in a way to capture just an iframe, without the user having to choose the right thing, that'd be great. – Cerumen