| |
| |
| |
| import Button from '../button'; |
| import Component from '../component'; |
| import * as Dom from '../utils/dom.js'; |
| |
| |
| |
| |
| |
| |
| |
| |
| class SeekToLive extends Button { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| constructor(player, options) { |
| super(player, options); |
| |
| this.updateLiveEdgeStatus(); |
| |
| if (this.player_.liveTracker) { |
| this.updateLiveEdgeStatusHandler_ = (e) => this.updateLiveEdgeStatus(e); |
| this.on(this.player_.liveTracker, 'liveedgechange', this.updateLiveEdgeStatusHandler_); |
| } |
| } |
| |
| |
| |
| |
| |
| |
| |
| createEl() { |
| const el = super.createEl('button', { |
| className: 'vjs-seek-to-live-control vjs-control' |
| }); |
| |
| this.setIcon('circle', el); |
| |
| this.textEl_ = Dom.createEl('span', { |
| className: 'vjs-seek-to-live-text', |
| textContent: this.localize('LIVE') |
| }, { |
| 'aria-hidden': 'true' |
| }); |
| |
| el.appendChild(this.textEl_); |
| return el; |
| } |
| |
| |
| |
| |
| |
| updateLiveEdgeStatus() { |
| |
| if (!this.player_.liveTracker || this.player_.liveTracker.atLiveEdge()) { |
| this.setAttribute('aria-disabled', true); |
| this.addClass('vjs-at-live-edge'); |
| this.controlText('Seek to live, currently playing live'); |
| } else { |
| this.setAttribute('aria-disabled', false); |
| this.removeClass('vjs-at-live-edge'); |
| this.controlText('Seek to live, currently behind live'); |
| } |
| } |
| |
| |
| |
| |
| |
| |
| handleClick() { |
| this.player_.liveTracker.seekToLiveEdge(); |
| } |
| |
| |
| |
| |
| dispose() { |
| if (this.player_.liveTracker) { |
| this.off(this.player_.liveTracker, 'liveedgechange', this.updateLiveEdgeStatusHandler_); |
| } |
| this.textEl_ = null; |
| |
| super.dispose(); |
| } |
| } |
| |
| |
| |
| |
| |
| |
| SeekToLive.prototype.controlText_ = 'Seek to live, currently playing live'; |
| |
| Component.registerComponent('SeekToLive', SeekToLive); |
| export default SeekToLive; |