Skip to content

Commit 27e74c1

Browse files
committed
refactor: change the split method of the IClip interface to be optional #324
1 parent 1d996cb commit 27e74c1

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

.changeset/strong-coins-walk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@webav/av-cliper': patch
3+
---
4+
5+
refactor: change the split method of the IClip interface to be optional #324

doc-site/docs/demo/2_6_1-custom-clip.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ class CountdownClip implements IClip {
1212

1313
ready;
1414

15+
get meta() {
16+
return {
17+
width: this.#cvsEl.width,
18+
height: this.#cvsEl.height,
19+
duration: this.#duration * 1e6,
20+
};
21+
}
22+
1523
constructor(duration: number) {
1624
this.#duration = duration;
1725
this.#cvsEl = document.createElement('canvas');
@@ -55,8 +63,8 @@ class CountdownClip implements IClip {
5563
};
5664
}
5765

58-
clone() {
59-
return new CountdownClip(this.#duration);
66+
async clone() {
67+
return new CountdownClip(this.#duration) as this;
6068
}
6169

6270
destroy() {

packages/av-cliper/src/clips/embed-subtitles-clip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export class EmbedSubtitlesClip implements IClip {
252252
}
253253

254254
/**
255-
* @see {@link IClip.destroy}
255+
* @see {@link IClip.split}
256256
*/
257257
async split(time: number) {
258258
await this.ready;

packages/av-cliper/src/clips/iclip.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ export interface IClip {
4242
clone: () => Promise<this>;
4343

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

5454
/**
5555
* 销毁实例,释放资源

0 commit comments

Comments
 (0)