HTML and CSS structure

Introduction

Flowplayer Native renders its user interface as plain HTML inside the container element you pass to flowplayer(). All styling happens in CSS, so you can change almost anything about the player's look by writing CSS rules for the elements described on this page.

Use this page as a map when you skin the player. It shows the elements the player creates, how the default stylesheet lays them out, and which class names and states you can hook into.

Most UI elements are web components with tag names starting with flowplayer-. Each of them also carries a class name starting with fp-. Write your CSS against the fp- classes: they are stable, short, and the same ones the default stylesheet uses.

HTML layout

This is the HTML the player renders for a standard VOD player with no plugins loaded. Attributes the player updates continuously (sizes, ARIA values) are left out.

<!-- player root: your container element -->
<div id="player" class="flowplayer use-play-1 is-paused is-starting is-small">

  <!-- the video element -->
  <video class="fp-engine" playsinline></video>

  <!-- keeps the aspect ratio, default 16:9 -->
  <div class="fp-ratio" style="padding-top: 56.25%;"></div>

  <!-- logo, only filled if the logo option is set -->
  <flowplayer-logo class="fp-logo"></flowplayer-logo>

  <!-- title and description from the player configuration -->
  <div class="fp-footer">
    <div class="fp-title">Video title</div>
    <div class="fp-desc">Video description</div>
  </div>

  <!-- the user interface -->
  <flowplayer-ui class="fp-ui">

    <!-- top bar -->
    <flowplayer-header class="fp-header">
      <flowplayer-header-left-zone class="fp-left">
        <flowplayer-header-duration class="fp-duration"></flowplayer-header-duration>
      </flowplayer-header-left-zone>
      <flowplayer-header-right-zone class="fp-right fp-togglable">
        <flowplayer-fullscreen-enter-icon class="fp-icon fp-fullscreen" role="button"></flowplayer-fullscreen-enter-icon>
        <flowplayer-fullscreen-exit-icon class="fp-icon fp-fullscreen-exit" role="button"></flowplayer-fullscreen-exit-icon>
      </flowplayer-header-right-zone>
    </flowplayer-header>

    <!-- the area between header and controlbar -->
    <flowplayer-middle class="fp-middle">
      <!-- touch zone for seeking backward, shows the seconds skipped -->
      <flowplayer-middle-left-zone class="fp-left-zone">
        <span class="fp-zone-seconds"></span>
        <flowplayer-rewind-icon class="fp-icon fp-rewind"></flowplayer-rewind-icon>
      </flowplayer-middle-left-zone>

      <flowplayer-middle-zone class="fp-middle-zone">
        <!-- loading indicator -->
        <flowplayer-wait class="fp-wait"><b></b><b></b><b></b></flowplayer-wait>
        <!-- big play/pause button -->
        <flowplayer-middle-buttons class="fp-switch">
          <flowplayer-play-icon class="fp-icon fp-play" role="button"></flowplayer-play-icon>
          <flowplayer-pause-icon class="fp-icon fp-pause" role="button"></flowplayer-pause-icon>
        </flowplayer-middle-buttons>
      </flowplayer-middle-zone>

      <!-- touch zone for seeking forward -->
      <flowplayer-middle-right-zone class="fp-right-zone">
        <span class="fp-zone-seconds"></span>
        <flowplayer-fast-forward-icon class="fp-icon fp-fast-forward"></flowplayer-fast-forward-icon>
      </flowplayer-middle-right-zone>
    </flowplayer-middle>

    <!-- controlbar -->
    <flowplayer-control class="fp-controls fp-togglable">
      <!-- small play/pause button -->
      <flowplayer-control-buttons class="fp-btns fp-small-switch">
        <flowplayer-small-pause-icon class="fp-icon fp-small-pause" role="button"></flowplayer-small-pause-icon>
        <flowplayer-small-play-icon class="fp-icon fp-small-play" role="button"></flowplayer-small-play-icon>
      </flowplayer-control-buttons>

      <!-- live indicator, only shown for livestreams -->
      <flowplayer-live-status class="fp-live-status" role="button">
        <div class="fp-live-indicator fp-color"></div>
        <div class="fp-live-text"></div>
      </flowplayer-live-status>

      <!-- current playback time -->
      <flowplayer-elapsed-time class="fp-elapsed">00:00</flowplayer-elapsed-time>

      <!-- timeline -->
      <flowplayer-timeline-bar class="fp-timeline fp-bar" role="slider">
        <div class="fp-buffer"></div>
        <div class="fp-hover"></div>
        <div class="fp-progress fp-color"></div>
        <div class="fp-dragger fp-color"></div>
        <div class="fp-timestamp"></div>
      </flowplayer-timeline-bar>

      <!-- duration -->
      <flowplayer-control-duration class="fp-duration">00:52</flowplayer-control-duration>

      <!-- mute button and volume bar -->
      <flowplayer-volume-control class="fp-volume-control">
        <flowplayer-volume-icon class="fp-icon fp-volume-mute-unmute fp-volumebtn" role="button"></flowplayer-volume-icon>
        <flowplayer-volume-bar class="fp-volume" role="slider">
          <i class="fp-tick"></i><i class="fp-tick"></i><i class="fp-tick"></i>
          <!-- ... one fp-tick per volume step -->
        </flowplayer-volume-bar>
      </flowplayer-volume-control>
    </flowplayer-control>

    <!-- error message, only visible when an error occurs -->
    <flowplayer-error class="fp-error">
      <p class="error-message"></p>
      <p class="error-id"></p>
      <p class="error-key"></p>
    </flowplayer-error>
  </flowplayer-ui>
</div>

