Skip to main content
With no framework, Bunny Player comes down to one function. It appends the iframe and returns a player.js Player for talking to it.

JavaScript example on GitHub

A framework-free Vite app with custom controls and an event log.

Quickstart

1

Install player.js

player.js ships without types. Add a declaration file anywhere your tsconfig.json includes, for example player.js.d.ts. It covers the methods and events the Bunny Player supports:
player.js.d.ts
2

Create the player function

The Player has to exist before the iframe finishes loading. Creating both in one function takes care of the order.
src/bunny-player.ts
3

Mount it

src/main.ts
params takes any player parameter.

Control playback

Getters answer through a callback, since the value comes back from the iframe. Playback speed is missing from the npm build (0.1.0), and send() covers the gap:
Browsers block unmuted play() before the viewer has clicked anything. Mute first if playback has to start on its own. The Playback control API lists every method and event.

Track progress

timeupdate fires several times a second. Throttle it before it reaches your backend.
Pass the saved position back as params: { t: savedSeconds } to resume.

Use it without a bundler

We host a build of player.js that adds setPlaybackRate() and the playbackratechange event (Methods). Classic scripts run as the browser parses them, which puts both scripts ahead of the iframe’s load.

Troubleshooting

The iframe loaded before player.js was listening. Module and defer scripts run after parsing, by which time an iframe in the HTML may be done. Create the iframe from script, as createBunnyPlayer does.A hidden tab also holds ready back until the viewer switches to it.
Each Player adds a message listener to window that player.js never removes. Capture it by wrapping playerjs.addEvent while you construct the Player, then remove it with the iframe, as the React guide does.
The library’s allowed domains, direct access block, or token authentication is rejecting the embed. See Embedding restrictions.
Last modified on October 7, 2026