In order to enhance the page management function of the whiteboard, we introduce a new concept: scene.
Scene
is a page of the whiteboard we have been using.
A scene
mainly contains two parts: scene name
and PPT (background image)
.
When managing multiple scenes, we want to get a specific scene, at this time we need scene path
. Each scene path
points to a specific scene.
Analyze the concept of PC files and folders.
Scene->File
Scene Directory->Folder Path
Scene Path->File Absolute Address
Analyze the concept of courseware management.
Scene->The name of a page of the PPT document
Scene directory-> The location of a PPT file
Scene path-> The absolute position of a page of the PPT document
The following is a set of legal scene path
.
/init
/Eng/ppt1
/Eng/ppt2
/Eng/ppt3
/Phy/ppt1
/Phy/ppt2
/Phy/ppt3
Scene path
is divided into levels with /
and must start with /
. The rightmost level is the name of the scene.
You can also use the following format to represent the file structure to represent this set of scenes.
|____init (scene)
|____Eng (Scene Directory)
| |____ppt1 (scene)
| |____ppt3 (scene)
| |____ppt2 (scene)
|____Phy (Scene directory)
| |____ppt1 (scene)
| |____ppt3 (scene)
| |____ppt2 (scene)
There can be multiple scenes
in the same scene directory
;
Then /Phy
has the following three scenes
under the scene directory
.
The uniqueness of the scene path:
The concept of similar files, each scene path, points to a unique scene.
When using the move, copy, or insert scene API, if a specific scene already exists in the path passed in, the scene will be overwritten by the new scene.
Scene directory and scene path cannot be the same:
When there is a scene with the scene path/Eng/ppt1
in the whiteboard room, it is impossible to exist/accept a scene named/Eng
. Becausescene path
is composed ofscene directory
andscene name
.
If this happens, the insertion will fail.
The APIs involved in this document are all methods of the whiteboard Room
(iOS: WhiteRoom
). It can also be viewed in the corresponding sdk file.
//Room.Java
/** Get the current scene state */
public void getSceneState(final Promise<SceneState> promise)
/** Get current scene directory, all scene information */
public void getScenes(final Promise<Scene[]> promise)
Through the above API, the current scene information content and the specific content structure can be viewed in each SDK.
2.7.3 New API
Get the room and all current scene information, and return it in dictionary format, the key is the address of the scene directory, and the value is the list of all pages (scene) in the directory.
//Displayer.java
/**
* Get all the whiteboard page information in the current room
* @param promise returns a map, the key is the address of the scene directory, and the value is the array of all Scenes in the directory.
*/
public void getEntireScene(final Promise<Map<String, Scene[]>> promise)
2.6.4 New API
//Displayer.java
/**
* The content corresponding to the query path is still a page (scene), or a page (scene) directory, or there is no content.
* @param path The path to query
* @param promise callback result, for specific content, please check {@link WhiteScenePathType}
*/
public void getScenePathType(String path, final Promise<WhiteScenePathType> promise)
The current scene represents the page that everyone sees in the whiteboard room.
When creating a whiteboard room, there will be a default scene
called init
. His scene directory
is /
, and his scene path
is /init
.
If you want to modify the current scene and move to another scene, you only need to call the following API and pass in the scene path
.
//Room.Java
public void setScenePath(String path)
//example code
room.setScenePath:"/Phy/ppt1";
When the switching API does not respond, or an error is reported in the callback, it may be the following situations:
- The path is illegal. Please read the previous chapters and make sure that the
scene path
entered is in compliance with the specification (beginning with/
).- The
scene
corresponding to the path does not exist.- The path corresponds to the
scene directory
. Note that theScene Directory
is not the same as the scene.
//Room.java
/**
Insert, maybe create multiple pages
@param dir scene page group name, equivalent to directory
@param scenes WhiteScence instance; when generating WhiteScence, ppt can be configured at the same time
@param index Select the position to insert in the page group. index is the index position of the new scence. If you want to put it at the end, you can pass Integer.MAX_VALUE.
*/
public void putScenes(String dir, Scene[] scenes, int index)
Insert the scene API, accepting three parameters:
Scene directory
, the corresponding directory location where the scene wants to be inserted.scene directory
, if you want to add a blank page after page 3, set the index Is 3.The incoming
scene directory
(dir) cannot be thescene path
of an existing scene. (You cannot insert files into the file)
When the newly inserted scene,
scene path
(dir + scene name) is the same as thescene path
of the old scene, the newscene
will overwrite the oldscene
. (The new file will overwrite the old file)
Similar to the mv command of Linux, macOS.
//Room.Java
/**
Move/rename page
@param source The scene path of the page you want to move
@param target target path. If it is a scene directory, move the source into it; otherwise, rename it while moving.
*/
public void moveScene(String source, String target)
// Room.java
/**
@param dirOrPath Scene path, or scene directory. If the scene path is passed in, the scene path is removed. If the incoming scene directory is a scene directory, all scenes in the scene directory will be removed.
*/
public void removeScenes(String dirOrPath)
You can pass in "/"
to this parameter to clear all scenes in the blank board room.
At least one scene will exist in the whiteboard room.
Therefore, when you delete the last scene in the whiteboard room, a blank scene named init with the scene path "/init" will be automatically generated immediately.
/**
The content of the scene that the user sees when switching is intercepted, not all the content in the scene.
FIXME: Picture support: only when the picture server supports cross-domain, it can be displayed in the screenshot
@param scenePath The scene path of the scene where you want to intercept, for example /init; if there is no scene path entered, a blank picture will be returned
@param completionHandler callback function, image may be empty
*/
public void getScenePreviewImage(String scenePath, final Promise<Bitmap>promise) {}
public void getSceneSnapshotImage(String scenePath, final Promise<Bitmap>promise) {}
First, we need to know the scene class: SceneState
and PptPage
classes.
Please note: The classes in the SDK are all configuration data, used to transfer data to the whiteboard, and do not hold any whiteboard instances
The PptPage class is the configuration information related to ppt. Passed in when creating the WhiteScene class, and then when inserting the scene API, a whiteboard page with background image is generated.
public PptPage(String src, Double width, Double height)
The center of the picture is the center point of the whiteboard page.
public Scene(String name, PptPage ppt)
WhiteScene managed a whiteboard page, which contained the name, and took over the original ppt content.
The whiteboard page only accepts ppt parameters when it is created.
public class SceneState {
//All pages in the current scene directory
public Scene[] getScenes() {
return scenes;
}
//Current scene path
public String getScenePath() {
return scenePath;
}
//The index of the current scene in Path
public int getIndex() {
return index;
}
}
This class describes the status of the current scene directory.