mirror of
https://github.com/stashapp/stash.git
synced 2026-05-09 05:05:29 +02:00
Fix viewing jwplayer after non-jwplayer video
This commit is contained in:
parent
8ed3c5f71d
commit
46c2957787
3 changed files with 26 additions and 12 deletions
|
|
@ -40,7 +40,7 @@ export const SceneMarkersPanel: FunctionComponent<ISceneMarkersPanelProps> = (pr
|
|||
const sceneMarkerUpdate = StashService.useSceneMarkerUpdate();
|
||||
const sceneMarkerDestroy = StashService.useSceneMarkerDestroy();
|
||||
|
||||
const jwplayer = SceneHelpers.getJWPlayer();
|
||||
const jwplayer = SceneHelpers.getPlayer();
|
||||
|
||||
function onOpenEditor(marker: GQL.SceneMarkerDataFragment | null = null) {
|
||||
setIsEditorOpen(true);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,12 @@ export class VideoJSPlayer extends React.Component<IScenePlayerProps> {
|
|||
componentDidMount() {
|
||||
this.player = videojs(this.videoNode);
|
||||
|
||||
// dirty hack - make this player look like JWPlayer
|
||||
this.player.seek = this.player.currentTime;
|
||||
this.player.getPosition = this.player.currentTime;
|
||||
|
||||
SceneHelpers.registerJSPlayer(this.player);
|
||||
|
||||
this.player.src(this.props.scene.paths.stream);
|
||||
|
||||
// hack duration
|
||||
|
|
@ -49,15 +55,6 @@ export class VideoJSPlayer extends React.Component<IScenePlayerProps> {
|
|||
};
|
||||
|
||||
this.player.ready(() => {
|
||||
// dirty hack - make this player look like JWPlayer
|
||||
this.player.seek = this.player.currentTime;
|
||||
this.player.getPosition = this.player.currentTime;
|
||||
|
||||
// hook it into the window function
|
||||
(window as any).jwplayer = () => {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
this.player.on("timeupdate", () => {
|
||||
this.props.onTime();
|
||||
});
|
||||
|
|
@ -73,6 +70,7 @@ export class VideoJSPlayer extends React.Component<IScenePlayerProps> {
|
|||
componentWillUnmount() {
|
||||
if (this.player) {
|
||||
this.player.dispose();
|
||||
SceneHelpers.deregisterJSPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -225,7 +223,7 @@ export class ScenePlayer extends React.Component<IScenePlayerProps, IScenePlayer
|
|||
}
|
||||
|
||||
private onReady() {
|
||||
this.player = SceneHelpers.getJWPlayer();
|
||||
this.player = SceneHelpers.getPlayer();
|
||||
if (this.props.timestamp > 0) {
|
||||
this.player.seek(this.props.timestamp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,12 @@ import {
|
|||
} from "@blueprintjs/core";
|
||||
import React, { } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import videojs from "video.js";
|
||||
import * as GQL from "../../core/generated-graphql";
|
||||
|
||||
export class SceneHelpers {
|
||||
private static videoJSPlayer: videojs.Player | null;
|
||||
|
||||
public static maybeRenderStudio(
|
||||
scene: GQL.SceneDataFragment | GQL.SlimSceneDataFragment,
|
||||
height: number,
|
||||
|
|
@ -33,8 +36,21 @@ export class SceneHelpers {
|
|||
);
|
||||
}
|
||||
|
||||
public static registerJSPlayer(player : videojs.Player) {
|
||||
this.videoJSPlayer = player;
|
||||
}
|
||||
|
||||
public static deregisterJSPlayer() {
|
||||
this.videoJSPlayer = null;
|
||||
}
|
||||
|
||||
public static getJWPlayerId(): string { return "main-jwplayer"; }
|
||||
public static getJWPlayer(): any {
|
||||
public static getPlayer(): any {
|
||||
// return videoJSPlayer if it is set, otherwise use jwplayer()
|
||||
if (this.videoJSPlayer) {
|
||||
return this.videoJSPlayer;
|
||||
}
|
||||
|
||||
return (window as any).jwplayer("main-jwplayer");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue