tencent cloud

User Generated Short Video SDK

Android

Download
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-05-11 17:46:58

Feature Overview

Through the draft-related APIs, you can implement undo and redo during short video editing, and export to the draft box for continued editing next time.
TAVDraftManager provides draft management features, including setting the storage directory, reading/deleting drafts, generating/loading drafts, and undo/redo operations.

Related API Classes

API Class Name
Description
TAVDraftManager
Draft operation manager class.

Related Methods

Set Draft Storage Directory

/**
* Sets the directory for saving drafts
* @param storageDir storage directory path
*/
public static void setDraftStorageDir(String storageDir);

Read Draft List

/**
* Reads all drafts in the draft storage directory
* @return list of drafts sorted in reverse chronological order
*/
public static List<TAVDraft> readDraftList();

Delete Draft

/**
* Deletes the specified draft
* @param draft draft object to delete
* @return whether deletion succeeds
*/
public static boolean deleteDraft(TAVDraft draft);

/**
* Deletes all drafts
* @return whether deletion succeeds
*/
public static boolean deleteAllDrafts();

Generate Draft

/**
* Saves the current editing state as a draft
* @param consumer callback that receives the saved draft path
*/
public abstract void generateDraft(TAVConsumer<String> consumer);

Load Draft

/**
* Loads the specified draft
* @param draft draft object to load
* @param callback loading result callback
*/
public abstract void loadDraft(TAVDraft draft, DraftLoadingCallback callback);

Undo/Redo Operations

Commit Checkpoint

/**
* Commits the current editing state
* @param tag tag value
* @return whether this commit takes effect
*/
public abstract boolean commit(String tag);

State Check

/**
* Checks whether undo is available
* @return whether undo is available
*/
public abstract boolean canUndo();

/**
* Checks whether redo is available
* @return whether redo is available
*/
public abstract boolean canRedo();

Perform Operations

/**
* Performs the undo operation
* @param callback operation result callback
*/
public abstract void undo(DraftActionCallback callback);

/**
* Performs the redo operation
* @param callback operation result callback
*/
public abstract void redo(DraftActionCallback callback);

State Listeners

Set State Listener

/**
* Sets the draft state listener
* @param listener state listener
*/
public abstract void setDraftStateListener(DraftStateListener listener);

Set Component Change Observer

/**
* Sets the draft component change observer
* @param observer component observer
*/
public abstract void setDraftComponentObserver(DraftComponentObserver observer);

Draft State Listener

public interface DraftStateListener {
/**
* Undo availability state changed
* @param canUndo whether undo is available
*/
void onUndoStateChange(boolean canUndo);

/**
* Redo availability state changed
* @param canRedo whether redo is available
*/
void onRedoStateChange(boolean canRedo);
}

Operation Callback

public interface DraftActionCallback {
/**
* Callback when the operation is completed
* @param tag tag value used during commit
* @param diffResult change result
*/
void onCheckoutDraft(String tag, TAVDiffResult diffResult);

/**
* Callback when the operation fails
* @param errorCode error code
*/
void onError(int errorCode);
}
Error Codes for errorCode:
Error Code
Constant Name
Description
1
ERROR_NOT_COMMITTED
Draft has not been committed.
100
ERROR_SDK_INTERNAL
Internal SDK error.
101
ERROR_RESOURCE_NOT_FOUND
Resource does not exist.
102
ERROR_RESOURCE_INVALID
Invalid resource format.
-1
ERROR_UNKNOWN
Unknown error.

Callback Interfaces

Component Observer

public interface DraftComponentObserver {
/**
* Component update callback
* @param component updated draft component
*/
void onComponentUpdate(TAVDraftComponent component);
}

Usage Example

// Set the draft storage directory
TAVDraftManager.setDraftStorageDir("/sdcard/drafts/");

// Read the draft list
List<TAVDraft> drafts = TAVDraftManager.readDraftList();

// Load a draft
tavEditor.getDraftManager().loadDraft(drafts.get(0), new DraftLoadingCallback() {
@Override
public void onDraftLoadingFinished(DraftLoadingResult result) {
if (result.isSuccess()) {
// Load succeeded
} else {
// Handle the error
}
}
});

// Commit the current state
boolean committed = tavEditor.getDraftManager().commit("auto_save");

// Set the state listener
tavEditor.getDraftManager().setDraftStateListener(new DraftStateListener() {
@Override
public void onUndoStateChange(boolean canUndo) {
// Update the UI state of the undo button
}

@Override
public void onRedoStateChange(boolean canRedo) {
// Update the UI state of the redo button
}
});


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백