@zcomponent/core 1.1.0 → 1.3.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/lib/animation/clips/clip.d.ts +3 -2
  2. package/lib/animation/clips/clip.js +20 -4
  3. package/lib/animation/index.d.ts +1 -0
  4. package/lib/animation/index.js +1 -0
  5. package/lib/animation/layerclip.d.ts +2 -0
  6. package/lib/animation/layerclip.js +18 -5
  7. package/lib/animation/stream.d.ts +1 -0
  8. package/lib/animation/tracks/cliptrack.d.ts +4 -0
  9. package/lib/animation/tracks/cliptrack.js +25 -0
  10. package/lib/animation/tracks/streamtrack.d.ts +39 -0
  11. package/lib/animation/tracks/streamtrack.js +144 -0
  12. package/lib/behaviors/ActivateState.d.ts +48 -0
  13. package/lib/behaviors/ActivateState.js +39 -0
  14. package/lib/behaviors/stream/PauseStream.d.ts +22 -0
  15. package/lib/behaviors/stream/PauseStream.js +26 -0
  16. package/lib/behaviors/stream/PlayStream.d.ts +45 -0
  17. package/lib/behaviors/stream/PlayStream.js +37 -0
  18. package/lib/behaviors/stream/SeekStream.d.ts +29 -0
  19. package/lib/behaviors/stream/SeekStream.js +33 -0
  20. package/lib/behaviors/stream/StopStream.d.ts +22 -0
  21. package/lib/behaviors/stream/StopStream.js +26 -0
  22. package/lib/components/Audio.d.ts +59 -0
  23. package/lib/components/Audio.js +96 -0
  24. package/lib/components/AudioLayerSettings.d.ts +26 -0
  25. package/lib/components/AudioLayerSettings.js +22 -0
  26. package/lib/contexts/audiocontextcontext.d.ts +14 -0
  27. package/lib/contexts/audiocontextcontext.js +38 -0
  28. package/lib/data/animation.d.ts +7 -3
  29. package/lib/data/change.js +12 -1
  30. package/lib/index.d.ts +1 -0
  31. package/lib/index.js +1 -0
  32. package/lib/inflate.js +13 -2
  33. package/lib/types.d.ts +16 -2
  34. package/lib/types.js +7 -1
  35. package/lib/zcomponent.d.ts +8 -1
  36. package/lib/zcomponent.js +20 -0
  37. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import * as Data from '../../data';
2
2
  import { Observable } from '../../observable';
3
3
  import { Animation } from '../animation';
4
+ import { StreamState } from '../stream';
4
5
  import { Track } from '../tracks/track';
5
6
  export declare class Clip {
6
7
  animation: Animation;
@@ -13,6 +14,7 @@ export declare class Clip {
13
14
  private _tracksByPath;
14
15
  private _tracksByPathDirty;
15
16
  private _tracks;
17
+ private _streamTracks;
16
18
  constructor(animation: Animation, length: number, scriptName?: string | undefined, id?: string | undefined);
17
19
  computePathProperty(t: number, p: string, valueBefore: any, parentWeight?: number): any;
18
20
  addTrack(t: Track): void;
@@ -24,8 +26,7 @@ export declare class Clip {
24
26
  [id: string]: Partial<Data.FadeParameters>;
25
27
  }): void;
26
28
  resolveClipTime(t: number, t0: number, s0: number, rate: number, t1?: number): number;
27
- streamPlay(speed?: number): void;
28
29
  streamPause(): void;
29
- streamStop(): void;
30
30
  streamSeek(t: number): void;
31
+ streamTick(state: StreamState, ct: number, rate: number, force?: boolean, parentWeight?: number): void;
31
32
  }
@@ -1,6 +1,7 @@
1
1
  import { Observable } from '../../observable';
2
2
  import { ClipTrack } from '../tracks/cliptrack';
3
3
  import { PropertyTrack } from '../tracks/propertytrack';
