Non-Printable Material

    videojs-responsive-controls

    1.0.1 • Public • Published

    videojs-responsive-controls

    Adapts Video.js controls to different player sizes.

    Table of contents

    Installation

    npm install --save videojs-responsive-controls

    Basics

    Basic usage:

    import 'videojs-responsive-controls';
     
    player.responsiveControls({
        controls: {
          remainingTimeDisplay: { mini: false, small: false },
          'vjs-resolution-button': { mini: false },
          'vjs-language-container': { mini: false }
        }
    });

    Allows controlling both Video.js native plugins and legacy plugins (via their class names).

    Defaults

    Default breakpoints are:

    • mini: <450px,
    • small: <600px,
    • default: any higher resolution

    Default settings are:

    currentTimeDisplay: {
      mini: false,
    },
    timeDivider: {
      mini: false,
    },
    durationDisplay: {
      mini: false,
    },
    remainingTimeDisplay: {
      mini: false,
      small: false,
    },
    captionsButton: {
      mini: false,
    },
    

    Features

    Visible by default

    If user did not specified visibility for given plugin/breakpoint, and the visibility is also not specified in default settings - the plugin will be visible.

    Specifying own breakpoints

    You can specify own breakpoints like this:

    player.responsiveControls({
        sizes: {
            custom: 1024,
        },
        controls: {
            remainingTimeDisplay: { custom: false }
        }
    });

    Default breakpoints will be overwritten by this setting, therefore if you wish to use defaults too you'll have to specify default breakpoints along with your custom ones like so:

    player.responsiveControls({
        sizes: {
            mini: 450,
            small: 600,
            custom: 1024,
        },
        controls: {
            remainingTimeDisplay: { custom: false }
        }
    });

    Breakpoints are mobile-up so specified value is a maximum size video player can have to be affected by this breakpoint.

    To hide element by default use default breakpoint:

    player.responsiveControls({
        controls: {
            remainingTimeDisplay: { default: false, mini: true }
        }
    });

    Using with legacy plugins

    Legacy plugins does not register in videojs.controlBar space but you can still manage them throught this script passing class name in options, like this:

    player.responsiveControls({
        controls: {
            'vjs-language-container': { mini: false }
        }
    });

    Bundling with legacy systems

    To include videojs-responsive-controls on your website or web application, use any of the following legacy methods.

    <script> Tag

    This is the simplest case. Get the script in whatever way you prefer and include the plugin after you include video.js, so that the videojs global is available.

    <script src="//path/to/video.min.js"></script>
    <script src="//path/to/videojs-responsive-controls.min.js"></script>
    <script>
      var player = videojs('my-video');
     
      player.responsiveControls();
    </script> 

    Browserify/CommonJS

    When using with Browserify, install videojs-responsive-controls via npm and require the plugin as you would any other module.

    var videojs = require('video.js');
     
    // The actual plugin function is exported by this module, but it is also
    // attached to the `Player.prototype`; so, there is no need to assign it
    // to a variable.
    require('videojs-responsive-controls');
     
    var player = videojs('my-video');
     
    player.responsiveControls();

    RequireJS/AMD

    When using with RequireJS (or another AMD library), get the script in whatever way you prefer and require the plugin as you normally would:

    require(['video.js', 'videojs-responsive-controls'], function(videojs) {
      var player = videojs('my-video');
     
      player.responsiveControls();
    });

    License

    MIT. Copyright (c) Tomasz Janiczek <tjaniczek@twig-world.com>

    Install

    npm i videojs-responsive-controls

    DownloadsWeekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • adamoliver