/*! @name videojs-trimming-controls @version 0.0.0 @license MIT */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('video.js')) : typeof define === 'function' && define.amd ? define(['video.js'], factory) : (global.videojsTrimmingControls = factory(global.videojs)); }(this, (function (videojs) { 'use strict'; videojs = videojs && videojs.hasOwnProperty('default') ? videojs['default'] : videojs; function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } var version = "0.0.0"; var Plugin = videojs.getPlugin('plugin'); // Default options for the plugin. var defaults = { startTrim: 60, endTrim: 120, limitPlayback: false }; /** * An advanced Video.js plugin. For more information on the API * * See: https://blog.videojs.com/feature-spotlight-advanced-plugins/ */ var TrimmingControls = /*#__PURE__*/ function (_Plugin) { _inheritsLoose(TrimmingControls, _Plugin); /** * Create a TrimmingControls 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. */ function TrimmingControls(player, options) { var _this; // the parent class will add player under this.player _this = _Plugin.call(this, player) || this; _this.options = videojs.mergeOptions(defaults, options); _this.createTrimmingControls(); player.ready(function () { setTimeout(function () { _this.updateTrimTimes(_this.options.startTrim, _this.options.endTrim); }, 100); player.on("timeupdate", function () { if (_this.options.limitPlayback && _this.player.currentTime() >= _this.options.endTrim) { _this.player.currentTime(_this.options.endTrim); _this.player.pause(); } }); player.on('playing', function () { videojs.log('playback began!'); _this.updateTrimTimes(_this.options.startTrim, _this.options.endTrim); }); }); return _this; } var _proto = TrimmingControls.prototype; _proto.createTrimmingControls = function createTrimmingControls() { var player = this.player; var videoJsComponentClass = videojs.getComponent('Component'); /** * Extend vjs button class for quality button. */ var TrimControlBarClass = /*#__PURE__*/ function (_videoJsComponentClas) { _inheritsLoose(TrimControlBarClass, _videoJsComponentClas); /** * Component constructor. */ function TrimControlBarClass() { return _videoJsComponentClas.call(this, player, { title: player.localize('Trimming Controls') }) || this; } var _proto2 = TrimControlBarClass.prototype; _proto2.createEl = function createEl() { return videojs.dom.createEl('div', { // Prefixing classes of elements within a player with "vjs-" is a convention used in Video.js. className: 'vjs-control-bar vjs-trimming-controls', dir: 'ltr' }); }; return TrimControlBarClass; }(videoJsComponentClass); var videoJSSpacerClass = videojs.getComponent('Spacer'); var videoJSButtonClass = videojs.getComponent('Button'); var GoToButtonClass = /*#__PURE__*/ function (_videoJSButtonClass) { _inheritsLoose(GoToButtonClass, _videoJSButtonClass); function GoToButtonClass(_plugin, _targetPosition, _text) { var _this2; _this2 = _videoJSButtonClass.call(this, player, {// title: player.localize('Trim Button'), // label: "Trim Here" }) || this; _this2.trimmingControls = _plugin; _this2.targetPosition = _targetPosition; _this2.controlText(_text); _this2.el().getElementsByClassName('vjs-icon-placeholder')[0].classList += " material-icons"; return _this2; } var _proto3 = GoToButtonClass.prototype; _proto3.handleClick = function handleClick() { if (this.targetPosition == 0) { this.player().currentTime(this.trimmingControls.options.startTrim); } else if (this.targetPosition == 1) { this.player().currentTime(this.trimmingControls.options.endTrim); } }; return GoToButtonClass; }(videoJSButtonClass); var TrimButtonClass = /*#__PURE__*/ function (_videoJSButtonClass2) { _inheritsLoose(TrimButtonClass, _videoJSButtonClass2); function TrimButtonClass(_plugin, _targetPosition, _text) { var _this3; _this3 = _videoJSButtonClass2.call(this, player, {// title: player.localize('Trim Button'), // label: "Trim Here" }) || this; _this3.trimmingControls = _plugin; _this3.targetPosition = _targetPosition; _this3.controlText(_text); _this3.el().getElementsByClassName('vjs-icon-placeholder')[0].classList += " material-icons"; return _this3; } var _proto4 = TrimButtonClass.prototype; _proto4.handleClick = function handleClick() { if (this.targetPosition == 0) { this.trimmingControls.updateTrimTimes(this.player().currentTime(), this.trimmingControls.options.endTrim); } else if (this.targetPosition == 1) { this.trimmingControls.updateTrimTimes(this.trimmingControls.options.startTrim, this.player().currentTime()); } }; return TrimButtonClass; }(videoJSButtonClass); var TrimTimeDisplayClass = /*#__PURE__*/ function (_videoJsComponentClas2) { _inheritsLoose(TrimTimeDisplayClass, _videoJsComponentClas2); function TrimTimeDisplayClass(_defaultTime) { var _this4; _this4 = _videoJsComponentClas2.call(this, player, {}) || this; _this4.updateTimeContent(_defaultTime); return _this4; } var _proto5 = TrimTimeDisplayClass.prototype; _proto5.createEl = function createEl() { return videojs.dom.createEl('input', { // Prefixing classes of elements within a player with "vjs-" is a convention used in Video.js. className: 'vjs-time-display' }); }; _proto5.updateTimeContent = function updateTimeContent(timeInSeconds) { videojs.dom.emptyEl(this.el()); //this.controlText(videojs.formatTime(timeInSeconds, 600)) //videojs.dom.appendContent(this.el(), videojs.formatTime(timeInSeconds, 600)); //videojs.dom.textContent(this.el(), videojs.formatTime(timeInSeconds, 600)); this.el().value = videojs.formatTime(timeInSeconds, 600.01); }; return TrimTimeDisplayClass; }(videoJsComponentClass); var FrameButtonClass = /*#__PURE__*/ function (_videoJSButtonClass3) { _inheritsLoose(FrameButtonClass, _videoJSButtonClass3); function FrameButtonClass(_plugin, _targetPosition, _text) { var _this5; _this5 = _videoJSButtonClass3.call(this, player, {// title: player.localize('Trim Button'), // label: "Trim Here" }) || this; _this5.trimmingControls = _plugin; _this5.targetPosition = _targetPosition; _this5.controlText(_text); _this5.el().getElementsByClassName('vjs-icon-placeholder')[0].classList += " material-icons"; return _this5; } var _proto6 = FrameButtonClass.prototype; _proto6.handleClick = function handleClick() { if (this.targetPosition == 0) { this.player().currentTime(this.player().currentTime() - 0.1); } else if (this.targetPosition == 1) { this.player().currentTime(this.player().currentTime() + 0.1); } }; return FrameButtonClass; }(videoJSButtonClass); var videoJSPlayToggleClass = videojs.getComponent('PlayToggle'); var playbackEndToggleClass = /*#__PURE__*/ function (_videoJSButtonClass4) { _inheritsLoose(playbackEndToggleClass, _videoJSButtonClass4); function playbackEndToggleClass(_plugin, _text) { var _this6; _this6 = _videoJSButtonClass4.call(this, player, {// title: player.localize('Trim Button'), // label: "Trim Here" }) || this; _this6.trimmingControls = _plugin; _this6.controlText(_text); _this6.el().getElementsByClassName('vjs-icon-placeholder')[0].classList += " material-icons"; return _this6; } var _proto7 = playbackEndToggleClass.prototype; _proto7.handleClick = function handleClick() { this.trimmingControls.options.limitPlayback = !this.trimmingControls.options.limitPlayback; this.toggleClass('playbackLimited'); }; return playbackEndToggleClass; }(videoJSButtonClass); //Creating Trimming Seek Bar this._trimSeekControlBar = new TrimControlBarClass(); var trimSeekControlBarInstance = player.addChild(this._trimSeekControlBar, { componentClass: 'trimControlBar' }, player.children().length); trimSeekControlBarInstance.addClass('vljs-trim-seek'); trimSeekControlBarInstance.el().innerHTML = '