# FlexPlyr > FlexPlyr is a JavaScript video player library by Pardn Chiu (邱敬幃): one API drives HTML5 video and audio, the YouTube player, and Vimeo, with themed panels. Every documentation page in navigation order; each section starts with its source URL. --- Source: https://flexplyr.pardn.io/index.md > [!NOTE] > This README was generated by [SKILL](https://github.com/agenvoy/skill-readme-generate), get the ZH version from [here](https://github.com/pardnchiu/FlexPlyr/blob/main/doc/README.zh.md). > [!WARNING] > **Archived on 2026-10-30.** FlexPlyr is no longer maintained. The final release is `v2.2.9`; `npm i @pardnchiu/flexplyr` and the jsDelivr build remain available, but no new features, bug fixes, or security updates will be published, and issues and pull requests are no longer accepted. ***

ONE PLAYER API FOR HTML5, YOUTUBE AND VIMEO

npm Downloads License

*** > A JavaScript player library with unified HTML5/YouTube/Vimeo sources, themed control panels, and lifecycle events ## Table of Contents - [Features](#features) - [Architecture](#architecture) - [License](#license) - [Author](#author) ## Features > `npm i @pardnchiu/flexplyr` · [Documentation](https://github.com/pardnchiu/FlexPlyr/blob/main/doc/doc.md) - **Four sources, one interface** — A single `FPlyr` config object drives HTML5 video, audio, YouTube, and Vimeo, so play, pause, volume, and speed behave identically for the caller. - **Four composable panel themes** — Minimal, Classic, Retro, and Simple panels ship built in, and eight control items can be picked and ordered freely. - **One script tag to go live** — On load it injects the stylesheet, Material Symbols icons, and the YouTube/Vimeo SDKs, so no build step or extra includes are needed. - **Full lifecycle events** — Five callbacks (`ready`, `playing`, `pause`, `end`, `destroyed`) make it easy to hook in external logic and clean up resources. - **Synced mobile fullscreen** — A hidden dedicated fullscreen player takes over on mobile and syncs progress, volume, and speed on entry and exit. ## Architecture > [Full Architecture](https://github.com/pardnchiu/FlexPlyr/blob/main/doc/architecture.md) ```mermaid graph TB A[FPlyr Config] --> B[FPlyr Core] H[Head Assets Injected on Load] -.-> B B --> C[Source Dispatch] C --> D[HTML5 video / audio] C --> E[YouTube IFrame API] C --> F[Vimeo Player API] B --> G[playerPanel Controls] D & E & F --> I[State Handlers] I --> G I --> J[when Lifecycle Callbacks] ``` ## License This project is licensed under the [MIT LICENSE](https://github.com/pardnchiu/FlexPlyr/blob/main/LICENSE). ## Author Just [open an issue](https://github.com/pardnchiu/FlexPlyr/issues/new) to share an idea. FlexPlyr contributors *** ©️ 2024 [邱敬幃 Pardn Chiu](https://www.linkedin.com/in/pardnchiu) --- Source: https://flexplyr.pardn.io/getting-started.md # Getting Started This page covers loading FlexPlyr, mounting your first player, and calling its methods once it is ready. ## Prerequisites - A modern browser that supports ES2022 private fields (`#field`) and CSS `:has()` - Network access to `cdn.jsdelivr.net`, `fonts.googleapis.com`, `www.youtube.com`, and `player.vimeo.com` (see [Runtime Dependencies](/runtime-dependencies)) - Browser-only: the module touches `document` and `navigator` as soon as it loads ## Installation ### jsDelivr CDN ```html ``` The global `FPlyr` is available once the script loads. ### npm ```bash npm i @pardnchiu/flexplyr ``` ```javascript import { FPlyr } from "@pardnchiu/flexplyr/dist/FlexPlyr.esm.js"; ``` `main` in `package.json` points to `dist/FlexPlyr.js` (a non-module build that sets `window.FPlyr`); import `dist/FlexPlyr.esm.js` for the named export. ## Your First Player Pass the `id` of an existing element and one media source. The player turns that element into the `.FPlyr` container, which fills its parent, so the parent needs a height. ```demo
``` ## Call Methods After ready `when.ready` fires **before** the player sets its internal source flags (`src/js/model/player.js:395`), so calling `isPaused()`, `isMuted()`, or `play()` synchronously inside `ready` returns `undefined` or does nothing. Defer the call to the next task (for example with `setTimeout`) to get correct results; see [Lifecycle Events](/lifecycle-events). ## Next Steps - [Media Sources](/media-sources): switch to YouTube, Vimeo, or audio - [Panel Themes](/panel-themes) and [Panel Controls](/panel-controls): change the look and the buttons - [Configuration](/configuration): every constructor option --- Source: https://flexplyr.pardn.io/architecture.md # Architecture This page shows how FlexPlyr is layered and which way each layer depends on the next, in a single overview diagram. ## System Overview ```mermaid graph TB subgraph Load Phase MAIN["src/js/*.js"] --> HEAD[Inject head Assets] end subgraph Runtime Phase CFG[FPlyr Config] --> CORE[FPlyr Core] CORE --> SRC{Source Dispatch} SRC --> H5[HTML5 video / audio] SRC --> YT[YT.Player] SRC --> VM[Vimeo.Player] CORE --> PANEL[playerPanel] H5 & YT & VM --> STATE[State Handlers] STATE --> PANEL STATE --> WHEN[when Callbacks] end HEAD -.SDK.-> YT HEAD -.SDK.-> VM ``` ## Layers | Layer | File | Responsibility | |-------|------|----------------| | Bootstrap | `src/js/*.js` | Declares shared constants, detects `isMobile`/`isIOS`, and injects the stylesheet, icon font, and YouTube and Vimeo SDKs into `` | | Core | `src/js/model/player.js` | The `FPlyr` class: merges config, builds the container, initializes the source, and exposes one method set for all four sources | | Control panel | `src/js/model/playerPanel.js` | Builds controls from `panelItem` and exposes update hooks such as `setCurrent`, `setVolume`, and `show`/`hide` | | Helpers | `src/js/function/*.js` | `createElement` (builds elements from `tag#id.class`), `UUID` (YouTube container IDs), `getTime` (time formatting) | The bootstrap file is literally named `*.js`, and the `terser` build globs (`src/js/*.js src/js/**/*.js`) concatenate it with every other source file into `dist/`. The `FPlyr` and `playerPanel` classes live in `src/js/model`. `src/js/model/videoPlayer.js` is bundled into `dist/`, but nothing references it. ## Cross-Cutting Principles - **Source differences live only in the core**: every operation (play, seek, volume, speed) branches on `#isVideo`/`#isAudio`/`#isYoutube`/`#isVimeo`, so the panel and `when` callbacks never need to know the source type. - **State is event-driven**: panel icons and progress update only from source events (`playing`, `pause`, `ended`) and a 100 ms poll, never directly from button clicks. - **Mobile fullscreen uses a second player**: see [Mobile Fullscreen](/mobile-fullscreen). ## Further Reading Per-module diagrams, sequence diagrams, and the state machine live in [doc/architecture.md](https://github.com/pardnchiu/FlexPlyr/blob/main/doc/architecture.md). --- Source: https://flexplyr.pardn.io/media-sources.md # Media Sources This page covers the four media sources FlexPlyr supports, which one wins when several are set, and why YouTube and Vimeo players must wait for their SDKs. ## The Four Sources | Config field | Value | Underlying player | Notes | |--------------|-------|-------------------|-------| | `video` | Video URL | `