Need help with openplayerjs?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

250 Stars 34 Forks MIT License 1.2K Commits 1 Opened issues


Lightweight HTML5 video/audio player with smooth controls and ability to play VAST/VPAID/VMAP ads

Services available


Need anything else?

Contributors list




Tweet JSDelivr Build Status Size Donate

This is a media player that uses all the goods of HTML5 video/audio elements to play the most popular media in MP4/MP3, HLS and M(PEG)-DASH, and also has the ability to play VMAP, VAST and VPAID ads.


  • Supports IE11+ (Win8) and all modern browsers.
  • No dependencies, since it is written in Typescript.
  • Runs a simple but yet powerful algorithm to check the browser's autoplay capabilities across browsers.
  • Supports for local and remote captions for both video and audio, even without including the
  • Enhance your player adding your own buttons. Check here for more details.
  • Provides the ability to use a single VAST/VPAID source or a VAST/VPAID playlist from several different sources (including URLs and valid XML strings).
  • Can play ads in infinite loop, desired for ads that are in a heavy text page.
  • Always responsive by default, for both video/audio tags; for video,
    modes are available to either scale and crop media relative to its parent container, or to attempt to make the media fit its parent container (including black bars), respectively.

:warning: IMPORTANT: Migrating from v1.x.x to v2.x.x :warning:

In order to achieve a smooth upgrading between version

, there is a couple of things to keep in mind:
  1. The player will only accept now 2 parameters instead of 4: the player ID and the player options.
  2. controls
    properties are now complex object structures, where we can indicate visibility and a new set of extra layers/visibility.

To simplify this even more:


const player = new OpenPlayerJS('player', 'https://ads.example.url/xml', true, {
    controls: {
        left: ['play', 'time', 'volume'],
        middle: ['progress'],
        right: ['captions', 'settings', 'fullscreen'],
    showLiveProgress: false,
    // ...other player options


const player = new OpenPlayerJS('player', {
    ads: {
        src: 'https://ads.example.url/xml', // equivalent to the second argument in v1.x.x
        // ...other ads options
    mode: 'fullscreen', // equivalent to `true` in third argument in v1.x.x
    controls: {
        alwaysVisible: false,
        // Also available: `top-left`, `top-middle`,
        // `top-right`, `bottom-left`, `bottom-middle` and `bottom-right` or `main`
        layers: {
            left: ['play', 'time', 'volume'],
            middle: ['progress'],
            right: ['captions', 'settings', 'fullscreen'],
    live: {
        showLabel: true,
        showProgress: false, // equivalent of `showLiveProgress` in v1.x.x
    // ...other player options

Getting Started

The standard template to start using OpenPlayerJS is show in the following snippet.

    <link rel="stylesheet" href="[email protected]/dist/openplayer.min.css">

    <video class="op-player__media" id="player" controls playsinline>
        <source src="/path/to/video.mp4" type="video/mp4">
        <track kind="subtitles" src="/path/to/video.vtt" srclang="en" label="English">
    <script src="[email protected]/dist/openplayer.min.js"></script>
        // Check the `API and events` link below for more options
        const player = new OpenPlayerJS('player');

Usage and API Guides

If you want to unleash the power of OpenPlayerJS, learn more about OpenPlayerJS by checking the following links.

Code Samples

In 2.x.x, the

folder is now removed in favor of code samples.

If you need a reference on how to use OpenPlayerJS in some of the most common scenarios, check the following links:

  1. No configuration (only DOM classes)
  2. Minimal configuration
  3. Using
  4. Using
  5. Using Ads (linear and non-linear samples)
  6. Removing controls and using
  7. Add source after initialization (useful for AJAX)
  8. Fully customized audio player
  9. Playing HLS streaming with DRM (Encryption)
  10. M(PEG)-DASH with Ads
  11. Basic playlist (video and audio)
  12. Ads playlist (multiple URLs)
  13. Retrieve data from audio streaming (HLS)
  14. YouTube video (using plugin)
  15. Addition of a custom control
  16. OpenPlayerJS with Next.js
  17. Using
    and setting width/height
  18. Trigger Ad manually
  19. Use FLV source (only modern browsers and Android, not iOS)
  20. Using hls.js p2p plugin

Built With


See also the list of contributors who participated in this project.


This project is licensed under the MIT License - see the file for details.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.