-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathplugin.js
57 lines (47 loc) · 1.6 KB
/
plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import videojs from 'video.js';
import {version as VERSION} from '../package.json';
const Plugin = videojs.getPlugin('plugin');
// Default options for the plugin.
import defaults from './defaults';
import ShareButton from './ShareButton';
import ShareOverlay from './ShareOverlay';
/**
* An advanced Video.js plugin. For more information on the API
*
* See: https://blog.videojs.com/feature-spotlight-advanced-plugins/
*/
class Share extends Plugin {
/**
* Create a Share plugin instance.
*
* @param {Player} player
* A Video.js Player instance.
*
* @param {Object} [options]
* An optional options object.
*
* While not a core part of the Video.js plugin architecture, a
* second argument of options is a convenient way to accept inputs
* from your plugin's caller.
*/
constructor(player, options) {
// the parent class will add player under this.player
super(player);
this.options = videojs.mergeOptions(defaults, options);
this.player.ready(() => {
this.player.addClass('vjs-share');
player.addClass('vjs-videojs-share');
player.getChild('controlBar').addChild('ShareButton', options);
player.addChild('ShareOverlay', options);
});
}
}
// Define default values for the plugin's `state` object here.
Share.defaultState = {};
// Include the version number.
Share.VERSION = VERSION;
// Register the plugin with video.js.
videojs.registerComponent('ShareButton', ShareButton);
videojs.registerComponent('ShareOverlay', ShareOverlay);
videojs.registerPlugin('share', Share);
export default Share;