diff --git a/.changeset/strong-coins-walk.md b/.changeset/strong-coins-walk.md new file mode 100644 index 00000000..df702daa --- /dev/null +++ b/.changeset/strong-coins-walk.md @@ -0,0 +1,5 @@ +--- +'@webav/av-cliper': patch +--- + +refactor: change the split method of the IClip interface to be optional #324 diff --git a/doc-site/docs/demo/2_6_1-custom-clip.tsx b/doc-site/docs/demo/2_6_1-custom-clip.tsx index bde9c81c..e074def1 100644 --- a/doc-site/docs/demo/2_6_1-custom-clip.tsx +++ b/doc-site/docs/demo/2_6_1-custom-clip.tsx @@ -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'); @@ -55,8 +63,8 @@ class CountdownClip implements IClip { }; } - clone() { - return new CountdownClip(this.#duration); + async clone() { + return new CountdownClip(this.#duration) as this; } destroy() { diff --git a/packages/av-cliper/src/clips/embed-subtitles-clip.ts b/packages/av-cliper/src/clips/embed-subtitles-clip.ts index ef2a7595..ddda64f4 100644 --- a/packages/av-cliper/src/clips/embed-subtitles-clip.ts +++ b/packages/av-cliper/src/clips/embed-subtitles-clip.ts @@ -252,7 +252,7 @@ export class EmbedSubtitlesClip implements IClip { } /** - * @see {@link IClip.destroy} + * @see {@link IClip.split} */ async split(time: number) { await this.ready; diff --git a/packages/av-cliper/src/clips/iclip.ts b/packages/av-cliper/src/clips/iclip.ts index 30b6c066..2c82e880 100644 --- a/packages/av-cliper/src/clips/iclip.ts +++ b/packages/av-cliper/src/clips/iclip.ts @@ -42,14 +42,14 @@ export interface IClip { clone: () => Promise; /** - * 按指定时间切割,返回该时刻前后两个新素材 + * 按指定时间切割,返回该时刻前后两个新素材,常用于剪辑场景按时间分割素材 * * 该方法不会破坏原素材的数据 * * @param time 时间,微秒 * @returns */ - split: (time: number) => Promise<[this, this]>; + split?: (time: number) => Promise<[this, this]>; /** * 销毁实例,释放资源