mirror of
https://github.com/stashapp/stash.git
synced 2026-05-05 11:01:22 +02:00
* Use big-buttons instead of videojs-mobile-ui touch controls * Update @types/videojs-mobile-ui to 0.8.0
69 lines
1.6 KiB
TypeScript
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;
|