Skip to content

Moskize91/netless-combine-player

 
 

Repository files navigation

netless-combine-player

Synchronize video and whiteboard playback projects

中文文档

Usages

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();
    });

API

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

Example:

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

Example:

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

Example:

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>

Example:

combinePlayer.play();
// or
await combinePlayer.play();

Pause video and whiteboard

return type: Promise<void>

Example:

combinePlayer.pause();
// or
await combinePlayer.pasue();
combinePlayer.seek(ms)

Synchronously jump to the specified millisecond timestamp

return type: Promise<void>

Example:

combinePlayer.seek(1000);
// or
await combinePlayer.seek(1000);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 92.2%
  • JavaScript 7.8%