vendor: 1,102 bytes, lines 1-27
1/*! @name videojs-seek-buttons @version 4.0.2 @license Apache-2.0 */ 2(function (global, factory) { 3 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('video.js')) : 4 typeof define === 'function' && define.amd ? define(['video.js'], factory) : 5 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.videojsSeekButtons = factory(global.videojs)); 6 })(this, (function (videojs) { 'use strict'; 7 8 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } 9 10 var videojs__default = /*#__PURE__*/_interopDefaultLegacy(videojs); 11 12 var version = "4.0.2"; 13 14 const Button = videojs__default["default"].getComponent('Button'); // Default options for the plugin. 15 16 const defaults = { 17 forwardIndex: 1, 18 backIndex: 1 19 }; 20 /** 21 * Set up buttons when the player is ready. 22 * 23 * @function onPlayerReady 24 * @param {Player} player 25 * A Video.js player object. 26 * 27 * @param {Object} [options={}]
28 * A plain object containing options for the plugin. 29 */ 30 31 const onPlayerReady = (player, options) => { 32 player.addClass('vjs-seek-buttons'); 33 34 if (options.forward && options.forward > 0) { 35 player.controlBar.seekForward = player.controlBar.addChild('seekButton', { 36 direction: 'forward', 37 seconds: options.forward 38 }, options.forwardIndex); 39 } 40 41 if (options.back && options.back > 0) { 42 player.controlBar.seekBack = player.controlBar.addChild('seekButton', { 43 direction: 'back', 44 seconds: options.back 45 }, options.backIndex); 46 } 47 }; 48 /** 49 * Plugin init if ready or on ready 50 * 51 * @function seekButtons 52 * @param {Object} [options={}] 53 * An object of options left to the plugin author to define. 54 */ 55 56 57 const seekButtons = function (options) { 58 this.ready(() => { 59 onPlayerReady(this, videojs__default["default"].obj.merge(defaults, options)); 60 }); 61 }; // Include the version number. 62 63 64 seekButtons.VERSION = version; 65 /** 66 * Button to seek forward/back 67 * 68 * @extends Button 69 * @class SeekButton 70 */ 71 72 class SeekButton extends Button { 73 /** 74 * Constructor for class 75 * 76 * @param {Player|Object} player The player 77 * @param {Object=} options Button options 78 * @param {string} options.direction back or forward 79 * @param {Int} options.seconds number of seconds to seek 80 */ 81 constructor(player, options) { 82 super(player, options); 83 84 if (this.options_.direction === 'forward') { 85 this.controlText(this.localize('Seek forward {{seconds}} seconds').replace('{{seconds}}', this.options_.seconds)); 86 } else if (this.options_.direction === 'back') { 87 this.controlText(this.localize('Seek back {{seconds}} seconds').replace('{{seconds}}', this.options_.seconds)); 88 } 89 } 90 /** 91 * Return button class names which include the seek amount. 92 * 93 * @return {string} css cass string 94 */ 95 96 97 buildCSSClass() { 98 /* Each button will have the classes: 99 `vjs-seek-button` 100 `skip-forward` or `skip-back` 101 `skip-n` where `n` is the number of seconds 102 So you could have a generic icon for "skip back" and a more 103 specific one for "skip back 30 seconds" 104 */ 105 return `vjs-seek-button skip-${this.options_.direction} ` + `skip-${this.options_.seconds} ${super.buildCSSClass()}`; 106 } 107 /** 108 * Seek with the button's configured offset 109 */ 110 111 112 handleClick() { 113 const now = this.player_.currentTime(); 114 115 if (this.options_.direction === 'forward') { 116 let duration = this.player_.duration(); 117 118 if (this.player_.liveTracker && this.player_.liveTracker.isLive()) { 119 duration = this.player_.liveTracker.seekableEnd(); 120 } 121 122 this.player_.currentTime(Math.min(now + this.options_.seconds, duration)); 123 } else if (this.options_.direction === 'back') { 124 this.player_.currentTime(Math.max(0, now - this.options_.seconds)); 125 } 126 } 127 128 } 129 130 videojs__default["default"].registerComponent('SeekButton', SeekButton); // Register the plugin with video.js. 131 132 videojs__default["default"].registerPlugin('seekButtons', seekButtons); 133 134 return seekButtons; 135 136 }));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.