Skip to content

Commit

Permalink
fix(web): use window manager in replay mode (#1140)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious committed Nov 25, 2021
1 parent 66811e7 commit f29e5c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions web/flat-web/src/api-middleware/SmartPlayer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "video.js/dist/video-js.css";

import "@netless/window-manager/dist/style.css";
import CombinePlayerFactory, { CombinePlayer, PublicCombinedStatus } from "@netless/combine-player";
import { CursorTool } from "@netless/cursor-tool";
import {
PluginId as VideoJsPluginId,
videoJsPlugin,
Expand All @@ -19,6 +18,7 @@ import {
} from "white-web-sdk";
import { Region } from "flat-components";
import { NETLESS, NODE_ENV } from "../constants/process";
import { WindowManager } from "@netless/window-manager";

export enum SmartPlayerEventType {
Ready = "Ready",
Expand Down Expand Up @@ -99,6 +99,7 @@ export class SmartPlayer extends EventEmitter<SmartPlayerEventType> {
appIdentifier: NETLESS.APP_IDENTIFIER,
plugins: plugins,
region,
useMobXState: true,
});

this.whiteWebSdk = whiteWebSdk;
Expand All @@ -123,13 +124,12 @@ export class SmartPlayer extends EventEmitter<SmartPlayerEventType> {
}
});

const cursorAdapter = new CursorTool();

const replayRoomParams: ReplayRoomParams = {
room: whiteboardUUID,
roomToken: whiteboardRoomToken,
cursorAdapter: cursorAdapter,
region,
invisiblePlugins: [WindowManager],
useMultiViews: true,
};

if (recording) {
Expand All @@ -138,9 +138,6 @@ export class SmartPlayer extends EventEmitter<SmartPlayerEventType> {
}

const player = await whiteWebSdk.replayRoom(replayRoomParams, {
onLoadFirstFrame: () => {
cursorAdapter.setPlayer(player);
},
onPhaseChanged: phase => {
if (this.combinePlayer) {
return;
Expand Down Expand Up @@ -183,9 +180,12 @@ export class SmartPlayer extends EventEmitter<SmartPlayerEventType> {
},
});

cursorAdapter.setPlayer(player);

player.bindHtmlElement(whiteboardEl);
void WindowManager.mount({
room: player as any,
container: whiteboardEl,
cursor: true,
chessboard: false,
});

this.whiteboardPlayer = player;

Expand Down
2 changes: 1 addition & 1 deletion web/flat-web/src/stores/class-room-replay-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class ClassRoomReplayStore {
});
} catch (error) {
console.error(error);
this.updateError(error);
this.updateError(error as Error);
}

runInAction(() => {
Expand Down

0 comments on commit f29e5c1

Please sign in to comment.