files/en-us/web/api/xrmediabinding/createquadlayer/index.md
{{APIRef("WebXR Device API")}}{{SeeCompatTable}}
The createQuadLayer() method of the {{domxref("XRMediaBinding")}} interface returns an {{domxref("XRQuadLayer")}} object which is a layer that takes up a flat rectangular space in the virtual environment.
createQuadLayer(video, options)
video
options
space is required:
height {{optional_inline}}
invertStereo {{optional_inline}}
false.layout {{optional_inline}}
default
mono
stereo
texture-array texture type for stereo layouts.stereo-left-right
stereo-top-bottom
mono.space Required
transform {{optional_inline}}
space.width {{optional_inline}}
An {{domxref("XRQuadLayer")}} object.
XRQuadLayer to display a videoCreate an {{domxref("XRMediaBinding")}} and use an {{domxref("HTMLVideoElement")}} that is passed into createQuadLayer(). Configure the quad layer using the options listed above and present the layer to the XR device by adding it to the layers render state in {{domxref("XRSession.updateRenderState()")}}.
function onXRSessionStarted(xrSession) {
const xrMediaBinding = new XRMediaBinding(xrSession);
const video = document.createElement("video");
video.src = "just-fascination.mp4";
const videoLayer = xrMediaBinding.createQuadLayer(video, {
space: xrReferenceSpace,
});
xrSession.updateRenderState({
layers: [videoLayer],
});
}
{{Specifications}}
{{Compat}}