Skip to content

Commit

Permalink
refactor: change the split method of the IClip interface to be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
hughfenghen committed Nov 18, 2024
1 parent 1d996cb commit 27e74c1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-coins-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@webav/av-cliper': patch
---

refactor: change the split method of the IClip interface to be optional #324
12 changes: 10 additions & 2 deletions doc-site/docs/demo/2_6_1-custom-clip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ class CountdownClip implements IClip {

ready;

get meta() {
return {
width: this.#cvsEl.width,
height: this.#cvsEl.height,
duration: this.#duration * 1e6,
};
}

constructor(duration: number) {
this.#duration = duration;
this.#cvsEl = document.createElement('canvas');
Expand Down Expand Up @@ -55,8 +63,8 @@ class CountdownClip implements IClip {
};
}

clone() {
return new CountdownClip(this.#duration);
async clone() {
return new CountdownClip(this.#duration) as this;
}

destroy() {
Expand Down
2 changes: 1 addition & 1 deletion packages/av-cliper/src/clips/embed-subtitles-clip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export class EmbedSubtitlesClip implements IClip {
}

/**
* @see {@link IClip.destroy}
* @see {@link IClip.split}
*/
async split(time: number) {
await this.ready;
Expand Down
4 changes: 2 additions & 2 deletions packages/av-cliper/src/clips/iclip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ export interface IClip {
clone: () => Promise<this>;

/**
* 按指定时间切割,返回该时刻前后两个新素材
* 按指定时间切割,返回该时刻前后两个新素材,常用于剪辑场景按时间分割素材
*
* 该方法不会破坏原素材的数据
*
* @param time 时间,微秒
* @returns
*/
split: (time: number) => Promise<[this, this]>;
split?: (time: number) => Promise<[this, this]>;

/**
* 销毁实例,释放资源
Expand Down

0 comments on commit 27e74c1

Please sign in to comment.