Synchronize video and whiteboard playback projects
import CombinePlayerFactory from "netless-combine-player";
whiteWebSdk.replayRoom({ room, roomToken })
.then(async (player) => {
const combinePlayerFactory = new CombinePlayerFactory(player, {
url: "video url",
videoDOM: videoEle.current as HTMLVideoElement,
});
const combinePlayer = combinePlayerFactory.create();
combinePlayer.setOnStatusChange((status, message) => {
console.log("status change:", status, message);
});
await combinePlayer.play();
await combinePlayer.seek(1000 * 60);
await combinePlayer.pause();
});
new CombinePlayerFactory(whiteboard, videoOptions, debug);
Generated by the replayRoom
function
type: Player
Video configuration items
type: VideoOptions
Type Details:
videoOptions: {
url: string; // video url address
videoDOM?: HTMLVideoElement // Which video tag to mount to(If you do not pass in, it will automatically create one)
videoJsOptions?: import("video.js").VideoJsPlayerOptions // video.js options(see: https://docs.videojs.com/tutorial-options.html)
}
videoJsOptions
defaults is:
{
preload: "auto"
}
Whether to enable debug log
type: boolean
default is: false
whiteWebSdk.replayRoom({ room, roomToken })
.then(player => {
const combinePlayerFactory = new CombinePlayerFactory(player, {
url: "video url",
videoDOM: videoEle.current as HTMLVideoElement,
});
});
Create an instance of the CombinePlayer and return
const combinePlayer: CombinePlayer = combinePlayerFactory.create();
return type: CombinePlayer
Get the video element
This method can come in handy when the CombinePlayerFactory
method is used and no videoDOM
is passed in
const videoDOM: HTMLVideoElement = combinePlayerFactory.getVideoDOM();
return type: HTMLVideoElement
Register a callback function to notify when the status changes
combinePlayer.setOnStatusChange(statusOnChange);
type: StatusChangeHandle
const statusOnChange = (status: PublicCombinedStatus, message: string): void => {
console.log("status change:", status, message);
}
combinePlayer.setOnStatusChange(statusOnChange);
Remove the specified status notification callback
combinePlayer.removeStatusChange(statusOnChange);
type: StatusChangeHandle
const statusOnChange = (status: PublicCombinedStatus, message: string): void => {
console.log("status change:", status, message);
}
combinePlayer.setOnStatusChange(statusOnChange);
combinePlayer.removeStatusChange(statusOnChange);
Remove all status notification callbacks
combinePlayer.removeAllStatusChange();
Actively obtain the current status
combinePlayer.getStatus()
return type: PublicCombinedStatus
Start synchronized playback
return type: Promise<void>
combinePlayer.play();
// or
await combinePlayer.play();
Pause video
and whiteboard
return type: Promise<void>
combinePlayer.pause();
// or
await combinePlayer.pasue();
combinePlayer.seek(ms)
Synchronously jump to the specified millisecond timestamp
return type: Promise<void>
combinePlayer.seek(1000);
// or
await combinePlayer.seek(1000);