Instance API
This page lists the public methods and properties of an FPlyr instance, plus the globals and ESM exports.
Methods
These methods branch on source flags that are set only at readiness, so calling them before when.ready fires, or synchronously inside ready, returns undefined and does not reach the media (see Lifecycle Events).
What destroy() Releases, in Order
- Removes the container's
mousemove/mouseleave handlers
- Stops the progress poll
- Vimeo/YouTube call the SDK's
destroy() (YouTube also destroys its fullscreen player); HTML5 media is paused and its src cleared
- Removes the container from the DOM
- Calls
when.destroyed if it is a function
Properties
Example
<div style="height: 240px"><div id="player"></div></div>
<button id="destroy">destroy()</button>
<script>
const player = new FPlyr({
id: "player",
video: "https://cdn.pixabay.com/video/2023/11/28/191159-889246512_tiny.mp4",
when: {
ready: () => setTimeout(() => {
console.log("isPaused:", player.isPaused());
console.log("isMuted:", player.isMuted());
console.log("option:", JSON.stringify(player.option));
}),
destroyed: () => console.log("destroyed, in DOM:", player.body.isConnected),
},
});
document.getElementById("destroy").onclick = () => player.destroy();
</script>
Live preview · @pardnchiu/flexplyr@2.2.9
Globals and Exports
import { FPlyr } from "@pardnchiu/flexplyr/dist/FlexPlyr.esm.js";
Related Pages