index.js 1015 Bytes
Newer Older
zhanghaozhe committed
1
import videojs from "video.js"
2

zhanghaozhe committed
3 4
const Component = videojs.getComponent("Component")
const Button = videojs.getComponent("Button")
5 6

class CustomPlayButtonCover extends Component {
zhanghaozhe committed
7 8 9 10 11 12 13 14 15
  createEl() {
    return super.createEl("div", {
      className: "vjs-custom-play-button-cover",
    })
  }

  dispose() {
    this.el_ && (this.el_ = null)
  }
16 17 18
}

class CustomPlayButton extends Button {
zhanghaozhe committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
  constructor(player, options) {
    super(player, options)
    this.on("tap", this.tap)
  }

  createEl() {
    return super.createEl(
      "button",
      {
        className: "vjs-custom-play-button",
      },
      {
        type: "button",
      }
    )
  }

  tap() {
    this.player_.play()
  }

  dispose() {
    if (this.el_) {
      this.off("tap", this.tap)
      this.el_ = null
44
    }
zhanghaozhe committed
45
  }
46 47
}

zhanghaozhe committed
48
Component.registerComponent("CustomPlayButton", CustomPlayButton)
49 50

CustomPlayButtonCover.prototype.options_ = {
zhanghaozhe committed
51
  children: ["CustomPlayButton"],
52 53
}

zhanghaozhe committed
54
Component.registerComponent("CustomPlayButtonCover", CustomPlayButtonCover)