Skip to main content
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.

Attributes
AttributeWhat it does
slugWhich video. Use @handle/video-slug; a bare video slug still works for older links.
orgThe creator's handle. Only needed with a bare slug; @handle/video-slug sets it for you.
titleName of the player frame for screen readers. Defaults to "PatchCut video".
aspectauto 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.
accentOne suggested colour (#rrggbb) for the player's controls. Applied only if it passes the contrast check.
refYour own label for this view (for example a session id), echoed back in every event. Never put personal data in it.
tStart time in seconds.
endStop 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.
vPlay an earlier release by number. Honoured only when the creator allows version history.
pinA pinned-embed code. Always plays that frozen release, never the live one.
autoplay1 starts playing straight away. Browsers require autoplay to start muted.
muted1 starts muted; 0 asks for sound (the browser may still mute it).
ambient1 for showcase mode: silent autoplay, no centre play button, and a tap-to-unmute pill.
loop1 plays the video on a loop.
captions1 turns captions on at the start.
controls0 hides the seek bar and toolbar.
transport0 hides the centre play/pause button.
share0 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.
heatmap0 hides the viewer-interest curve above the seek bar.
unmute0 hides the tap-to-unmute pill.
hookPreview loop: auto (default), manual (waits for startHook()) or 0 (poster only).
hook_dwellSeconds (0–30) the player must be on screen before an automatic preview loop starts.
ads0 turns ads off. Honoured only on PatchCut Stream's own sites.
npa1 asks for non-personalised ads, for viewers who haven't given consent.
max_ratingA, 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.
endslateSet to off (or 0) to skip the end credits. On by default; credits only appear for public videos that declare them.
endslate_dwellSeconds each credits card stays up, from 1.5 to 8 (default 3). Other values are ignored.
credit_linksSet to host to open credit links yourself from the creditopen event. Only honoured on PatchCut Stream; elsewhere links always open in a new tab.
theaterSet 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

Playback
EventMessageWhat it does
readyreadyLoaded and the length is known. detail.protocol and detail.commands list what this player supports.
metadatametadataThe video's shape and length: width, height, aspectRatio and duration.
playplayPlayback started.
pausepausePlayback paused.
seekedseekThe playhead moved.
timeupdatetimeupdateCurrent time and whether it's playing. Only after subscribeTime(), about every 250 ms while the clock moves.
progressprogressPassed 25, 50, 75 or 90% (detail.milestone).
heartbeatheartbeatEvery 10 seconds while playing.
completecompleteReached the end, or 95% watched.
volumechangemedia_stateVolume or mute changed: detail.volume and detail.muted.
ratechangemedia_stateSpeed changed: detail.rate.
errorerrorThe video can't play. detail.code is one of the error codes below.

Preview loop

Preview loop
EventMessageWhat it does
hookreadyhook_readyThe preview loop is ready.
hookstarthook_startedThe preview loop started.
hookclickhook_clickedThe viewer clicked the preview loop.

Ads

Ads
EventMessageWhat it does
adbreakstartad_break_startedAn ad started. During a full ad break, seeking, speed, sound and the clipper are refused until it ends.
adbreakendad_break_endedThe ad finished.
adcardad_card_shownA sponsor card was shown over the video.
adnofillad_no_fillAn ad slot had no ad; the video carries on.

Clipping and sign-in

Clipping and sign-in
EventMessageWhat it does
clipperopenclipper_openedThe clip panel opened.
clipclipper_savedA signed-in viewer saved a clip. detail.clip has inSeconds, outSeconds and the saved ids. No labels or notes.
clippercloseclipper_closedThe clip panel closed.
clipperunavailableclipper_unavailableThis video can't be clipped: not public, an older or pinned release, or clipping is switched off.
signedinsigned_inThe viewer signed in to the player. No identity is included.

End credits

End credits
EventMessageWhat it does
endslatestartendslate_startedThe video ended and the credits began. detail.endSlate.cards says how many cards there are.
endslatecardendslate_cardThe viewer moved to another credits card (detail.endSlate.index and kind).
endslateendendslate_endedThe credits finished, were skipped or were cancelled by replaying or seeking (detail.endSlate.reason).
creditopencredit_openedThe viewer opened a credit. detail.credit has its public address, plus handle and slug for PatchCut videos.

Theme

Theme
EventMessageWhat it does
themechangethemeWhich accent applied: detail.accent, detail.accentSource (host, brand or default) and detail.refused.

Layout

Layout
EventMessageWhat it does
theatertoggletheatertoggleThe viewer pressed the theater button or t. detail.active is the view they asked for; you change your layout.

Clickable titles

Clickable titles
EventMessageWhat it does
overlayclickoverlay_clickedThe 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

Sharing
EventMessageWhat it does
shareopenshare_openedPatchCut's share card opened. detail.share.from says where: controls, credits, endcard or host (your openShare()).
sharecloseshare_closedThe share card closed.
sharesharedThe 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.
sharerequestshare_requestedWith 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

Live broadcasts
EventMessageWhat it does
livewaitinglive_waitingA live broadcast hasn't started yet.
livestartlive_startedThe broadcast went live.
livereconnectinglive_reconnectingThe broadcast lost its signal and is reconnecting.
liveresumelive_resumedThe broadcast is back.
liveendlive_endedThe broadcast ended.

Everything

Everything
EventMessageWhat 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());
Commands and properties
CommandWhat 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

Read-only state and shortcuts
PropertyWhat it does
currentTimeLast reported time, in seconds.
durationLength in seconds.
pausedWhether it's paused.
inAdBreaktrue during a full ad break (not sponsor cards).
volumeLast reported volume (0–1). Setting it calls setVolume().
mutedLast reported mute state. Setting it calls setMuted().
playbackRateLast reported speed. Setting it calls setPlaybackRate().
theaterActiveLast known theater state; setting it calls setTheater.
metadata{ width, height, aspectRatio } once known, otherwise null.
errorThe 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.

Refusal reasons
ReasonWhat it does
ad_breakAn ad break is playing. Seeking, speed, sound and the clipper wait until it ends.
not_readyThe player hasn't finished loading. Wait for ready.
clipping_unavailableThis video can't be clipped.
invalidThe value is out of range or the command isn't recognised.
needs_gestureThe browser needs a tap from the viewer before sound can play. The video carries on muted.
low_contrastThe accent would be hard to see in this player's theme. The previous colour stays.
share_unavailableSharing is off for this video or this embed (share=0, a private video or the creator turned it off).
timeoutNo answer within 4 seconds, for example because the frame was removed.

Error codes

Error codes
CodeWhat it does
unavailableThe video doesn't exist, was removed or isn't published. These are deliberately not told apart.
privateThe video is for members or needs a passphrase. The player shows its own unlock screen.
rate_limitedReserved for future use: too many attempts, try again later. Handle it now so your page is ready.
not_live_yetReserved for future use. Today a scheduled broadcast sends livewaiting instead.
playback_failedReserved for future use: the video loaded but couldn't play. Handle it now so your page is ready.
rating_restrictedThe 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);
});
Iframe commands
ActionFields
play—
pause—
seektime
startHook—
stopHook—
setVolumevalue: 0–1
setMutedvalue: boolean
setPlaybackRatevalue: 0.5 | 0.75 | 1 | 1.25 | 1.5 | 2
subscribeTime—
unsubscribeTime—
openClipperinSeconds?, outSeconds?
closeClipper—
setAccentvalue: "#rrggbb" | null
setTheatervalue: 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.