2.2.8

Architecture

Last updated


This page shows how FlexPlyr is layered and which way each layer depends on the next, in a single overview diagram.

System Overview


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
  1. graph TB
  2. subgraph Load Phase
  3. MAIN["src/js/*.js"] --> HEAD[Inject head Assets]
  4. end
  5. subgraph Runtime Phase
  6. CFG[FPlyr Config] --> CORE[FPlyr Core]
  7. CORE --> SRC{Source Dispatch}
  8. SRC --> H5[HTML5 video / audio]
  9. SRC --> YT[YT.Player]
  10. SRC --> VM[Vimeo.Player]
  11. CORE --> PANEL[playerPanel]
  12. H5 & YT & VM --> STATE[State Handlers]
  13. STATE --> PANEL
  14. STATE --> WHEN[when Callbacks]
  15. end
  16. HEAD -.SDK.-> YT
  17. HEAD -.SDK.-> VM

Layers


LayerFileResponsibility
Bootstrapsrc/js/*.jsDeclares shared constants, detects isMobile/isIOS, and injects the stylesheet, icon font, and YouTube and Vimeo SDKs into <head>
Coresrc/js/model/player.jsThe FPlyr class: merges config, builds the container, initializes the source, and exposes one method set for all four sources
Control panelsrc/js/model/playerPanel.jsBuilds controls from panelItem and exposes update hooks such as setCurrent, setVolume, and show/hide
Helperssrc/js/function/*.jscreateElement (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.

Further Reading


Per-module diagrams, sequence diagrams, and the state machine live in doc/architecture.md.
中文