Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop Icon #46

Open
Exlord opened this issue Dec 15, 2021 · 0 comments
Open

Loop Icon #46

Exlord opened this issue Dec 15, 2021 · 0 comments

Comments

@Exlord
Copy link

Exlord commented Dec 15, 2021

Hi, Could you add Loop icon to the font?
I created a button plugin to allow disable/enable loop

repeat and repeat_on icons

/* eslint-disable */
import videojs from 'video.js';

const Button = videojs.getComponent('Button');
const Component = videojs.getComponent('Component');

export default class LoopToggle extends Button {
  constructor(player, options = {}) {
    super(player, options);
  }

  ready() {
    this.onIcon = this.$('.vjs-loop-on-icon');
    this.offIcon = this.$('.vjs-loop-off-icon');
    this.toggleIcon();
  }

  toggleIcon() {
    const isOn = this.player_.loop();
    this.onIcon.style.display = isOn ? '' : 'none';
    this.offIcon.style.display = isOn ? 'none' : '';
  }

  buildCSSClass() {
    return `vjs-loop-control ${super.buildCSSClass()}`;
  }

  handleClick(event) {
    this.player_.loop(!this.player_.loop());
    this.toggleIcon();
  }

  createEl(tag, props = {}, attributes = {}) {
    tag = 'button';

    props.innerHTML = `
    <span aria-hidden="true" class="vjs-icon-placeholder">
      <i class="material-icons-round vjs-loop-off-icon" style="display: none;">repeat</i>
      <i class="material-icons-round vjs-loop-on-icon" style="display: none;">repeat_on</i>
    </span>`;
    props.className = this.buildCSSClass();

    attributes = {
      type: 'button',
      ...attributes,
    };

    const el = Component.prototype.createEl.call(this, tag, props, attributes);

    this.createControlTextEl(el);

    return el;
  }
}

LoopToggle.prototype.controlText_ = 'Toggle Loop';
Component.registerComponent('LoopToggle', LoopToggle);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant