Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1291 split view progress bar in wrong position after entering fullscreen mode if the width ratio of two views adjusted #1393

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions web/ts/splitview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { getPlayers } from "./TUMLiveVjs";
import Split from "split.js";
import { cloneEvents } from "./global";
import videojs, { VideoJsPlayer } from "video.js";
import PlayerOptions = videojs.PlayerOptions;

const mouseMovingTimeout = 2200;

Expand Down Expand Up @@ -37,16 +39,16 @@ export class SplitView {
this.videoWrapperResizeObs.observe(this.videoWrapper);
this.detectMouseNotMoving();

this.players[0].ready(() => {
this.players[1].ready(() => {
this.setTrackBarModes(0, "disabled");
});

this.players[1].ready(() => {
this.players[0].ready(() => {
this.setupControlBars();
this.overwriteFullscreenToggle();
});

cloneEvents(this.players[0].el(), this.players[1].el(), ["mousemove", "mouseenter", "mouseleave"]);
cloneEvents(this.players[1].el(), this.players[0].el(), ["mousemove", "mouseenter", "mouseleave"]);

// Setup splitview
// eslint-disable-next-line @typescript-eslint/no-this-alias
Expand Down Expand Up @@ -107,15 +109,15 @@ export class SplitView {
}

private setupControlBars() {
this.players[0].controlBar.hide();
this.players[0].muted(true);
this.players[1].controlBar.hide();
this.players[1].muted(true);

this.players[1].el().addEventListener("fullscreenchange", () => {
this.players[0].el().addEventListener("fullscreenchange", () => {
this.isFullscreen = document.fullscreenElement !== null;
this.updateControlBarSize(this.getSizes());
});

const mainControlBarElem = this.players[1].controlBar.el();
const mainControlBarElem = this.players[0].controlBar.el();
mainControlBarElem.style.position = "absolute";
mainControlBarElem.style.zIndex = "1";

Expand All @@ -126,38 +128,40 @@ export class SplitView {
const wrapperSize = this.videoWrapper.getBoundingClientRect().width;

let marginLeft;
if (this.isFullscreen) {
marginLeft = "0";
} else if (sizes[0] === 100) {
marginLeft = `${this.gutterWidth / 2 - wrapperSize}px`; //`calc(${this.gutterWidth / 2}px - 100vw)`;
} else if (sizes[0] === 0) {
marginLeft = `-${this.gutterWidth / 2}px`;
if (sizes[0] === 0) {
marginLeft = `${this.gutterWidth / 2}px`;
} else {
const leftContainerWidth = (sizes[0] * wrapperSize) / 100;
marginLeft = `-${leftContainerWidth}px`;
marginLeft = `0px`;
}

const mainControlBarElem = this.players[1].controlBar.el();
mainControlBarElem.style.marginLeft = marginLeft;
const mainControlBarElem = this.players[0].controlBar.el();
mainControlBarElem.style.width = `${wrapperSize}px`;
mainControlBarElem.style.marginLeft = marginLeft;

const textTrackDisplay = this.players[1].el_.querySelector(".vjs-text-track-display");
const textTrackDisplay = this.players[0].el_.querySelector(".vjs-text-track-display");
if (textTrackDisplay) {
textTrackDisplay.style.left = marginLeft;
textTrackDisplay.style.width = `${wrapperSize}px`;
textTrackDisplay.style.zIndex = "1";
}
}

private overwriteFullscreenToggle() {
const fullscreenToggle = this.players[1].controlBar.fullscreenToggle;
const fullscreenToggle = this.players[0].controlBar.fullscreenToggle;
fullscreenToggle.off("click");

fullscreenToggle.on("click", async () => {
if (document.fullscreenElement === null) {
await this.splitParent.requestFullscreen();
} else {
await document.exitFullscreen();
}
await this.toggleFullscreen();
});

(this.players[0] as VideoJsPlayer).options_.userActions.doubleClick = async () => await this.toggleFullscreen();
(this.players[1] as VideoJsPlayer).options_.userActions.doubleClick = async () => await this.toggleFullscreen();
}

private async toggleFullscreen() {
if (document.fullscreenElement === null) {
await this.splitParent.requestFullscreen();
} else {
await document.exitFullscreen();
}
}

private setTrackBarModes(k: number, mode: string) {
Expand Down
Loading