4
+ import { StreamTrack } from '../tracks/streamtrack';
4
5
  export class Clip {
5
6
  constructor(animation, length, scriptName, id) {
6
7
  this.animation = animation;
@@ -12,6 +13,7 @@ export class Clip {
12
13
  this._tracksByPath = new Map();
13
14
  this._tracksByPathDirty = false;
14
15
  this._tracks = [];
16
+ this._streamTracks = [];
15
17
  this._dirty = (v) => {
16
18
  if (v) {
17
19
  this.influencedPathsDirty.value = true;
@@ -35,6 +37,8 @@ export class Clip {
35
37
  t.influencedPathsDirty.addListener(this._dirty);
36
38
  this.influencedPathsDirty.value = true;
37
39
  this._tracksByPathDirty = true;
40
+ if (t instanceof StreamTrack || t instanceof ClipTrack)
41
+ this._streamTracks.push(t);
38
42
  }
39
43
  clearTracks() {
40
44
  const existingPaths = this._influencedPaths;
@@ -44,6 +48,7 @@ export class Clip {
44
48
  this._tracks = [];
45
49
  this.influencedPathsDirty.value = true;
46
50
  this._tracksByPathDirty = true;
51
+ this._streamTracks = [];
47
52
  this.animation.evaluateTouchedPaths(existingPaths);
48
53
  }
49
54
  get tracksByPath() {
@@ -108,8 +113,19 @@ export class Clip {
108
113
  bounded += this.length;
109
114
  return bounded;
110
115
  }
111
- streamPlay(speed) { }
112
- streamPause() { }
113
- streamStop() { }
114
- streamSeek(t) { }
116
+ streamPause() {
117
+ for (const track of this._streamTracks) {
118
+ track.streamPause();
119
+ }
120
+ }
121
+ streamSeek(t) {
122
+ for (const track of this._streamTracks) {
123
+ track.streamSeek(t);
124
+ }
125
+ }
126
+ streamTick(state, ct, rate, force = false, parentWeight) {
127
+ for (const track of this._streamTracks) {
128
+ track.streamTick(state, ct, rate, force, parentWeight);
129
+ }
130
+ }
115
131
  }
@@ -5,3 +5,4 @@ export * from './tracks/track';
5
5
  export * from './tracks/cliptrack';
6
6
  export * from './tracks/propertytrack';
7
7
  export * from './clips/clip';
8
+ export * from './stream';
@@ -5,3 +5,4 @@ export * from './tracks/track';
5
5
  export * from './tracks/cliptrack';
6
6
  export * from './tracks/propertytrack';
7
7
  export * from './clips/clip';
8
+ export * from './stream';
@@ -19,6 +19,7 @@ export declare class LayerClip implements Stream {
19
19
  private _t1;
20
20
  private _rate;
21
21
  private _loop;
22
+ private _lastTickTime;
22
23
  private _lastClipTime;
23
24
  private _stopped;
24
25
  state: StreamState;
@@ -29,6 +30,7 @@ export declare class LayerClip implements Stream {
29
30
  getRemainingTimeEstimate(): number;
30
31
  private _getTime;
31
32
  queue(opts?: LayerClipPlayOptions): void;
33
+ length(): number;
32
34
  play(opts?: LayerClipPlayOptions): void;
33
35
  pause(): void;
34
36
  seek(ct: number, opts?: LayerClipSeekOptions): void;
@@ -32,6 +32,7 @@ export class LayerClip {
32
32
  const t0 = this._t0 + (t - (this._pauseTime ?? t));
33
33
  const t1 = this._t1 + (t - (this._pauseTime ?? t));
34
34
  const ct = this.clip.resolveClipTime(t, t0, this._rate >= 0 ? 0 : this.clip.length, this._rate, t1);
35
+ this._lastTickTime = ct;
35
36
  if (ct !== this._lastClipTime || force) {
36
37
  touchedPaths.push(...this.clip.influencedPaths);
37
38
  }
@@ -39,6 +40,7 @@ export class LayerClip {
39
40
  this.pause();
40
41
  this.state = StreamState.Ended;
41
42
  }
43
+ this.clip.streamTick(this.state, ct, this._rate);
42
44
  }
43
45
  computePathProperty(p, valueBefore) {
44
46
  const t = this._getTime();
@@ -59,6 +61,9 @@ export class LayerClip {
59
61
  queue(opts) {
60
62
  this.layer.queue(this, opts);
61
63
  }
64
+ length() {
65
+ return this.clip.length;
66
+ }
62
67
  play(opts) {
63
68
  if (opts?.speed === 0) {
64
69
  this.pause();
@@ -67,11 +72,12 @@ export class LayerClip {
67
72
  this._stopped = false;
68
73
  this._loop = opts?.loop ?? this.defaultLoop;
69
74
  this._rate = opts?.speed ?? this.defaultPlaySpeed;
75
+ const t = this._getTime();
70
76
  if (this.state === StreamState.Ended) {
71
- this._t0 = this._getTime();
77
+ this._t0 = t;
72
78
  }
73
79
  else if (this._pauseTime !== undefined) {
74
- this._t0 = this._getTime() - (this._pauseTime - this._t0);
80
+ this._t0 = t - (this._pauseTime - this._t0);
75
81
  }
76
82
  delete this._pauseTime;
77
83
  if (this._loop)
@@ -84,10 +90,14 @@ export class LayerClip {
84
90
  else
85
91
  this._t1 = Infinity;
86
92
  }
87
- this.clip.streamPlay(this._rate);
93
+ const t0 = this._t0 + (t - (this._pauseTime ?? t));
94
+ const t1 = this._t1 + (t - (this._pauseTime ?? t));
95
+ const ct = this.clip.resolveClipTime(t, t0, this._rate >= 0 ? 0 : this.clip.length, this._rate, t1);
96
+ this.clip.streamTick(StreamState.Playing, ct, this._rate, true);
88
97
  this.state = StreamState.Playing;
89
98
  this.animation._pendingEvents.push({ evt: AnimationEvents.onLayerClipState, args: [this] });
90
99
  this._lastClipTime = undefined;
100
+ this._lastTickTime = undefined;
91
101
  if (this.layer.active !== this) {
92
102
  this.layer._activateLayerClip(this, opts);
93
103
  this.layer._evaulate();
@@ -118,9 +128,11 @@ export class LayerClip {
118
128
  if (this._loop)
119
129
  this._t1 = Infinity;
120
130
  this._lastClipTime = undefined;
131
+ this._lastTickTime = undefined;
121
132
  if (this.layer.active !== this && !opts?.dontActivateLayer) {
122
133
  this.layer._activateLayerClip(this, { fade: opts?.fade });
123
134
  }
135
+ this.clip.streamSeek(ct);
124
136
  this.layer._evaulate();
125
137
  }
126
138
  /** @internal */
@@ -159,14 +171,15 @@ export class LayerClip {
159
171
  this.state = entry.state;
160
172
  }
161
173
  get clipTime() {
162
- return this._lastClipTime !== undefined ? this._lastClipTime : this.defaultPlaySpeed > 0 ? 0 : this.clip.length;
174
+ return this._lastTickTime !== undefined ? this._lastTickTime : this.defaultPlaySpeed > 0 ? 0 : this.clip.length;
163
175
  }
164
176
  stop() {
165
177
  this._stopped = true;
166
178
  this._pauseTime = this._t0;
167
179
  this._lastClipTime = undefined;
180
+ this._lastTickTime = undefined;
168
181
  this._rate = 1;
169
- this.clip.streamStop();
182
+ this.clip.streamTick(StreamState.Ended, this._t0, 1, true);
170
183
  this.state = StreamState.Ended;
171
184
  this.animation._pendingEvents.push({ evt: AnimationEvents.onLayerClipState, args: [this] });
172
185
  }
@@ -8,6 +8,7 @@ export interface Stream {
8
8
  pause: () => void;
9
9
  seek: (t: number) => void;
10
10
  stop: () => void;
11
+ length?: () => number | undefined;
11
12
  }
12
13
  export interface PlayOptions {
13
14
  speed?: number;
@@ -1,6 +1,7 @@
1
1
  import { ClipTrackEntity } from '../../data';
2
2
  import { Clip } from '../clips/clip';
3
3
  import { Keyframe } from '../keyframe';
4
+ import { StreamState } from '../stream';
4
5
  import { Track } from './track';
5
6
  export declare class ClipTrack extends Track {
6
7
  readonly clip: Clip;
@@ -23,4 +24,7 @@ export declare class ClipTrack extends Track {
23
24
  }): void;
24
25
  get sortedBlocks(): ClipTrackEntity[];
25
26
  computePathProperty(t: number, p: string, valueBefore: any, parentWeight?: number): any;
27
+ streamPause(): void;
28
+ streamSeek(t: number): void;
29
+ streamTick(clipState: StreamState, t: number, rate: number, force?: boolean, parentWeight?: number): void;
26
30
  }
@@ -65,4 +65,29 @@ export class ClipTrack extends Track {
65
65
  }
66
66
  return valueBefore;
67
67
  }
68
+ streamPause() {
69
+ this.clip.streamPause();
70
+ }
71
+ streamSeek(t) {
72
+ const blocks = this.sortedBlocks;
73
+ for (let i = blocks.length - 1; i >= 0; i--) {
74
+ const block = blocks[i];
75
+ if (block.t0 > t)
76
+ continue;
77
+ const ct = this.clip.resolveClipTime(t, block.t0, block.s0, block.rate, block.t1);
78
+ this.clip.streamSeek(ct);
79
+ return;
80
+ }
81
+ }
82
+ streamTick(clipState, t, rate, force = false, parentWeight) {
83
+ const blocks = this.sortedBlocks;
84
+ for (let i = blocks.length - 1; i >= 0; i--) {
85
+ const block = blocks[i];
86
+ if (block.t0 > t)
87
+ continue;
88
+ const ct = this.clip.resolveClipTime(t, block.t0, block.s0, block.rate, block.t1);
89
+ this.clip.streamTick(clipState, ct, block.rate, force);
90
+ return;
91
+ }
92
+ }
68
93
  }
@@ -0,0 +1,39 @@
1
+ import { StreamTrackEntity } from '../../data';
2
+ import { Animation } from '../animation';
3
+ import { Keyframe } from '../keyframe';
4
+ import { Stream, StreamState } from '../stream';
5
+ import { Track } from './track';
6
+ export declare class StreamTrack extends Track {
7
+ readonly animation: Animation;
8
+ private _entity;
9
+ private _property;
10
+ private _stream;
11
+ private _entities;
12
+ private _entitiesById;
13
+ private _entitiesDirty;
14
+ private _weights;
15
+ private _weightsById;
16
+ private _weightsDirty;
17
+ private _lastTick?;
18
+ private _lastLoopNumber?;
19
+ private _lastRate;
20
+ constructor(animation: Animation, _entity: any, _property: (string | number)[]);
21
+ get influencedPaths(): string[];
22
+ get stream(): Stream | undefined;
23
+ computePathProperty(t: number, p: string, valueBefore: any, parentWeight?: number): any;
24
+ setWeightsById(weights: {
25
+ [id: string]: Keyframe;
26
+ }): void;
27
+ get sortedWeights(): Keyframe[];
28
+ addBlock(k: StreamTrackEntity): void;
29
+ setBlocksById(weights: {
30
+ [id: string]: StreamTrackEntity;
31
+ }): void;
32
+ get sortedBlocks(): StreamTrackEntity[];
33
+ streamPause(): void;
34
+ streamSeek(t: number): void;
35
+ streamTick(clipState: StreamState, t: number, rate: number, force?: boolean, parentWeight?: number): void;
36
+ private _applyState;
37
+ private _resolveBlock;
38
+ private _resolveBlockTime;
39
+ }
@@ -0,0 +1,144 @@
1
+ import { StreamState } from '../stream';
2
+ import { resolveKeyframes, resolveKeyframeValue, Track } from './track';
3
+ export class StreamTrack extends Track {
4
+ constructor(animation, _entity, _property) {
5
+ super(animation);
6
+ this.animation = animation;
7
+ this._entity = _entity;
8
+ this._property = _property;
9
+ this._entities = [];
10
+ this._entitiesById = {};
11
+ this._entitiesDirty = false;
12
+ this._weights = [];
13
+ this._weightsById = {};
14
+ this._weightsDirty = false;
15
+ this._lastRate = 1;
16
+ }
17
+ get influencedPaths() {
18
+ return [];
19
+ }
20
+ get stream() {
21
+ if (!this._stream) {
22
+ let obj = this._entity;
23
+ for (let i = 0; i < this._property.length; i++) {
24
+ obj = obj[this._property[i]];
25
+ if (!obj)
26
+ return undefined;
27
+ }
28
+ this._stream = obj;
29
+ }
30
+ return this._stream;
31
+ }
32
+ computePathProperty(t, p, valueBefore, parentWeight) {
33
+ // n/a
34
+ }
35
+ setWeightsById(weights) {
36
+ this._weightsById = weights;
37
+ this._weightsDirty = true;
38
+ }
39
+ get sortedWeights() {
40
+ if (!this._weightsDirty)
41
+ return this._weights;
42
+ this._weights = Object.values(this._weightsById);
43
+ this._weights.sort((a, b) => a.t - b.t);
44
+ this._weightsDirty = false;
45
+ return this._weights;
46
+ }
47
+ addBlock(k) {
48
+ this._entitiesById[k.id] = k;
49
+ this._entitiesDirty = true;
50
+ }
51
+ setBlocksById(weights) {
52
+ this._entitiesById = weights;
53
+ this._entitiesDirty = true;
54
+ }
55
+ get sortedBlocks() {
56
+ if (!this._entitiesDirty)
57
+ return this._entities;
58
+ this._entities = Object.values(this._entitiesById);
59
+ this._entities.sort((a, b) => a.t0 - b.t0);
60
+ this._entitiesDirty = false;
61
+ return this._entities;
62
+ }
63
+ streamPause() {
64
+ this.stream?.pause();
65
+ }
66
+ streamSeek(t) {
67
+ const blockNow = this._resolveBlock(t);
68
+ if (!blockNow)
69
+ return;
70
+ const [bt, loopNumber] = this._resolveBlockTime(t, blockNow.t0, blockNow.s0, blockNow.rate, blockNow.t1);
71
+ this.stream?.seek(bt);
72
+ this._lastLoopNumber = loopNumber;
73
+ }
74
+ streamTick(clipState, t, rate, force = false, parentWeight) {
75
+ let weight = 1;
76
+ const [weightBefore, weightAfter] = resolveKeyframes(this.sortedWeights, t);
77
+ if (weightBefore)
78
+ weight = resolveKeyframeValue(t, weightBefore, weightAfter);
79
+ weight *= parentWeight ?? 1;
80
+ const blockBefore = this._lastTick === undefined ? undefined : this._resolveBlock(this._lastTick);
81
+ this._lastTick = t;
82
+ const blockNow = this._resolveBlock(t);
83
+ if (blockBefore !== blockNow || force) {
84
+ let desiredState = clipState;
85
+ if (!blockNow)
86
+ desiredState = StreamState.Paused;
87
+ else {
88
+ const [bt, loopNumber] = this._resolveBlockTime(t, blockNow.t0, blockNow.s0, blockNow.rate, blockNow.t1);
89
+ this._lastLoopNumber = loopNumber;
90
+ this.stream?.seek(bt);
91
+ }
92
+ this._applyState(desiredState, (blockNow?.rate ?? 1) * rate);
93
+ }
94
+ if (blockNow) {
95
+ const [bt, loopNumber] = this._resolveBlockTime(t, blockNow.t0, blockNow.s0, blockNow.rate, blockNow.t1);
96
+ if (loopNumber !== this._lastLoopNumber) {
97
+ console.log('Loop number changed', loopNumber, 'last', this._lastLoopNumber, 'seek', bt);
98
+ this._lastLoopNumber = loopNumber;
99
+ this.stream?.seek(bt);
100
+ }
101
+ }
102
+ }
103
+ _applyState(s, rate) {
104
+ switch (s) {
105
+ case StreamState.Playing:
106
+ this.stream?.play({ speed: rate });
107
+ break;
108
+ case StreamState.Paused:
109
+ this.stream?.pause();
110
+ break;
111
+ case StreamState.Ended:
112
+ this.stream?.stop();
113
+ break;
114
+ }
115
+ }
116
+ _resolveBlock(t) {
117
+ const blocks = this.sortedBlocks;
118
+ for (let i = blocks.length - 1; i >= 0; i--) {
119
+ const block = blocks[i];
120
+ if (block.t0 > t)
121
+ continue;
122
+ if (block.t1 !== undefined && block.t1 <= t)
123
+ return undefined;
124
+ return block;
125
+ }
126
+ return undefined;
127
+ }
128
+ _resolveBlockTime(t, t0, s0, rate, t1 = Infinity) {
129
+ const length = this.stream?.length?.() ?? Infinity;
130
+ if (length === 0)
131
+ return [0, 0];
132
+ t = Math.min(t, t1);
133
+ const ct = s0 + (t - t0) * rate;
134
+ const loopNumber = Math.floor(ct / length);
135
+ let bounded = ct % length;
136
+ if (bounded < 0)
137
+ bounded += length;
138
+ if (bounded === 0 && rate >= +0 && t === t1)
139
+ bounded += length;
140
+ if (bounded === 0 && rate < 0 && t === t0)
141
+ bounded += length;
142
+ return [bounded, loopNumber];
143
+ }
144
+ }
@@ -0,0 +1,48 @@
1
+ import { ActionBehavior, ActionBehaviorConstructorProps } from "../actionbehavior";
2
+ import { Component } from "../component";
3
+ import { ContextManager } from "../context";
4
+ /**
5
+ * @zbehavior
6
+ * @zicon play_circle
7
+ * @zgroup Animation Actions
8
+ */
9
+ export declare class ActivateState extends ActionBehavior {
10
+ private zcomponent;
11
+ /**
12
+ * @zprop
13
+ * @zgroup Activate State Settings
14
+ * @zgrouppriority 20
15
+ * @zvalues layerclipids
16
+ */
17
+ state: string | undefined;
18
+ /**
19
+ * @zprop
20
+ * @zgroup Override Fade
21
+ * @zgrouppriority 10
22
+ */
23
+ fadeTime?: number;
24
+ /**
25
+ * @zprop
26
+ * @zgroup Override Fade
27
+ * @zgrouppriority 10
28
+ * @zdefault 0
29
+ */
30
+ pin?: Pin | number;
31
+ /**
32
+ * @zprop
33
+ * @zgroup Override Fade
34
+ * @zgrouppriority 10
35
+ * @zdefault 0
36
+ * @zvalues easings
37
+ */
38
+ easing?: string;
39
+ constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
40
+ perform(): void;
41
+ /** @zprop */
42
+ preview(): void;
43
+ }
44
+ export declare enum Pin {
45
+ Start = 0,
46
+ Middle = 0.5,
47
+ End = 1
48
+ }
@@ -0,0 +1,39 @@
1
+ import { ActionBehavior, } from "../actionbehavior";
2
+ import { registerBehaviorRunAtDesignTime } from "../behavior";
3
+ /**
4
+ * @zbehavior
5
+ * @zicon play_circle
6
+ * @zgroup Animation Actions
7
+ */
8
+ export class ActivateState extends ActionBehavior {
9
+ constructor(contextManager, instance, props) {
10
+ super(contextManager, instance, props);
11
+ this.zcomponent = this.getZComponentInstance();
12
+ }
13
+ perform() {
14
+ if (!this.state)
15
+ return;
16
+ const layerclip = this.zcomponent.animation.layerClipByID.get(this.state);
17
+ if (!layerclip)
18
+ return;
19
+ const opts = {
20
+ fade: {
21
+ time: this.fadeTime,
22
+ pin: this.pin,
23
+ easing: this.easing
24
+ }
25
+ };
26
+ layerclip.play(opts);
27
+ }
28
+ /** @zprop */
29
+ preview() {
30
+ this.perform();
31
+ }
32
+ }
33
+ export var Pin;
34
+ (function (Pin) {
35
+ Pin[Pin["Start"] = 0] = "Start";
36
+ Pin[Pin["Middle"] = 0.5] = "Middle";
37
+ Pin[Pin["End"] = 1] = "End";
38
+ })(Pin || (Pin = {}));
39
+ registerBehaviorRunAtDesignTime(ActivateState);
@@ -0,0 +1,22 @@
1
+ import { ActionBehavior, ActionBehaviorConstructorProps } from "../../actionbehavior";
2
+ import { Component } from "../../component";
3
+ import { ContextManager } from "../../context";
4
+ /**
5
+ * @zbehavior
6
+ * @zicon pause_circle
7
+ * @zgroup Stream Actions
8
+ */
9
+ export declare class PauseStream extends ActionBehavior {
10
+ private zcomponent;
11
+ /**
12
+ * @zprop
13
+ * @zgroup Pause Settings
14
+ * @zgrouppriority 20
15
+ * @zvalues streamids
16
+ */
17
+ stream: string | undefined;
18
+ constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
19
+ perform(): void;
20
+ /** @zprop */
21
+ preview(): void;
22
+ }
@@ -0,0 +1,26 @@
1
+ import { ActionBehavior, } from "../../actionbehavior";
2
+ import { registerBehaviorRunAtDesignTime } from "../../behavior";
3
+ /**
4
+ * @zbehavior
5
+ * @zicon pause_circle
6
+ * @zgroup Stream Actions
7
+ */
8
+ export class PauseStream extends ActionBehavior {
9
+ constructor(contextManager, instance, props) {
10
+ super(contextManager, instance, props);
11
+ this.zcomponent = this.getZComponentInstance();
12
+ }
13
+ perform() {
14
+ if (!this.stream)
15
+ return;
16
+ const stream = this.zcomponent.resolveStreamID(this.stream);
17
+ if (!stream)
18
+ return;
19
+ stream.pause();
20
+ }
21
+ /** @zprop */
22
+ preview() {
23
+ this.perform();
24
+ }
25
+ }
26
+ registerBehaviorRunAtDesignTime(PauseStream);
@@ -0,0 +1,45 @@
1
+ import { ActionBehavior, ActionBehaviorConstructorProps } from "../../actionbehavior";
2
+ import { Component } from "../../component";
3
+ import { ContextManager } from "../../context";
4
+ /**
5
+ * @zbehavior
6
+ * @zicon play_circle
7
+ * @zgroup Stream Actions
8
+ */
9
+ export declare class PlayStream extends ActionBehavior {
10
+ private zcomponent;
11
+ /**
12
+ * @zprop
13
+ * @zgroup Play Settings
14
+ * @zgrouppriority 20
15
+ * @zvalues streamids
16
+ */
17
+ stream: string | undefined;
18
+ /**
19
+ * @zprop
20
+ * @zgroup Play Settings
21
+ * @zgrouppriority 20
22
+ * @zdefault false
23
+ */
24
+ loop?: boolean;
25
+ /**
26
+ * @zprop
27
+ * @zgroup Play Settings
28
+ * @zgrouppriority 20
29
+ * @zdefault 1
30
+ */
31
+ speed?: number;
32
+ /**
33
+ * Seek the clip to the start before playing
34
+ *
35
+ * @zprop
36
+ * @zgroup Play Settings
37
+ * @zgrouppriority 20
38
+ * @zdefault false
39
+ */
40
+ fromStart: boolean;
41
+ constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
42
+ perform(): void;
43
+ /** @zprop */
44
+ preview(): void;
45
+ }
@@ -0,0 +1,37 @@
1
+ import { ActionBehavior, } from "../../actionbehavior";
2
+ import { registerBehaviorRunAtDesignTime } from "../../behavior";
3
+ /**
4
+ * @zbehavior
5
+ * @zicon play_circle
6
+ * @zgroup Stream Actions
7
+ */
8
+ export class PlayStream extends ActionBehavior {
9
+ constructor(contextManager, instance, props) {
10
+ super(contextManager, instance, props);
11
+ this.zcomponent = this.getZComponentInstance();
12
+ /**
13
+ * Seek the clip to the start before playing
14
+ *
15
+ * @zprop
16
+ * @zgroup Play Settings
17
+ * @zgrouppriority 20
18
+ * @zdefault false
19
+ */
20
+ this.fromStart = false;
21
+ }
22
+ perform() {
23
+ if (!this.stream)
24
+ return;
25
+ const stream = this.zcomponent.resolveStreamID(this.stream);
26
+ if (!stream)
27
+ return;
28
+ if (this.fromStart ?? false)
29
+ stream.seek(0);
30
+ stream.play({ loop: this.loop, speed: this.speed });
31
+ }
32
+ /** @zprop */
33
+ preview() {
34
+ this.perform();
35
+ }
36
+ }
37
+ registerBehaviorRunAtDesignTime(PlayStream);
@@ -0,0 +1,29 @@
1
+ import { ActionBehavior, ActionBehaviorConstructorProps } from "../../actionbehavior";
2
+ import { Component } from "../../component";
3
+ import { ContextManager } from "../../context";
4
+ /**
5
+ * @zbehavior
6
+ * @zicon fast_forward
7
+ * @zgroup Stream Actions
8
+ */
9
+ export declare class SeekStream extends ActionBehavior {
10
+ private zcomponent;
11
+ /**
12
+ * @zprop
13
+ * @zgroup Stop Settings
14
+ * @zgrouppriority 20
15
+ * @zvalues streamids
16
+ */
17
+ stream: string | undefined;
18
+ /**
19
+ * @zprop
20
+ * @zgroup Stop Settings
21
+ * @zgrouppriority 20
22
+ * @zdefault 0
23
+ */
24
+ time: number;
25
+ constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
26
+ perform(): void;
27
+ /** @zprop */
28
+ preview(): void;
29
+ }