Contact us

tel:15797766463

mail:business@seeshiontech.com

中文
English
中文
登录/注册

{user.username}

ID: {user.id}

<span><a href="/docs/index.html">首页</a> > <a href="/docs/en-us/editor/group_123.html">SDK</a> > <a href="/docs/en-us/editor/group_129.html">iOS SDK</a> > SXEditManager</span>

SXEditManager

Update time : 2020-08-11 16:15:58

SXEditManager can manage all resources of editing process such as groups, tracks, and effects etc. Each instance object manages only the resources it generates, which will take up a lot of memory. And we recommend you do not create multiple instances at the same time.

//example:
SXEditOptions *options = [[SXEditOptions alloc] init];
//The license needs to be verified. All actions will not work if the license is invalid, please check the console print. 
options.license = @&quot;Your License&quot;;
//Customize rendering width. 
options.width = 720;
//Customize rendering height.  
options.height = 1280;
//Set a global default font.
options.fontFile = @“default font path”;
/**
* Initialize SXEditManager.
* @param options Initialization parameters. Be Effective after initialization, be invalid when post-modification.
*/
SXEditManager *editManager = [[SXEditManager alloc] initWithOptions:options];
//example:
// Get the view of rendering result in editManager.
UIView *playView = [_editManager getPlayerView];
int videoWidth = _editManager.options.width;
int videoHeight = _editManager.options.height;

_playerScale =  1 / [SXUICalculateUtil getScale:CGSizeMake(videoWidth, videoHeight) maxSize:_videoContentView.bounds.size];

playView.bounds = CGRectMake(0, 0, videoWidth * _playerScale, videoHeight * _playerScale);
playView.center = CGPointMake(_videoContentView.bounds.size.width / 2, _videoContentView.bounds.size.height / 2);
[_videoContentView addSubview:playView];
//Start previewing the contents in the current edit and get the playback progress in the callback. 
[_editManager start];
/**
*Get main track group, and the tracks in the group will be connected in time order. 
* @note The track group is created by default and can not be deleted. 
* @warning Return the pointer of the instance object of main track only when the license is valid, otherwise return nullptr. 
* @note Only Media track can be inserted into main track. 
* @return The instance object of main track, returns nullptr if license is invalid. 
*/
- (SXMainTrackGroup *)mainGroup;
/**
* The corresponding group is obtained via ID, which can be gotten via class method uuid. 
* @param groupId The uuid of group
* @return The instance object of group will return nullptr when no corresponding group exists. 
*/
- (SXTrackGroup *)group:(NSString *)groupId;
/**
* Add a new group at the end.
* @return Instance object of new group.
*/
- (SXTrackGroup *)addNewGroup;
/**
* Groups are saved orderly, so you can insert a group at where index is.
* @param index Index of position.  When the number of index is over that of group, it is equivalent to addNewGroup.
* @return Instance object of new group.
*/
- (SXTrackGroup *)insertNewGroupAt:(int)index;
/**
* You can delete a group with ID; all tracks will be removed but not be deleted if any track exists in the group. 
* @param groupId The unique ID of group. 
*/
- (void)removeGroup:(NSString *)groupId;
/**
* Get all groups.
* @return All groups saved orderly.
*/
- (NSArray *)groups;
/example:
//Create media track.
SXMediaTrack *track = [_editManager createMediaTrack:filePath];
//If media track is created successfully, the return value is not null. If the file path contains image, the duration is 3 seconds by default. If the file path contains videos or Gifs, the duration of those is the duration of track. 
if (track) {
//Add track to main track group. 
    if ([_editManager.mainGroup addTrack:track startTime:_editManager.mainGroup.duration]) {
        [track fitToEditContext:NO margin:0];
    }
}
//Start rendering the footage in the current management, and the rendering process and the rendering result can be gotten in the callback. 
[_editManager startRender];
//Some resources can be released with invoking stop method. 
[_editManager stop];