Browse the knowledge hub
Player reference
Everything the <patchcut-player> web component and the embed iframe can do on your page. The player is the same either way: same video, same ads, same privacy rules. No viewer identity ever reaches your page.
Load the player
Add the script once per page, then one <patchcut-player> tag per video. Use the creator-scoped @handle/video-slug form so two creators with the same video name never clash.
The player sizes itself to 16:9 unless you set aspect. Give it a width with your own CSS; the height follows.
<script src="https://patchcut.com/api/public/v1/patchcut-player.v4.js" async></script>
<patchcut-player slug="@your-handle/launch-film" ref="session-42" aspect="auto"></patchcut-player>Attributes
Attributes you can set on the tag. Values the player would reject are dropped before the frame loads, so you see the same rules as the iframe. Changing slug or a playback setting reloads the frame; title, aspect and accent change in place.
| Attribute | What it does |
|---|---|
slug | Which video. Use @handle/video-slug; a bare video slug still works for older links. |
org | The creator's handle. Only needed with a bare slug; @handle/video-slug sets it for you. |
title | Name of the player frame for screen readers. Defaults to "PatchCut video". |
aspect | auto follows the video's shape (16:9, 9:16 or 1:1). A ratio such as 4/3 fixes it. Leave it out for 16:9. |
accent | One suggested colour (#rrggbb) for the player's controls. Applied only if it passes the contrast check. |
ref | Your own label for this view (for example a session id), echoed back in every event. Never put personal data in it. |
t | Start time in seconds. |
end | Stop time in seconds for a short moment (0.5–60 s after t). Playback stops there and returns to t; with loop=1 the moment repeats. Used for comment clips. |
v | Play an earlier release by number. Honoured only when the creator allows version history. |
pin | A pinned-embed code. Always plays that frozen release, never the live one. |
autoplay | 1 starts playing straight away. Browsers require autoplay to start muted. |
muted | 1 starts muted; 0 asks for sound (the browser may still mute it). |
ambient | 1 for showcase mode: silent autoplay, no centre play button, and a tap-to-unmute pill. |
loop | 1 plays the video on a loop. |
captions | 1 turns captions on at the start. |
controls | 0 hides the seek bar and toolbar. |
transport | 0 hides the centre play/pause button. |
share | 0 hides every share button and the share card. host keeps the buttons but hands sharing to your page: you get a sharerequest event (public url, title and at) and show your own share drawer. host needs the player embedded in your page; otherwise PatchCut's own share card is used. |
heatmap | 0 hides the viewer-interest curve above the seek bar. |
unmute | 0 hides the tap-to-unmute pill. |
hook | Preview loop: auto (default), manual (waits for startHook()) or 0 (poster only). |
hook_dwell | Seconds (0–30) the player must be on screen before an automatic preview loop starts. |
ads | 0 turns ads off. Honoured only on PatchCut Stream's own sites. |
npa | 1 asks for non-personalised ads, for viewers who haven't given consent. |
max_rating | A, G, M or R: the highest suitability rating this page allows. Anything above it (and anything not rated yet, under A or G) shows a notice instead of playing and sends the rating_restricted error. |
endslate | Set to off (or 0) to skip the end credits. On by default; credits only appear for public videos that declare them. |
endslate_dwell | Seconds each credits card stays up, from 1.5 to 8 (default 3). Other values are ignored. |
credit_links | Set to host to open credit links yourself from the creditopen event. Only honoured on PatchCut Stream; elsewhere links always open in a new tab. |
theater | Set to host to show a theater mode button (and the t shortcut) left of full screen. Your page resizes its own layout from the theatertoggle event. Off by default; hidden on small players and in full screen. |
Events
Listen with addEventListener. Every event's detail is the same patchcut:player v1 message the iframe sends (the Message column), so code written for the iframe can be reused.
Playback
| Event | Message | What it does |
|---|---|---|
ready | ready | Loaded and the length is known. detail.protocol and detail.commands list what this player supports. |
metadata | metadata | The video's shape and length: width, height, aspectRatio and duration. |
play | play | Playback started. |
pause | pause | Playback paused. |
seeked | seek | The playhead moved. |
timeupdate | timeupdate | Current time and whether it's playing. Only after subscribeTime(), about every 250 ms while the clock moves. |
progress | progress | Passed 25, 50, 75 or 90% (detail.milestone). |
heartbeat | heartbeat | Every 10 seconds while playing. |
complete | complete | Reached the end, or 95% watched. |
volumechange | media_state | Volume or mute changed: detail.volume and detail.muted. |
ratechange | media_state | Speed changed: detail.rate. |
error | error | The video can't play. detail.code is one of the error codes below. |
Preview loop
| Event | Message | What it does |
|---|---|---|
hookready | hook_ready | The preview loop is ready. |
hookstart | hook_started | The preview loop started. |
hookclick | hook_clicked | The viewer clicked the preview loop. |
Ads
| Event | Message | What it does |
|---|---|---|
adbreakstart | ad_break_started | An ad started. During a full ad break, seeking, speed, sound and the clipper are refused until it ends. |
adbreakend | ad_break_ended | The ad finished. |
adcard | ad_card_shown | A sponsor card was shown over the video. |
adnofill | ad_no_fill | An ad slot had no ad; the video carries on. |
Clipping and sign-in
| Event | Message | What it does |
|---|---|---|
clipperopen | clipper_opened | The clip panel opened. |
clip | clipper_saved | A signed-in viewer saved a clip. detail.clip has inSeconds, outSeconds and the saved ids. No labels or notes. |
clipperclose | clipper_closed | The clip panel closed. |
clipperunavailable | clipper_unavailable | This video can't be clipped: not public, an older or pinned release, or clipping is switched off. |
signedin | signed_in | The viewer signed in to the player. No identity is included. |
End credits
| Event | Message | What it does |
|---|---|---|
endslatestart | endslate_started | The video ended and the credits began. detail.endSlate.cards says how many cards there are. |
endslatecard | endslate_card | The viewer moved to another credits card (detail.endSlate.index and kind). |
endslateend | endslate_ended | The credits finished, were skipped or were cancelled by replaying or seeking (detail.endSlate.reason). |
creditopen | credit_opened | The viewer opened a credit. detail.credit has its public address, plus handle and slug for PatchCut videos. |
Theme
| Event | Message | What it does |
|---|---|---|
themechange | theme | Which accent applied: detail.accent, detail.accentSource (host, brand or default) and detail.refused. |
Layout
| Event | Message | What it does |
|---|---|---|
theatertoggle | theatertoggle | The viewer pressed the theater button or t. detail.active is the view they asked for; you change your layout. |
Clickable titles
| Event | Message | What it does |
|---|---|---|
overlayclick | overlay_clicked | The viewer clicked a clickable title. detail.overlay has its id and kind (link, jump or host), plus key for host actions, the verified url for links or at (seconds) for jumps. Host actions only reach you when embedded. |
Sharing
| Event | Message | What it does |
|---|---|---|
shareopen | share_opened | PatchCut's share card opened. detail.share.from says where: controls, credits, endcard or host (your openShare()). |
shareclose | share_closed | The share card closed. |
share | shared | The viewer shared: detail.share.channel is link, time (a link with a start time), embed or native (the device share sheet), and detail.share.url is the public address they shared. Nothing about who they are. |
sharerequest | share_requested | With share="host", the viewer pressed Share. Show your own share drawer: detail.share has the public url, title and at (seconds; 0 from the end screen, so the whole video is shared). |
Live broadcasts
| Event | Message | What it does |
|---|---|---|
livewaiting | live_waiting | A live broadcast hasn't started yet. |
livestart | live_started | The broadcast went live. |
livereconnecting | live_reconnecting | The broadcast lost its signal and is reconnecting. |
liveresume | live_resumed | The broadcast is back. |
liveend | live_ended | The broadcast ended. |
Everything
| Event | Message | What it does |
|---|---|---|
message | * | Every event above, under one name. |
Commands and properties
Every command returns a promise. It resolves with true once the player has done it, or rejects with an Error whose reason says why not (see the next section). Wait for ready before sending commands.
const player = document.querySelector("patchcut-player");
player.addEventListener("ready", async (e) => {
console.log(e.detail.protocol, e.detail.commands); // 4, ["play", "pause", ...]
try {
await player.setMuted(false); // may reject "needs_gesture": it keeps playing muted
} catch (err) { showMyUnmuteHint(err.reason); }
await player.subscribeTime(); // "timeupdate" about every 250 ms while playing
});
player.addEventListener("timeupdate", (e) => highlightTranscript(e.detail.time));
player.addEventListener("adbreakstart", () => disableMyTranscriptLinks());| Command | What it does |
|---|---|
play() | Start playback. The browser may start it muted. |
pause() | Pause playback. |
seek(seconds) | Move to a time in seconds. Refused during an ad break. |
setVolume(0–1) | Set the volume from 0 to 1. Refused during an ad break. |
setMuted(true | false) | Mute or unmute. Unmuting without a viewer tap rejects needs_gesture and the video keeps playing muted. |
setPlaybackRate(rate) | Speed: 0.5, 0.75, 1, 1.25, 1.5 or 2. Refused during an ad break. |
subscribeTime() | Start timeupdate events. Carries on if the frame reloads. |
unsubscribeTime() | Stop timeupdate events. |
openClipper({ inSeconds, outSeconds }?) | Pause and open the clip panel, optionally with a starting range. Refused during an ad break or when clipping isn't available. |
closeClipper() | Close the clip panel. |
openShare() | Pause and open PatchCut's share card, also with share="host". Rejects share_unavailable when sharing is off, and ad_break during an ad break. |
startHook() | Start the preview loop (for hook="manual"). |
stopHook() | Stop the preview loop. |
setAccent("#rrggbb" | null) | Suggest an accent colour, or null to clear it. Rejects low_contrast if it would be hard to see. |
setTheater(true | false) | Keep the theater button in step after you change layout yourself, for example on Esc. Needs theater="host" (otherwise rejects invalid) and never fires theatertoggle. |
Read-only state and shortcuts
| Property | What it does |
|---|---|
currentTime | Last reported time, in seconds. |
duration | Length in seconds. |
paused | Whether it's paused. |
inAdBreak | true during a full ad break (not sponsor cards). |
volume | Last reported volume (0–1). Setting it calls setVolume(). |
muted | Last reported mute state. Setting it calls setMuted(). |
playbackRate | Last reported speed. Setting it calls setPlaybackRate(). |
theaterActive | Last known theater state; setting it calls setTheater. |
metadata | { width, height, aspectRatio } once known, otherwise null. |
error | The last error code, or null. |
theme | { accent, source, refused } once the player reports it. |
capabilities | { protocol, commands } for the loaded script. |
Refusal reasons and error codes
A refusal means one command didn't happen; the video carries on. An error code (the error event) means the video can't play at all. Error codes never reveal whether a video was deleted or never existed.
| Reason | What it does |
|---|---|
ad_break | An ad break is playing. Seeking, speed, sound and the clipper wait until it ends. |
not_ready | The player hasn't finished loading. Wait for ready. |
clipping_unavailable | This video can't be clipped. |
invalid | The value is out of range or the command isn't recognised. |
needs_gesture | The browser needs a tap from the viewer before sound can play. The video carries on muted. |
low_contrast | The accent would be hard to see in this player's theme. The previous colour stays. |
share_unavailable | Sharing is off for this video or this embed (share=0, a private video or the creator turned it off). |
timeout | No answer within 4 seconds, for example because the frame was removed. |
Error codes
| Code | What it does |
|---|---|
unavailable | The video doesn't exist, was removed or isn't published. These are deliberately not told apart. |
private | The video is for members or needs a passphrase. The player shows its own unlock screen. |
rate_limited | Reserved for future use: too many attempts, try again later. Handle it now so your page is ready. |
not_live_yet | Reserved for future use. Today a scheduled broadcast sends livewaiting instead. |
playback_failed | Reserved for future use: the video loaded but couldn't play. Handle it now so your page is ready. |
rating_restricted | The video is rated above this page's max_rating (or isn't rated yet). The player shows a notice instead of playing. |
Theming
You can style the box around the player, never the controls or video inside it. Set --patchcut-radius and --patchcut-bg on the element, and style the iframe with ::part(frame).
You can also suggest one accent colour for the play button, progress bar and focus rings. It's used only if it stays clearly visible in the player's theme (4.5:1 for text on it, 3:1 against the player's surfaces). Otherwise the creator's brand colour, or PatchCut orange, stays and you're told why. Changing the accent never restarts the video.
<style>
patchcut-player { --patchcut-radius: 16px; --patchcut-bg: #111; }
patchcut-player::part(frame) { box-shadow: 0 8px 24px rgb(0 0 0 / .3); }
</style>
<patchcut-player slug="@your-handle/launch-film" accent="#2dd4bf"></patchcut-player>
<script>
const player = document.querySelector("patchcut-player");
player.addEventListener("themechange", (e) => console.log(e.detail.accentSource, e.detail.refused));
player.setAccent("#1d4ed8").catch((err) => console.log(err.reason)); // "low_contrast" on the dark player
</script>Viewer sign-in
Viewers sign in to clip from inside the player. On their tap, the browser is first asked whether the player may use their existing PatchCut sign-in; if not, a small PatchCut window opens on PatchCut's own address. Your page never handles a password, token, email or user id, and there's no way for a host to start or finish sign-in itself.
When it finishes you get a signedin event with no identity in it, so you can refresh your own interface.
player.addEventListener("signedin", () => {
// No token, email or user id is included. Refresh your own interface.
reloadMyCratesPanel();
});Using the iframe directly
Prefer a plain iframe? Send the same commands with postMessage to https://patchcut.com, and listen for patchcut:player messages from that origin. The player only accepts commands from its parent page at a known address.
Add an id (letters, numbers, - or _, up to 40 characters) to any command and the player answers with exactly one command_result message: ok, plus reason when refused. Volume and speed changes arrive as media_state messages.
const frame = document.querySelector("iframe");
const ORIGIN = "https://patchcut.com";
frame.contentWindow.postMessage(
{ source: "patchcut:command", v: 1, action: "setPlaybackRate", value: 1.5, id: "rate-1" },
ORIGIN,
);
window.addEventListener("message", (e) => {
if (e.origin !== ORIGIN || e.source !== frame.contentWindow) return;
if (e.data?.source !== "patchcut:player") return;
if (e.data.event === "command_result") console.log(e.data.id, e.data.ok, e.data.reason);
});| Action | Fields |
|---|---|
play | — |
pause | — |
seek | time |
startHook | — |
stopHook | — |
setVolume | value: 0–1 |
setMuted | value: boolean |
setPlaybackRate | value: 0.5 | 0.75 | 1 | 1.25 | 1.5 | 2 |
subscribeTime | — |
unsubscribeTime | — |
openClipper | inSeconds?, outSeconds? |
closeClipper | — |
setAccent | value: "#rrggbb" | null |
setTheater | value: boolean |
openShare | — |
Script versions
Load patchcut-player.v4.js to keep this exact contract: breaking changes ship under a new number, so your page can't break without you choosing to move. The plain patchcut-player.js address always serves the newest version. Both are free to load and need no key.
TypeScript definitions are at /api/public/v1/patchcut-player.d.ts. Reference them with a triple-slash reference, or copy the file into your types folder.
This page describes protocol 4. The ready event's detail.protocol tells you which version loaded.
Upgrading from an earlier version
play(), pause() and seek() now return promises. Existing calls still work, but add .catch() so a refused command (for example during an ad) doesn't show as an unhandled rejection.
@handle/video-slug now loads the creator's video correctly; earlier scripts could show nothing for this form. New in version 4: aspect, accent, the metadata, error, timeupdate, volumechange, ratechange, themechange and signedin events, and the volume, mute, speed, time-subscription and accent commands.