26 lines
867 B
JavaScript
26 lines
867 B
JavaScript
|
|
import videojs from "video.js";
|
|||
|
|
const BigPlayButton = videojs.getComponent("BigPlayButton");
|
|||
|
|
class BigPlayPauseButton extends BigPlayButton {
|
|||
|
|
handleClick() {
|
|||
|
|
const player = this.player();
|
|||
|
|
if (player.paused()) {
|
|||
|
|
player.play();
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
player.pause();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
videojs.registerComponent("BigPlayPauseButton", BigPlayPauseButton);
|
|||
|
|
// Функция плагина с аннотацией типа this
|
|||
|
|
function bigPlayPauseButtonPlugin() {
|
|||
|
|
const player = this;
|
|||
|
|
const defaultButton = player.getChild("bigPlayButton");
|
|||
|
|
if (defaultButton) {
|
|||
|
|
defaultButton.dispose();
|
|||
|
|
}
|
|||
|
|
player.addChild("BigPlayPauseButton", {});
|
|||
|
|
}
|
|||
|
|
videojs.registerPlugin("bigPlayPauseButton", bigPlayPauseButtonPlugin);
|
|||
|
|
export default bigPlayPauseButtonPlugin;
|
|||
|
|
//# sourceMappingURL=big-play-pause-button.js.map
|