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 certain PPT document Scene path -> the absolute position of a certain 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 a file similar to 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.
The scene directory and the 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.
@interface WhiteRoom: NSObject
/** Get the current scene state */
-(void)getSceneStateWithResult:(void (^) (WhiteSceneState *state))result;
/** Get current scene directory, all scene information */
-(void)getScenesWithResult:(void (^) (NSArray<WhiteScene *> *scenes))result;
@end
Through the above API, the current scene information content and the specific content structure can be viewed in each SDK.
2.7.4 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.
@interface WhiteDisplayer: NSObject
/**
* Get a list of all scenes in the room, the return format:
* Scene directory path: an array of all pages in the corresponding scene directory
* The key is the scenepath, and the value is the WhiteScene array.
* There are only rooms in /init, the return structure is:
* {"/": @[init WhiteScene]}
*/
-(void)getEntireScenes:(void (^) (NSDictionary<NSString *, NSArray<WhiteScene *>*> *dict))result;
@end
2.6.3 New API
@interface WhiteDisplayer: NSObject
/**
* The content corresponding to the query path is still a page (scene), or a page (scene) directory, or there is no content.
* See WhiteScenePathType class description for query results
*/
-(void)getScenePathType:(NSString *)pathOrDir result:(void (^) (WhiteScenePathType pathType))result;
@end
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
.
@interface WhiteRoom: NSObject
-(void)setScenePath:(NSString *)path;
@end
//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.
@interface WhiteRoom: NSObject
/**
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 in NSUIntegerMax.
*/
-(void)putScenes:(NSString *)dir scenes:(NSArray<WhiteScene *> *)scenes index:(NSUInteger)index;
@end
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.
@interface WhiteRoom: NSObject
/**
Move/rename page
@param source The absolute path of the page you want to move
@param target target path. If it is a folder, move the source in; otherwise, rename it while moving.
*/
-(void)moveScene:(NSString *)source target:(NSString *)target;
@end
@interface WhiteRoom: NSObject
/**
@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.
*/
-(void)removeScenes:(NSString *)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.
2.3.0 New API, playback room and real-time room, both support this function
The size of the screenshot is the size of the current playback/real-time room display.
// This class is the parent class of WhiteRoom and WhitePlayer
@interface WhiteDisplayer: NSObject
/**
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
*/
-(void)getScenePreviewImage:(NSString *)scenePath completion:(void (^)(UIImage * _Nullable image))completionHandler;
/**
A screenshot of the scene cover, which will contain 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
*/
-(void)getSceneSnapshotImage:(NSString *)scenePath completion:(void (^)(UIImage * _Nullable image))completionHandler;
@end
First, we need to know the scene classes: WhiteScene
and WhitePptPage
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 WhitePptPage 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.
@interface WhitePptPage: WhiteObject
//The map's address
@property (nonatomic, copy) NSString *src;
@property (nonatomic, assign) CGFloat width;
@property (nonatomic, assign) CGFloat height;
@end
The center of the picture is the center point of the whiteboard page.
@interface WhiteScene: WhiteObject
-(instancetype)init;
-(instancetype)initWithName:(nullable NSString *)name ppt:(nullable WhitePptPage *)ppt;
@property (nonatomic, copy, readonly) NSString *name;
//You can judge whether the page has content by whether the attribute is 0. (This number does not calculate ppt, and it is also 0 when there is only ppt).
@property (nonatomic, assign, readonly) NSInteger componentsCount;
@property (nonatomic, strong, readonly, nullable) WhitePptPage *ppt;
@end
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.
@interface WhiteSceneState: WhiteObject
//All scenes in the current scene group
@property (nonatomic, nonnull, strong, readonly) WhiteScene *scenes;
//Current scene group directory
@property (nonatomic, nonnull, strong, readonly) NSString *scenePath;
//The current scene, the index position in the scenes array.
@property (nonatomic, assign, readonly) NSInteger index;
@end
This class describes the status of the current scene directory.