/// Initialize preview player/// - Parameter param: Requires a parent container and rendering mode- (void)setPreview:(TAVPreviewParam *)param;/// Set loop playback/// - Parameter isLoop: Whether to enable loop playback- (void)setPlayLoop:(BOOL)isLoop;- (BOOL)isPlayLoop;/// Play- (void)play;/// Start playback from a specified time/// - Parameter time: Start playback time- (void)playAtTime:(CMTime)time;/// Pause- (void)pause;/// Stop- (void)stop;/// Refresh preview player- (void)refresh;//- (void)replay;/// Seek to the specified time for playback/// - Parameter seekTime: Specified playback time- (void)seekToTime:(CMTime)seekTime;/// Seek to the specified time for playback/// - Parameters:/// - seekTime: Specified playback time/// - completion: Seek completion callback- (void)seekToTime:(CMTime)seekTime completion:(void (^)(BOOL finished))completion;/// Get total preview duration (requires calling flushImmediately after adding assets for accurate result)- (CMTime)getTotalDuration;/// Total duration of the main track (available immediately after adding assets)- (NSTimeInterval)duration;/// Whether playback is in progress- (BOOL)isPlaying;/// Current playback time- (NSTimeInterval)currentTime;- (CMTime)currentCMTime;/// Set preview fill mode/// - Parameter fillMode: Fill mode- (void)setPlayerViewFillMode:(TAVPlayerFillMode)fillMode;/// Get player fill mode- (TAVPlayerFillMode)playerViewFillMode;/// Register playback state observer/// - Parameter observer: Observer- (void)registerPlayerObserver:(id<TAVEditorPlayerObserver>)observer;/// Unregister playback state observer/// - Parameter observer: Observer- (void)resignObserver:(id<TAVEditorPlayerObserver>)observer;// Set current render size- (void)setRenderSize:(CGSize)renderSize;/// Get current render size- (CGSize)getRenderSize;//- (void)setPainting:(int)fillModel color:(NSString *)hexColor;/// Get the complete AVAsset of the current player- (AVAsset *)currentAVAsset;/// Get the complete AVVideoComposition of the current player- (AVVideoComposition *)currentComposition;
/// Append video asset to the end/// - Parameter path: Video asset path/// - return: Index after successful addition- (int)addVideoClip:(NSString *)path;/// Add video asset at a specified position/// - Parameters:/// - paths: Array of video asset paths/// - index: Insert position- (int)addVideoClips:(NSArray *)paths index:(int)index;/// Append image asset to the end/// - Parameters:/// - path: Image asset path/// - duration: Display duration of the image asset. Pass kCMTimeZero for the default 3 seconds- (int)addImageClip:(NSString *)path duration:(CMTime)duration;/// Add image asset at a specified position/// - Parameters:/// - path: Image asset path/// - index: Insert position/// - durations: Display durations in seconds. Pass @(0) for the default 3 seconds- (int)addImageClips:(NSArray<NSString *> *)paths index:(int)index durations:(NSArray<NSNumber *> *)durations;/// Get the number of assets currently being edited/// @return Number of assets- (int)getClipCount;/// Get current asset information- (NSArray<TAVClipInfo *> *)getClipInfos;/// Remove video or image asset at the specified position/// - Parameter index: Asset index- (void)removeClip:(int)index;/// Remove all asset (video/image/template) clips- (void)removeAllClip;/// Clear all assets (video & BGM) and all effects (sticker & filter & motion)- (void)clearAll;/// Modify the duration of a specific asset/// - Parameters:/// - timeRange: Asset playback range/// - index: Asset index- (void)setClipRange:(CMTimeRange)timeRange index:(int)index;/// Modify the speed of a specific asset/// - Parameters:/// - speed: Speed rate (0, 3]/// - index: Asset index- (void)setClipSpeed:(CGFloat)speed index:(int)index;/// Adjust asset position/// - Parameters:/// - oldIndex: Original index before reordering/// - newIndex: New index after reordering- (BOOL)updateClipIndex:(int)oldIndex toIndex:(int)newIndex;/// This method must be called after modifying assets/BGM to regenerate playback resources/// Method logic: 1. Synchronously generate player resources. 2. Bind resources to the player. 3. Restore state (asynchronous): playback state and current time./// Since this method has asynchronous state, calling player operations like getting time or playback status immediately after may produce errors. Use the completion callback in the second parameter instead.- (void)flushImmediately;- (void)flushImmediatelyCompletion:(void (^)(BOOL finished))completion;/// flushImmediately executes the following two steps separately, as it is a time-consuming operation with the main overhead in the preparePlayerItem method./// Therefore, the method is separated for finer-grained performance control. You can call the following two methods to achieve the same result as flushImmediately- (AVPlayerItem *)preparePlayerItem;- (void)bindPlayerItem:(AVPlayerItem *)playerItem completion:(void (^)(BOOL finished))completion;/// Set background volume for the specified asset/// - Parameters:/// - volume: Volume (0-1f)/// - index: Asset index- (void)setClipVolume:(float)volume index:(int)index;/// Set background volume for all assets/// - Parameters:/// - volume: Volume (0-1f)- (void)setAllClipsVolume:(float)volume;/// Get volume of the asset at the specified index/// - Parameter index: Asset- (float)getClipVolume:(int)index;/// Set whether to reverse video playback (todo)- (void)setReverse:(BOOL)isReverse;/// Set video rotation angle (clockwise)/// - Parameter rotation: Clockwise rotation angle (0-360)- (void)setClipsRotation:(int)rotation;/// Set video rotation angle by index/// - Parameters:/// - rotation: Clockwise rotation angle (0-360)/// - index: Asset index- (void)setClipRotation:(int)rotation index:(int)index;/// Set asset transform- (void)setClipTransform:(CGAffineTransform)transform;- (void)setClipTransform:(CGAffineTransform)transform index:(int)index;- (void)setClipSize:(CGSize)size;- (void)setClipSize:(CGSize)size index:(int)index;- (void)setCropInfo:(TAVMediaAssetCropInfo *)cropInfo index:(int)index;
/* Preview initialization */TAVPreviewParam *previewParam = [[TAVPreviewParam alloc] init];// Container for preview displaypreviewParam.videoView = [(TAVPreviewView *)_previewView playerView];previewParam.fillMode = TAVPlayerFillModeAspectFit;previewParam.observer = self;previewParam.widgetContentView = self.widgetContentView;[self.editor setPreview:previewParam];/* Add data source */// Add video resource[editor addVideoClip:@"video_path"];// Add image resource[editor addImageClip:imageUrl.path duration:kCMTimeZero];// Refresh current frame to apply resources[editor flushImmediately];
/// Generate and export video/// - Parameters:/// - exportConfig: Video export configuration. Pass nil to use default settings (resolution matches preview, 30 fps, bitrate 8*1000*1000)/// - progressBlock: Video export progress callback/// - completion: Video export completion callback- (void)generateVideo:(TAVEditorGenerateConfig *)configoutputPath:(NSString *)outputPathprogress:(void (^)(CGFloat progress))progressBlockcompletion:(void (^)(NSError *error, NSString *outputPath))completion;/// Generate and export video/// - Parameters:/// - TAVVideoCompressed: Export resolution/// - progressBlock: Video export progress callback/// - completion: Video export completion callback- (void)generateVideoWithCompressed:(TAVVideoCompressed)compressedoutputPath:(NSString *)outputPathprogress:(void (^)(CGFloat progress))progressBlockcompletion:(void (^)(NSError *error, NSString *outputPath))completion;/// Quickly generate and export video/// - Parameters:/// - exportConfig: Video export configuration. Pass nil to use default settings (resolution matches preview, 30 fps, bitrate 8*1000*1000)/// - progressBlock: Video export progress callback/// - completion: Video export completion callback- (void)quickGenerateVideo:(TAVEditorGenerateConfig *)configoutputPath:(NSString *)outputPathprogress:(void (^)(CGFloat progress))progressBlockcompletion:(void (^)(NSError *error, NSString *outputPath))completion;/// Quickly generate and export video/// - Parameters:/// - TAVVideoCompressed: Export resolution/// - progressBlock: Video export progress callback/// - completion: Video export completion callback- (void)quickGenerateVideoWithCompressed:(TAVVideoCompressed)compressedoutputPath:(NSString *)outputPathprogress:(void (^)(CGFloat progress))progressBlockcompletion:(void (^)(NSError *error, NSString *outputPath))completion;/// Cancel video generation/// - Parameter completion: Cancellation completion callback- (void)cancelGenerate:(void(^ __nullable)(void))completion;/// Pause export- (void)pauseGenerate;/// Resume export- (void)resumeGenerate;
フィードバック