A few details to note:

  • The player adds the flowplayer class to your container. All other classes on the root are modifier classes you set yourself, or state classes the player sets during playback.
  • If your container already holds a <video> element, the player uses it instead of creating a new one.
  • The volume bar is not rendered on iOS, where the volume can only be changed with the device buttons.
  • Plugins add their own elements, for example menus for subtitles, quality selection or sharing in the header and the controlbar, or overlays like the endscreen. See plugin components for their tag names.

Element reference

[list-table width="1200" style="font-size: small;"]

    • Class
    • Element
    • Description
    • .flowplayer
    • your container
    • The player root. Carries modifier and state classes and sets the base font size.
    • .fp-engine
    • <video>
    • The video element. Covers the whole player area.
    • .fp-ratio
    • <div>
    • Spacer that gives the player its height from the aspect ratio (the ratio option or the video's own size).
    • .fp-logo
    • flowplayer-logo
    • The logo set with the logo option.
    • .fp-footer, .fp-title, .fp-desc
    • <div>
    • Title and description shown on the start screen.
    • .fp-ui
    • flowplayer-ui
    • Container for all controls. Covers the whole player area on top of the video.
    • .fp-header
    • flowplayer-header
    • Top bar, split into .fp-left and .fp-right.
    • .fp-middle
    • flowplayer-middle
    • Click and touch area between header and controlbar. Holds the touch seek zones .fp-left-zone / .fp-right-zone and the .fp-middle-zone with the loading indicator .fp-wait and the big play/pause button .fp-switch.
    • .fp-controls
    • flowplayer-control
    • Controlbar.
    • .fp-timeline
    • flowplayer-timeline-bar
    • Timeline with buffer (.fp-buffer), hover (.fp-hover) and progress (.fp-progress) bars, the drag handle (.fp-dragger) and the time tooltip (.fp-timestamp).
    • .fp-volume-control
    • flowplayer-volume-control
    • Mute button (.fp-volume-mute-unmute) and volume bar (.fp-volume, made of .fp-tick elements).
    • .fp-icon
    • all icon components
    • Every icon button. The icon itself is a CSS background image taken from a CSS variable.
    • .fp-color
    • several
    • Elements painted in the brand color, for example the timeline progress and the drag handle.
    • .fp-error
    • flowplayer-error
    • Error message view. [/list-table]

How the CSS is organized

The default stylesheet flowplayer.css is built in layers. Knowing them helps you decide where to hook in:

  1. CSS variables on :root: the brand color --fp-brand-color and all icons (--fp-play-icon, --fp-fs-icon and so on). Change these first, they cover the most ground with the least code.
  2. Base layout for the root and the UI regions described below.
  3. Modifier classes such as use-thin-controlbar or logo-on-right, which you set on the container.
  4. State classes such as is-paused or is-fullscreen, which the player sets.
  5. Plugin styles for menus, ads, subtitles and other plugin elements.

Sizing

All sizes in the player are set in em, relative to the font size of the root element. The root uses 16px by default, 14px when the player has the is-small class and 12px with is-tiny. A narrow player therefore shrinks all its controls at once.

Spacing uses the --spacing variable (0.9em). Header and controlbar are four times --spacing high.

Follow the same approach in your own CSS: size elements in em or with --spacing and they will scale together with the rest of the player.

Layout

  • .fp-engine and .fp-ui are positioned absolutely and cover the whole player. The UI sits on top of the video.
  • .fp-ui is a vertical flexbox: .fp-header at the top, .fp-middle taking all remaining space, .fp-controls at the bottom.
  • .fp-controls is a horizontal flexbox. The timeline grows to fill the space the other elements leave free.
  • .fp-middle is a horizontal flexbox of three zones: the touch seek zones on the left and right, and the middle zone with the play button in the center.

Because header, controlbar and middle area are flexboxes, hidden elements leave no gap: the remaining elements move up automatically.

Visibility of the controls

The header right zone and the controlbar carry the .fp-togglable class. They are hidden (opacity: 0) while the video plays and become visible when one of these state classes is set on the root:

  • is-hovered: the mouse moves over the player (the class is removed after two seconds without movement)
  • is-paused
  • is-touched: a tap on touch devices
  • is-kb-active: keyboard use
  • has-menu-opened: a plugin menu is open

On touch devices the hidden controls also get visibility: hidden, so they cannot be tapped by accident.

The big play and pause buttons are hidden by setting their width and height to 0, not with display: none. Do not change their width or height in your CSS, or both buttons show up at the same time. To make them bigger or smaller, use transform: scale() on .fp-middle .fp-play and .fp-middle .fp-pause.

State classes

The player sets state classes on the root element during playback, for example is-playing, is-paused, is-seeking, is-fullscreen, is-live or is-small. Combine them with element classes to style the player differently in each state. See the list of player states.

Changing the layout

Hiding elements

Hide elements with CSS. This rule hides the elapsed time and the duration in the controlbar:

.flowplayer .fp-controls .fp-elapsed,
.flowplayer .fp-controls .fp-duration {
  display: none;
}

The other elements of the controlbar close the gap automatically.

Some elements have their own modifier class or UI option, for example no-controls, no-header or no-title. Prefer those where they exist: they also adjust the surrounding layout.

Adding elements

You can place your own elements inside the player container, for example a banner or a custom button. To stay clickable, they must be stacked above the player UI:

<div id="player">
  <a class="my-banner" href="https://example.com">Visit our shop</a>
</div>
.flowplayer .my-banner {
  position: absolute;
  top: 1em;
  left: 1em;
  z-index: 2;
}

To add, replace or rearrange controls inside the header, the middle area or the controlbar, replace the corresponding web component instead of moving the player's own elements with JavaScript. The player keeps references to its elements and attaches its event handling to them, so moving them around from outside is fragile.

Results