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:
Tan to the Dashi
2023-02-09 10:25:11 +01:00
committed by GitHub
parent 6b4f9a2a75
commit 59de5ab2c0

View File

@@ -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) {