项目作者: joaopaulovieira

项目描述 :
A context menu for Clappr player.
高级语言: JavaScript
项目地址: git://github.com/joaopaulovieira/clappr-context-menu-plugin.git
创建时间: 2017-04-27T15:52:12Z
项目社区:https://github.com/joaopaulovieira/clappr-context-menu-plugin

开源协议:BSD 3-Clause "New" or "Revised" License

下载





npm bundle size
Travis (.com)
Coveralls github

Clappr context menu plugin

screenshot

Demo

https://joaopaulovieira.github.io/clappr-context-menu-plugin/

Table of Contents

Features

  • Default actions:
    • Copy URL of the site where Clappr is playing;
    • Copy URL with the current time of the video;
    • Enable/Disable loop state;
  • Default info:
    • Clappr version;
  • Support to add new custom actions;
  • Support to add custom style;

Usage

You can use it from JSDelivr:

  1. https://cdn.jsdelivr.net/npm/clappr-context-menu-plugin@latest/dist/clappr-context-menu-plugin.min.js
  1. # Using yarn
  2. yarn add clappr-context-menu-plugin
  3. # Using npm
  4. npm i clappr-context-menu-plugin

Then just add ContextMenuPlugin into the list of plugins of your player instance

  1. var player = new Clappr.Player({
  2. source: 'http://your.video/here.mp4',
  3. plugins: [ContextMenuPlugin]
  4. });

Configuration

The options for the plugin go in the contextMenu property as shown below

  1. var player = new Clappr.Player({
  2. source: 'http://your.video/here.mp4',
  3. plugins: [ContextMenuPlugin],
  4. contextMenu: {
  5. menuItems: [`copyURL`, `copyURLCurrentTime`, `loop`, `playerVersion`],
  6. extraOptions: [
  7. {
  8. name: 'test',
  9. label: 'Test Label',
  10. //optional
  11. callback: function() {
  12. console.log('A absolutely awesome extra context menu item action')
  13. }
  14. }
  15. ],
  16. customStyle: {
  17. container: {
  18. 'display': 'block'
  19. },
  20. list: {
  21. 'background-color': 'gray'
  22. },
  23. items: {
  24. 'color': 'yellow'
  25. }
  26. }
  27. }
  28. });

menuItems {Array}

An array where each item is a name that matches one of the default menu items. The valid values are: ['copyURL', 'copyURLCurrentTime', 'loop', 'playerVersion']

extraOptions {Array}

An array of items to add on the context menu. Each context menu item on this array is an object which contains the parameters name, label, and callback

  • name {String}

    Name of the extra item

  • label {String}

    The label that will be displayed on the menu

  • callback {Function}

    A method that will be triggered when clicking on the item label. This option is not required if your desired menu item not have one action to call on click (like the playerVersion default menu item)

customStyle {Object}

Styles to apply to mapped elements on the context menu. This option is an object with the parameters container, list and items

  • container {Object}

    Attributes that will be applied in the main element. This option is an object that receives CSS attributes like the options example at the beginning of this section

  • list {Object}

    Attributes that will be applied in the <ul> element. This option is an object that receives CSS attributes like the options example at the beginning of this section

  • items {Object}

    Attributes that will be applied in each <li> element. This option is an object that receives CSS attributes like the options example at the beginning of this section

Development

Install dependencies: npm install

Run: npm start

Test: npm test

Lint: npm run lint

Build: npm run build

Minified version: npm run release