---
title: 'Flowplayer Native player API'
url: 'http://docs.flowplayer.com/player/player-api'
markdown: 'http://docs.flowplayer.com/player/player-api.md'
date: '2026-11-16'
description: 'Player API The Flowplayer Native player API is a JavaScript API that extends the HTML5 video object with a small set of its own properties, methods and event types. Most are for convenience and some extensions normalize the API so that it works consistently across browsers. Table …'
taxonomy:
  category:
    - documentation
  tag:
    - player
    - 'Flowplayer Native'
    - browser
    - API
    - interface
    - video
    - 'html5 video'
    - html5
    - mediaelement
    - 'media element'
  audience:
    - developer
---

# Player API

The Flowplayer Native player API is a JavaScript API that extends the HTML5 `video` object with a small set of its own properties, methods and event types. Most are for convenience and some extensions normalize the API so that it works consistently across browsers.

#### Table of contents

- [ Creating a Flowplayer instance ](#creating-a-flowplayer-instance)
- [ Using the API with OVP embeds ](#using-the-api-with-ovp-embeds)
- [ Properties ](#properties)
- [ Methods ](#methods)
- [ Events ](#events)
- [ Events reference ](#events-reference)
- [ Event names ](#event-names)
- [ Error handling ](#error-handling)
- [ Custom extensions ](#custom-extensions)
- [ Global object ](#global-object)

If you are using Flowplayer 7 please see the [Flowplayer 7 documentation](http://docs.flowplayer.com/player/flowplayer-7)

## Creating a Flowplayer instance

When using the JavaScript API, creating a Flowplayer instance is synchronous. The first argument is the selector or container you wish to have the Flowplayer instance live inside of, the second argument is the [configuration object](http://docs.flowplayer.com/player/configuration).

```js
// video is a real HTML5Video tag
var video = flowplayer('#player',
  { token : "keyboardcat"
  , src   : "cdn.example.com/video.mp4"
  })
```

## Using the API with OVP embeds

The JavaScript embed codes from Flowplayer OVP are [ESM embeds](http://docs.flowplayer.com/vod/publishing-videos#embed-a-video-using-javascript). The embed module loads the player, its plugins and the player configuration, and exports a `flowplayer()` function. Calling it creates the player synchronously and returns the player instance, so you can use the API right away.

For example, an OVP player embed looks similar to this:

- Flowplayer-hosted video source

```html
<div id="player-f576651c-4cc6-4664-84fa-bb3b35ef1aba"></div>
<script type="module">
  import flowplayer from "https://embed.flowplayer.com/c5ad8e31-7bbe-441a-8c29-eaeca03ac6e1/f576651c-4cc6-4664-84fa-bb3b35ef1aba.js";
  const video = flowplayer("#player-f576651c-4cc6-4664-84fa-bb3b35ef1aba", {});
  video.on("playing", () => console.log("flowplayer instance", video));
</script>
```

- Self-hosted video source

```html
<div id="player-1"></div>
<script type="module">
  import flowplayer from "https://embed.flowplayer.com/c5ad8e31-7bbe-441a-8c29-eaeca03ac6e1.js";
  const video = flowplayer("#player-1", {
    src: "//edge.flowplayer.org/bauhaus.m3u8"
  });
  video.on("playing", () => console.log("flowplayer instance", video));
</script>
```

### Legacy async embeds

Legacy async embeds, which use the deprecated cloud-hosted script `flowplayer.async.js`, load all Flowplayer libraries asynchronously in parallel and create the player automatically. Before you access the API of such a player, wait for the `flowplayer.cloud` [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) to make sure that all of the parallel loading is done:

```js
<script>
flowplayer.cloud.then(function() {
  // this is now the same synchronous environment
  // but we know all cloud assets are ready
  // since this was the target of the cloud loader
  // we just want a reference to the Flowplayer instance
  var video = flowplayer("#async-player")
  console.log('flowplayer instance', video);
});
</script>
```

Auto-initializing a cloud-hosted player can only happen on a tag that is not `<head>` or `<body>`

Async embeds intelligently detect if they are located in a container other than `<head>` and `<body>` to automatically create a Flowplayer instance. Adding a cloud hosted asset loader to a `<head>` or `<body>` tag will mean the loader will not automatically create the Flowplayer instances on resolving, since it is impossible to determine the best strategy in these setups.

This does not mean you cannot use the cloud-based player to manage configuration from the Platform, it just requires some special consideration. We have this [advanced cloud-based single-page application](https://github.com/flowplayer/advanced-demos/tree/master/demos/cloud-spa) as a demonstration of how to mix the two.

## Properties

Flowplayer extends the standard [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element), [HTMLMediaElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement) and [HTMLVideoElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement) objects with its own set of properties.

All Flowplayer specific properties are marked with an asterisk symbol (\*)

We won't touch the prototypes of the standard HTML "host objects". Only the individual DOM nodes are extended.

- - Property name
    - Description
- - currentSrc
    - Returns the absolute URL of the current video
- - currentTime
    - A float indicating the current playback time in seconds. Setting this value seeks the video to the new time.
- - disabled \*
    - A boolean specifying whether the player is disabled and the user cannot seek forward using the mouse or keyboard. Player is disabled and enabled with [toggleDisable()](#methods) method.
- - duration
    - Returns a float indicating the length of the video in seconds, or 0 if no video data is available.
- - ended
    - Returns a boolean flag that indicates whether the video element has finished playing.
- - muted
    - Returns a boolean flag that determines whether audio is muted. true if the audio is muted and false otherwise.
- - opts
    - A reference to the configuration state of the player.
- - paused
    - Returns a boolean flag that indicates whether the video element is paused.
- - playbackRate
    - You can control the speed of the playback with this property. A value larger than `1` will fast forward. A positive value smaller than `1` will play the video in slow motion.
- - poster
    - A URL to the poster image to show until the user plays (or seeks).
- - root \*
    - The root element of the video player. This is the immediate parent element of the video tag.
- - volume
    - A float indicating the audio volume, from 0.0 (silent) to 1.0 (loudest).
- - width
    - The width of the video's display area in pixels.

## Methods

- - play()
    - Begin video playback.
- - load()
    - loads the player/video (and makes metadata available for example)

## Events

Almost every API operation starts by listening to a player event — a specific action that happened during the existence of a player. For example when the playback starts or ends, when the player goes to fullscreen mode.

Flowplayer offers the `on` method to hook your event handlers to the player. It works as follows:

```js
// listen "seeking" and "seeked" events
video.on(['seeking', 'seeked'], function(e) {
  // e.type is the event type such as "seeking"
  var type = e.type
})

// or with a single event
video.on('seeked', function(e) { ... })
```

And since the API is a regular DOM object you can alternatively use your favorite UI library for events. Here's how you do the job with jQuery:

```js
// same as above, but with jQuery
$(video).on('seeking seeked', function(e) {
  // run your listener
})
```

Of course you can use the standard [addEventListener](//developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) call to register the listener, because our API is the actual `video` object. For example:

```js
video.addEventListener('ended', function() {
  // playback ended
})
```

Note that `addEventListener` accepts only a single event name, while the `on` listener can listen to multiple different event types.

## Events reference

List of the events emitted or used by Flowplayer. This list is not exhaustive, as all [Media Events](https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events) are available.

- - Event type
    - Description
- - fullscreenenter \*
    - Sent when player enters the fullscreen mode.
- - fullscreenexit \*
    - Sent when player leaves the fullscreen mode.
- - ended
    - Sent when playback completes.
- - error
    - Sent when an error occurs. Learn more about [error handling](#error-handling).
- - loadeddata
    - The first frame of the video has finished loading.
- - loadedmetadata
    - The video's metadata has finished loading; all attributes (like `HTMLVideoElement.duration`) now contain as much useful information as they're going to.
- - loadstart
    - Sent when loading of the video begins.
- - mount \*
    - Sent when the player interface is completely rendered and you can access all the elements with CSS and JavaScript. This event is only accessible inside of a [custom extension](#custom-extensions), due to the way mounting works.
- - pause
    - Sent when playback is paused.
- - playing
    - Sent when the video begins to play either for the first time, after having been paused, or after ending and then restarting.
- - progress
    - Sent periodically to inform of the video download progress. The download information can be found in the video's `buffered` attribute.
- - resize \*
    - Sent when the player dimensions are changed. This usually (but not necessarily) happens when the browser window is resized.
- - seeked
    - Sent when a seek operation completes.
- - seeking
    - Sent when a seek operation begins.
- - src \*
    - Sent right before the player `src` attribute is set. This allows you to change the video URL before the playback.
- - timeupdate
    - The time indicated by the element's `currentTime` attribute has changed.
- - viewenter \*
    - Sent when the player becomes visible for the user.
- - viewleave \*
    - Sent when the player leaves the user's viewport and is no longer visible.
- - volumechange
    - Sent when the audio volume changes both when the `volume` is set and when the `muted` attribute is changed.
- - waiting
    - Sent when video is waiting for the data to be downloaded from the server.
- - cuepoints \*
    - Sent when cuepoints are attached to the video, the attaching and parsing of cuepoints is possibly asynchronous depending on how they are registered, and this is the only safe way to interact with them. In the event of cuepoints being merged or changed (e.g. when changing the subtitle language), it is possible for this event to occur multiple times. *Deprecated in `flowplayer.events`, use `flowplayer.cuepoints.events.CUEPOINTS` from the [cuepoints plugin](http://docs.flowplayer.com/plugins/cuepoints).*
- - cuepointstart \*
    - Sent when a configured cuepoint is entered. \_Deprecated in `flowplayer.events`, use `flowplayer.cuepoints.events.CUEPOINT_START` from the [cuepoints plugin](http://docs.flowplayer.com/plugins/cuepoints).\_
- - cuepointend \*
    - Sent when a configured cuepoint is left. \_Deprecated in `flowplayer.events`, use `flowplayer.cuepoints.events.CUEPOINT_END` from the [cuepoints plugin](http://docs.flowplayer.com/plugins/cuepoints).\_
- - reap
    - Sent when a flowplayer instance is about to be removed from the DOM, and any unsafe references are about to be reaped, which allows Single Page Applications to perform the necessary resource cleanups. This is important when working with front-end frameworks like React. *This event should never be emitted directly, only listened to*

## Event names

All supported event names are listed in the `flowplayer.events` object for convenient access. You can, for example, use it to view and debug all the emitted events as follows

```js
video.on(Object.values(flowplayer.events), function(e) {
  console.info(e.type)
})
```

The `flowplayer.events` object contains the following public event names (events for internal use only are omitted). For events related to specific [plugins](http://docs.flowplayer.com/plugins/), see their documentation.

```js
{
  MOUNT: 'mount',
  RETRY: 'retry',
  ERROR: 'error',
  CONTEXT_MENU: 'contextmenu',
  CLICK: 'click',
  DBL_CLICK: 'dblclick',
  KEYUP: 'keyup',
  KEYDOWN: 'keydown',
  LOAD: 'load',
  MOUSE_ENTER: 'mouseenter',
  MOUSE_LEAVE: 'mouseleave',
  MOUSE_UP: 'mouseup',
  MOUSE_DOWN: 'mousedown',
  MOUSE_MOVE: 'mousemove',
  TOUCH_START: 'touchstart',
  TOUCH_MOVE: 'touchmove',
  TOUCH_END: 'touchend',
  TOUCH_CANCEL: 'touchcancel',
  RESIZE: 'resize',
  SCROLL: 'scroll',
  FULLSCREEN_ENTER: 'fullscreenenter',
  FULLSCREEN_EXIT: 'fullscreenexit',
  FULLSCREEN_CHANGE: 'fullscreenchange',
  METADATA: 'loadedmetadata',
  DATA: 'loadeddata',
  PROGRESS: 'progress',
  TIME_UPDATE: 'timeupdate',
  LOAD_START: 'loadstart',
  VOLUME_CHANGE: 'volumechange',
  PAUSE: 'pause',
  PLAYING: 'playing',
  PLAY: 'play',
  WAITING: 'waiting',
  CAN_PLAY: 'canplay',
  ENDED: 'ended',
  SEEKED: 'seeked',
  SEEKING: 'seeking',
  DURATION_CHANGE: 'durationchange',
  VIEW_ENTER: 'viewenter',
  VIEW_LEAVE: 'viewleave',
  SOURCE: 'src',
  REAP: 'reap',
  QUALITIES: 'qualities',
  QUALITY_CHANGE: 'qualitychange',
  VIDEO_TRACKS: 'videoTracks',
  VIDEO_TRACK_SELECT: 'tracks:video:select',
  LANDSCAPE: 'landscape',
  PORTRAIT: 'portrait',
  DVR: 'dvr',
  LIVE: 'live',
  RECOVER: 'recover',
  STANDARD_ERROR: 'flowplayer:error'
}
```

## Error handling

Playback errors are reported with the `flowplayer:error` event (`flowplayer.events.STANDARD_ERROR`). The native `error` event of the video element is mapped to this event as well. For example

```js
player.on(flowplayer.events.STANDARD_ERROR, function(e) {
  const error = e.detail.error
  console.info(error.flowplayerErrorCode, error.message)
})
```

`e.detail.error` is a `FlowplayerError` object with the following properties:

- `message` - a human readable description of the error
- `flowplayerErrorCode` - a string error code in the format `"01-02"`. The global `flowplayer.errors` object maps error names to these codes, for example `flowplayer.errors.MediaUnsupportedVideoFormat` is `"01-02"`
- `errorKey` - the name of the error code, for example `MediaUnsupportedVideoFormat`
- `isFatal` - whether the error stops playback

## Custom extensions

Flowplayer extensions are external JavaScript snippets with optional CSS that are automatically run for each player instance on a page.

An extension is a class whose instances implement an `init(opts, root, video)` method. Register the class with `flowplayer` like this:

```js
class MyExtension {
  init(opts, root, video) {

    // listen to the events and do your stuff
    video.on('ended', function() {
      // make voodoo
    })

  }
}

flowplayer(MyExtension)
```

Here's a demo that renders a custom mute button above the player:

 The `init` method is called for every flowplayer instance on the page right before the player is inserted (i.e. "mounted") on the page. Its arguments are

- `opts` is the configuration object and
- `root` is the root element of the player UI
- `video` is the HTMLVideoElement of the media

All extensions typically listen to the events and act on them.

Flowplayer itself is built as a list of extensions.

## Global object

The global `flowplayer` object has a set of properties and tools that are mainly targeted for plugin developers. For example

```js
// loop through all player instances on the page
flowplayer.instances.forEach(function(api) {
  console.info(api)
})
```

 [ From Flowplayer 7](http://docs.flowplayer.com/player/migration/fp7tonative) [ Plugins ](http://docs.flowplayer.com/plugins)

---

## Navigation

- Parent: [Flowplayer Native HTML5 video player](http://docs.flowplayer.com/player.md)
- Previous: [Flowplayer Native browser support](http://docs.flowplayer.com/player/browser-support.md)
- Next: [Flowplayer 7](http://docs.flowplayer.com/player/flowplayer-7.md)
