mirror of
https://github.com/motion-canvas/motion-canvas.git
synced 2026-01-11 06:48:12 -05:00
feat(2d): add video component property getter (#240)
I added get functions (`isPlaying`, `getCurrentTime` and `getDuration`) to provide access to these properties which is needed in some cases. Before there was a 'hacky' way of accessing them via the `indexing operator` (`[]`). ```ts videoRef()['playing']() ``` With these changes these properties can be used in a cleaner and secure way without interfering with core logic. ```ts videoRef().isPlaying() ```
This commit is contained in:
@@ -51,6 +51,18 @@ export class Video extends Rect {
|
||||
super(props);
|
||||
}
|
||||
|
||||
public isPlaying(): boolean {
|
||||
return this.playing();
|
||||
}
|
||||
|
||||
public getCurrentTime(): number {
|
||||
return this.time();
|
||||
}
|
||||
|
||||
public getDuration(): number {
|
||||
return this.video().duration;
|
||||
}
|
||||
|
||||
protected override desiredSize(): SerializedVector2<Length> {
|
||||
const custom = super.desiredSize();
|
||||
if (custom.x === null && custom.y === null) {
|
||||
|
||||
Reference in New Issue
Block a user