SDK reference

Methods

Every method on the player instance returned by Playgent.init(). Drive playback, swap content, and wire share.

js
const player = Playgent.init({ /* … */ });

Playback

player.play()

Resume from pause.

player.restart()

Reset to the cover screen.

player.hint()

Reveal the next hint. No-op if hints are disabled or exhausted.

player.openHowto()

Open the How to Play screen.

player.openArchive()

Open the past-games archive (requires the feature to be enabled on the player).

player.loadDate(date: string)

Jump to a specific date in daily mode. Format: YYYYMMDD.

js
player.loadDate("20260506");

Sound

player.mute() · player.unmute()

Toggle SFX/music. Persisted across the session for this iframe.

Loading & identity

player.load(opts?)

Reload the iframe with new config. Pass any subset of init options:

ts
player.load({
  game?: string;
  mode?: "pinned" | "daily" | "random";
  content?: string;
  theme?: string;
  language?: string;
  difficulty?: string;
  player?: string;
  // … any other init option
});

player.setIdentity({ externalUserId?, externalUsername? })

Update publisher-supplied identity at runtime. Pass null (or empty string) to clear.

js
player.setIdentity({ externalUserId: "u_42", externalUsername: "alice" });

Sharing

player.share(opts?)

Trigger Web Share API; falls back to clipboard when unavailable. Must be called from a user gesture.

ts
player.share(opts?: { text?: string }): Promise<void>

Returns the underlying Web Share / clipboard promise. Use text to override the templated shareText from the last complete event.

Listeners

player.on(eventName, fn) · player.off(eventName)

Attach or remove an event listener after init. Event names: "ready", "view", "start", "complete", "error".

js
player.on("complete", (data) => track(data));

Teardown

player.destroy()

Remove all listeners, stop in-view tracking, and remove the iframe from the DOM. Always call this when unmounting in SPAs.

Direct iframe access

player.iframe

The underlying HTMLIFrameElement. Use sparingly — for accessibility tweaks, custom styling, or framework-specific instrumentation.