videojs-contextmenu-ui

7.0.0 • Public • Published

videojs-contextmenu-ui

Build Status Greenkeeper badge Slack Status

NPM

A cross-device context menu UI for video.js players.

Note: Versions 4.x and lower of this plugin depended on the videojs-contextmenu plugin, but that plugin is not included with it. It must be included separately.

Versions 5.x and newer does not use the videojs-contextmenu plugin, so do not include it. Versions 5.x and newer rely on the native contextmenu event.

Maintenance Status: Stable

Installation

npm install --save videojs-contextmenu-ui

Usage

The plugin is invoked as a method of a video.js Player object:

player.contextmenuUI();

Once the plugin is invoked, a modal will appear with a list of links when the contextmenu event is triggered on the Player object.

Options

Options may be passed to the plugin in a plain object:

player.contextmenuUI({
  content: [{

    // A plain old link.
    href: 'https://www.brightcove.com/',
    label: 'Brightcove'
  }, {

    // A link with a listener. Its `href` will automatically be `#`.
    label: 'Example Link',
    listener: function() {
      alert('you clicked the example link!');
    }
  }]
});

content

Required Type: Array

The plugin requires that content be passed as an array. If it is not, an error will be thrown. The array should contain any number of objects which define a series of links that appear in the modal. These objects support the following properties:

  • href: Defines the value of the href attribute of the generated link.
  • listener: A function which will be bound to the click event of the generated link.
  • label: Text for the link.

keepInside

Type: Boolean

If true (default), the context menu will be kept within the bounds of the player. If false, it may extend outside. When set to false, the menu would still stay within the player if the menu would otherwise extend outside the document body, including fullscreen players and players in an iframe.

excludeElements

Type: Function Parameters: The DOM element that is being targeted Returns: Boolean | Returns true if the targeted element should be excluded from displaying context menu

Defines which elements should be excluded from displaying the context menu. input and textarea elements are excluded by the default function.

player.contextmenuUI({
  ...
  excludeElements: (targetEl) => {
    const tagName = targetEl.tagName.toLowerCase();

    return tagName === 'input';
  }
});

Inclusion

To include videojs-contextmenu-ui on your website or web application, use any of the following 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-contextmenu-ui.min.js"></script>
<script>
  var player = videojs('my-video');

  player.contextmenuUI();
</script>

CommonJS/Browserify

When using with Browserify, install videojs-contextmenu-ui 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-contextmenu-ui');

var player = videojs('my-video');

player.contextmenuUI();

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-contextmenu-ui'], function(videojs) {
  var player = videojs('my-video');

  player.contextmenuUI();
});

License

Apache-2.0. Copyright (c) Brightcove, Inc.

Readme

Keywords

Package Sidebar

Install

npm i videojs-contextmenu-ui

Weekly Downloads

263

Version

7.0.0

License

Apache-2.0

Unpacked Size

125 kB

Total Files

20

Last publish

Collaborators

  • vmnavarro
  • dkingston
  • alfredo-reyes
  • jterranova
  • pradeep.vernekar
  • jfloresbc
  • mlopez.b
  • vasu.p
  • ttabrilla-bc
  • msivalls
  • sstevanus
  • rwbarber2
  • kaustubh-thube-brightcove
  • rwinger
  • bcc-bfranklin
  • apenigalapati
  • lmaultsby
  • sravan.pbr
  • agrojas-bc
  • ijunaidf
  • mgoncalves
  • mfregozo
  • arevelo
  • madhu_g
  • hugocjim
  • luisbacasehua
  • daniel_campos
  • kevin.schick
  • m.morrison
  • uomar
  • abarstowbc
  • sbarathan
  • kpandiyarajan
  • rburnham
  • imorones
  • walterseymourbc
  • ddashkevich
  • albertogomez
  • gestrada-br
  • amillerbrightcove
  • lvohra
  • mcho-bc
  • awaldron
  • fsalazarbc
  • dawnpacko
  • ldominguez
  • bc-srimron-soutter
  • rsilva_brightcove
  • joeylesh
  • lmelchorx1
  • juan-sanchez
  • eolvera
  • cloewer_bc
  • carredondo
  • brianhsu
  • niklagbrightcove
  • tsraveling_bc
  • bcbclifford
  • bc-acgarcia
  • adavila1
  • vaishalijayaraman
  • kreynolds
  • bgs-devops
  • albinjohnson
  • rtezera
  • bcmneil
  • randresf
  • v.kozlov_bc
  • nagendra_m
  • michaelmccarthybc
  • georgesanchez.diazjr
  • poneill-bcov
  • mdeltorobcov
  • jmohneycove
  • inbc01
  • aperezbrightcove
  • ireyes94
  • brightcove-admin
  • tedk
  • abradley-brightcove
  • bc-alive
  • lasanchezc
  • marguinbc
  • brightcove-user
  • kmason
  • cbarstow
  • hikeh
  • myerramalla
  • pdias
  • jwhisenant
  • ebertaud
  • oespinosac
  • dsalnikov
  • sharanya.muruganandam
  • vikaskumar.gajula
  • xgarcia_npm
  • jguerra
  • rjune
  • jonbwalsh
  • khaipham
  • wswanbeck
  • gastafurov
  • adalwani
  • ekelson-bcove
  • syseng
  • mcarreiro
  • elbadawimustafa
  • hwoodbury
  • jblaker
  • bcmauleon
  • paco_oblea_bc
  • jsepulveda
  • biswaranjan
  • barroyo
  • bmartinez
  • bc-jcarlson
  • eledezma
  • jcueto
  • erodrigues
  • psousa
  • acruzr
  • marcogaray
  • javibright
  • bcpsalas
  • etobin
  • ackbabe
  • cvillasenor
  • omartinez
  • mgonzalez_bc
  • pdohertybcov
  • muthukumar.bc
  • bzizmond
  • jmpmacedo
  • scorreia
  • lescorcio
  • cavieira
  • arunjeyaprasad
  • bvilvanathan
  • anand.gangadharan
  • rociosantos
  • agarciabcov
  • attinder
  • lauralopez
  • skumar85
  • hrodriguez2
  • jasilvaantonio
  • palvarezbc
  • ericramos
  • carlosabajo
  • ingrid.s.cruz
  • luis_fernando_lopez_ruiz
  • vishal64
  • tresa.baji
  • luis.garcia.brightcove
  • rodrigofdz
  • pgutierrezgil
  • harish17
  • jjeyaprakash
  • rrajendran1698
  • jlomeli
  • sjimenez
  • rwenger_brightcove
  • rujordan
  • stuartmh
  • jherrerabcov
  • mshiwal
  • ptamizh
  • akamalakkannan
  • roman-bc
  • tnwanna
  • bsahlas.npm
  • dherrera1109
  • hswaminathan
  • echengbc
  • sbarrettbc
  • misteroneill
  • gkatsev
  • brandonocasey
  • abarstow