Skip to content

Commit

Permalink
feat(desktop): support window manager in replay mode (#1142)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrious authored Nov 25, 2021
1 parent 4e8c649 commit d0edfe0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
20 changes: 10 additions & 10 deletions desktop/renderer-app/src/api-middleware/smart-player.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "video.js/dist/video-js.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 {
appIdentifier: NETLESS.APP_IDENTIFIER,
plugins: plugins,
region,
useMobXState: true,
});

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

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 {
}

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 {
},
});

cursorAdapter.setPlayer(player);

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

this.whiteboardPlayer = player;

Expand Down
1 change: 1 addition & 0 deletions desktop/renderer-app/src/pages/ReplayPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { RouteNameType, RouteParams } from "../../utils/routes";

import videoPlaySVG from "../../assets/image/video-play.svg";
import "video.js/dist/video-js.min.css";
import "@netless/window-manager/dist/style.css";
import "./ReplayPage.less";
import { ExitReplayConfirmModal } from "../../components/Modal/ExitReplayConfirmModal";
import { errorTips } from "../../components/Tips/ErrorTips";
Expand Down
2 changes: 1 addition & 1 deletion desktop/renderer-app/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 d0edfe0

Please sign in to comment.