stash/ui/v2.5/src/components/ScenePlayer/big-buttons.ts
dumdum7 55d3deee49
Use big-buttons instead of videojs-mobile-ui touch controls (#3650)
* Use big-buttons instead of videojs-mobile-ui touch controls
* Update @types/videojs-mobile-ui to 0.8.0
2023-04-27 12:24:33 +10:00

69 lines
1.6 KiB
TypeScript

import videojs, { VideoJsPlayer } from "video.js";
// prettier-ignore
const BigPlayButton = videojs.getComponent("BigPlayButton") as unknown as typeof videojs.BigPlayButton;
class BigPlayPauseButton extends BigPlayButton {
handleClick(event: videojs.EventTarget.Event) {
if (this.player().paused()) {
super.handleClick(event);
} else {
this.player().pause();
}
}
buildCSSClass() {
return "vjs-control vjs-button vjs-big-play-pause-button";
}
}
class BigButtonGroup extends videojs.getComponent("Component") {
constructor(player: VideoJsPlayer) {
super(player);
this.addChild("seekButton", {
direction: "back",
seconds: 10,
});
this.addChild("BigPlayPauseButton");
this.addChild("seekButton", {
direction: "forward",
seconds: 10,
});
}
createEl() {
return super.createEl("div", {
className: "vjs-big-button-group",
});
}
}
class BigButtonsPlugin extends videojs.getPlugin("plugin") {
constructor(player: VideoJsPlayer) {
super(player);
player.ready(() => {
player.addChild("BigButtonGroup");
});
}
}
// Register the plugin with video.js.
videojs.registerComponent("BigButtonGroup", BigButtonGroup);
videojs.registerComponent("BigPlayPauseButton", BigPlayPauseButton);
videojs.registerPlugin("bigButtons", BigButtonsPlugin);
/* eslint-disable @typescript-eslint/naming-convention */
declare module "video.js" {
interface VideoJsPlayer {
bigButtons: () => BigButtonsPlugin;
}
interface VideoJsPlayerPluginOptions {
bigButtons?: {};
}
}
export default BigButtonsPlugin;