index.js 1.07 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 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 44 45 46 47 48 49 50 51 52
import videojs from 'video.js'

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

class CustomPlayButtonCover extends Component {
    createEl() {
        return super.createEl('div', {
            className: 'vjs-custom-play-button-cover'
        })
    }

    dispose() {
        this.el_ && (this.el_ = null)
    }
}

class CustomPlayButton extends Button {
    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
        }
    }
}


Component.registerComponent('CustomPlayButton', CustomPlayButton)

CustomPlayButtonCover.prototype.options_ = {
    children: [
        'CustomPlayButton'
    ]
}

xuzhenghua committed
53
Component.registerComponent('CustomPlayButtonCover', CustomPlayButtonCover)