Skip to content

Embed a work

Replace {id} with the work's id, the last part of its /e/ link (Share, then Embed, on any work links here with it filled in). Every embed shows the work's poster and preview and, on a computer, plays it right there in the page, with its credits, and tells its creator where it was seen; on a phone, Play opens it on Playspace in a new tab. Under it are the title, Made with Playspace and Report. After a play, and on the work's end card, it offers up to three other works from Playspace, each opening in a new tab.

1. The iframe

Works on any page that allows iframes. WordPress's automatic embeds can't run it; paste the embed code into a Custom HTML block instead.

<iframe src="https://www.joinplayspace.com/embed/{id}" width="720" height="437" style="border:0;max-width:100%" allow="autoplay; fullscreen" title="{title} on Playspace" loading="lazy"></iframe>

Keep allow="autoplay; fullscreen": it lets the work's sound start when the reader presses Play, and lets it go full screen. Without it the work plays silently, and full screen opens it on Playspace.

Every work is 16:9. The frame is 720 by 437: the work at 720 by 405 and a 32 px row under it. At another width, keep the height at the width times 9/16 plus 32, or use the web component, which does it for you.

2. The web component

embed.js sizes the frame to the column (16:9 plus the row under it) and loads it only when it comes near the screen. It adds one iframe and nothing else to your page.

<tinker-card id="{id}"></tinker-card>
<script async src="https://www.joinplayspace.com/embed.js"></script>

Or a single script tag, which puts the work right after itself:

<script async src="https://www.joinplayspace.com/embed.js" data-tinker-id="{id}"></script>

The component also takes width (the widest it gets, in pixels) and label (what screen readers call the frame). On the script tag, write each as data- plus its name.

3. Options

OptionValuesDefaultWhat it does
srcembed, oembed, wordpress, shopify, mcpembedWhich container framed it. oEmbed sets oembed; leave it alone otherwise.
muteon, offoffon: the work starts muted after the reader presses Play; the sound button turns it on.

A work's embed reads these two options, as ?mute=on on the iframe's address or mute="on" on the component. Anything else in the query, including the options of older snippets, is ignored and changes nothing.

4. Pages with a strict Content-Security-Policy

Allow our origin as a frame source:

frame-src https://www.joinplayspace.com;

and, if you use embed.js, as a script source too:

script-src https://www.joinplayspace.com;

Do not put a sandbox attribute on the iframe: the work cannot play inside a sandboxed frame, and on a phone Play opens it in a new tab, which a sandboxed frame blocks.

5. oEmbed

Editors that look up oEmbed can turn a pasted work link into the embed; which ones do is listed as it is checked, and WordPress's automatic embeds can't run it (paste the embed code into a Custom HTML block). Work links are discovered from the page; the endpoint is:

https://www.joinplayspace.com/oembed?url={url}&maxwidth={w}&maxheight={h}&format=json

It answers JSON with the iframe as HTML (never a script) for links like these:

https://www.joinplayspace.com/e/*
https://www.joinplayspace.com/h/*
https://www.joinplayspace.com/embed/*

Example:

https://www.joinplayspace.com/oembed?url=https%3A%2F%2Fwww.joinplayspace.com%2Fe%2F%7Bid%7D&format=json

What an embed records, and the rules for works: Privacy and Terms.