- 1 :
/**
- 2 :
* @file captions-button.js
- 3 :
*/
- 4 :
import TextTrackButton from './text-track-button.js';
- 5 :
import Component from '../../component.js';
- 6 :
import CaptionSettingsMenuItem from './caption-settings-menu-item.js';
- 7 :
- 8 :
/**
- 9 :
* The button component for toggling and selecting captions
- 10 :
*
- 11 :
* @extends TextTrackButton
- 12 :
*/
- 13 :
class CaptionsButton extends TextTrackButton {
- 14 :
- 15 :
/**
- 16 :
* Creates an instance of this class.
- 17 :
*
- 18 :
* @param {Player} player
- 19 :
* The `Player` that this class should be attached to.
- 20 :
*
- 21 :
* @param {Object} [options]
- 22 :
* The key/value store of player options.
- 23 :
*
- 24 :
* @param {Component~ReadyCallback} [ready]
- 25 :
* The function to call when this component is ready.
- 26 :
*/
- 27 :
constructor(player, options, ready) {
- 28 :
super(player, options, ready);
- 29 :
}
- 30 :
- 31 :
/**
- 32 :
* Builds the default DOM `className`.
- 33 :
*
- 34 :
* @return {string}
- 35 :
* The DOM `className` for this object.
- 36 :
*/
- 37 :
buildCSSClass() {
- 38 :
return `vjs-captions-button ${super.buildCSSClass()}`;
- 39 :
}
- 40 :
- 41 :
buildWrapperCSSClass() {
- 42 :
return `vjs-captions-button ${super.buildWrapperCSSClass()}`;
- 43 :
}
- 44 :
- 45 :
/**
- 46 :
* Create caption menu items
- 47 :
*
- 48 :
* @return {CaptionSettingsMenuItem[]}
- 49 :
* The array of current menu items.
- 50 :
*/
- 51 :
createItems() {
- 52 :
const items = [];
- 53 :
- 54 :
if (!(this.player().tech_ && this.player().tech_.featuresNativeTextTracks) &&
- 55 :
this.player().getChild('textTrackSettings')) {
- 56 :
items.push(new CaptionSettingsMenuItem(this.player_, {kind: this.kind_}));
- 57 :
- 58 :
this.hideThreshold_ += 1;
- 59 :
}
- 60 :
- 61 :
return super.createItems(items);
- 62 :
}
- 63 :
- 64 :
}
- 65 :
- 66 :
/**
- 67 :
* `kind` of TextTrack to look for to associate it with this menu.
- 68 :
*
- 69 :
* @type {string}
- 70 :
* @private
- 71 :
*/
- 72 :
CaptionsButton.prototype.kind_ = 'captions';
- 73 :
- 74 :
/**
- 75 :
* The text that should display over the `CaptionsButton`s controls. Added for localization.
- 76 :
*
- 77 :
* @type {string}
- 78 :
* @private
- 79 :
*/
- 80 :
CaptionsButton.prototype.controlText_ = 'Captions';
- 81 :
- 82 :
Component.registerComponent('CaptionsButton', CaptionsButton);
- 83 :
export default CaptionsButton;