Netless

Netless

  • JavaScript
  • Android
  • iOS
  • Server
  • FAQ
  • GitHub
  • 🇨🇳 中文

›Initialization

Document structure

  • Outline

Installation guide

  • SDK install
  • Version history
  • Open source
  • Debug

Quick start

  • Precondition
  • Room authentication
  • Real-time room
  • replay

Initialization

  • SDK parameters
  • Room parameters
  • Replay parameters

Features

  • Tools
  • Perspective operation
  • Page (scene) management
  • Status listen
  • Whiteboard operation
  • Custom event
  • Cursor position sync
  • Document conversion
  • Replay
  • Big class read-only
  • Plugins

Upgrade

  • SDK v2 migration

Replay parameters

room andplayer are actually subclasses of the internal displayer. In the TypeScript signature, the method signatures starting with/// Displayer.d.ts can be used in both room andplayer.

We will play back the room that was operated in the past, called ** playback room ** (the corresponding class is player`).

Initialize the API

TypeScript signature

//WhiteWebSdk.d.ts
replayRoom(params: ReplayRoomParams, callbacks?: PlayerCallbacks): Promise<Player>;

Sample

whiteWebSdk.replayRoom({
    room: "room",
    roomToken: "roomToken",
}, {
    onPhaseChanged: phase => {
        console.log(phase);
    },
    onLoadFirstFrame: () => {
        console.log("onLoadFirstFrame");
    },
    onPlayerStateChanged: modifyState => {
        console.log(modifyState);
    },
    onScheduleTimeChanged: scheduleTime => {
        console.log(scheduleTime);
    },
}).then(function(player) {
    window.player = player;
}).catch((e: Error) => {
    // Failed to initialize playback
    console.log(e);
});

ReplayRoomParams parameter Description

type ReplayRoomParams = {
    readonly slice?: string;
    readonly room?: string;
    readonly roomToken: string;
    readonly beginTimestamp?: number;
    readonly duration?: number;
    readonly mediaURL?: string;
    readonly cursorAdapter?: CursorAdapter;
    readonly cameraBound?: CameraBound;
}
parameterdescriptionremark
uuidUuid of playback roomRequired, and the room must be in playable mode
slicePlayback Room Fragment Addresssdk will find the data in the corresponding room according to the beginTimestamp and duration parameters, no need to fill in
roomTokenRoom authentication tokenrequire
beginTimestampUnix timestamp in milliseconds when playback startedOptional, if not filled, playback will start from room creation
durationPlayback duration (ms)Optional, if not filled, it will last until the last time all users log out
mediaURLAudio and video address (sdk is responsible for synchronous playback status)Optional. If there is, the whiteboard will uniformly play progress and playback status. When the whiteboard or media file enters the buffering state, it will be buffered (PlayerPhase enters the buffering state)

PlayerCallbacks Parameter Description

type PlayerCallbacks = {
    readonly onHandToolActive?: (active: boolean) => void;
    readonly onPPTLoadProgress?: (uuid: string, progress: number) => void;
    readonly onPhaseChanged?: (phase: PlayerPhase) => void;
    readonly onLoadFirstFrame?: () => void;
    readonly onPlayerStateChanged?: (modifyState: Partial<PlayerState>) => void;
    readonly onStoppedWithError?: (error: Error) => void;
    readonly onScheduleTimeChanged?: (scheduleTime: number) => void;
}

onHandToolActive

Hand tool activation / deactivation callback

onPPTLoadProgress

  • TypeScript signature
(uuid: string, progress: number) => void;
ppt preload cache callback, uuid is taskId during ppt conversion, and progress is two decimal places between 0 and 1.

This callback is only useful when the SDK is initialized with preloadDynamicPPT set to true

onPhaseChanged

export enum PlayerPhase {
    // After initialization, it is waiting for playback information. At this time, no operation can be performed, and player.state information cannot be obtained.
    WaitingFirstFrame = "waitingFirstFrame",
    // Playing
    Playing = "playing",
    // Stop
    Pause = "pause",
    // Aborted, unable to play again, new instance needs to be re-initialized
    Stopped = "stop",
    // Play completed
    Ended = "ended",
    // Buffering
    Buffering = "buffering",
}
Player state change callback

onLoadFirstFrame

The first frame of data is loaded, and the state of the room changes from `WaitingFirstFrame` to another state.

onPlayerStateChanged

This API is called back when the room status changes.
The `PlayerState` returned by this callback contains only the room state fields that have changed.

onStoppedWithError

An error occurred and the player stopped playing.

onScheduleTimeChanged

Time progress callback

Recommended reading

  1. Status monitoring
  2. Custom events-listen, logout
Last updated on 1/13/2020 by 伍双
← Room parametersTools →
  • Initialize the API
    • TypeScript signature
    • Sample
  • ReplayRoomParams parameter Description
  • PlayerCallbacks Parameter Description
    • onHandToolActive
    • onPPTLoadProgress
    • onPhaseChanged
    • onLoadFirstFrame
    • onPlayerStateChanged
    • onStoppedWithError
    • onScheduleTimeChanged
  • Recommended reading
Netless
Let's interactive.
Product
ConsoleHomepageDemoGithub
Company
Join usServicePrivacy
Contact
support@netless.linkCommunity
Copyright © 2020 Netless