@revideo/player 0.2.2 → 0.2.4-alpha.894

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 (2) hide show
  1. package/dist/main.js +225 -105
  2. package/package.json +3 -3
package/dist/main.js CHANGED
@@ -1,15 +1,33 @@
1
- var g = Object.defineProperty;
2
- var p = (o, s, t) => s in o ? g(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t;
3
- var e = (o, s, t) => (p(o, typeof s != "symbol" ? s + "" : s, t), t);
4
- import { Stage as v, Player as b, Vector2 as m } from "@revideo/core";
5
- const f = `.initial{display:none}.state-initial .initial{display:block}.loading{display:none}.state-loading .loading{display:block}.ready{display:none}.state-ready .ready{display:block}.error{display:none}.state-error .error{display:block}:host{position:relative;display:block}.overlay{position:absolute;left:0;right:0;top:0;bottom:0;display:flex;align-items:center;justify-content:center;opacity:0;background-color:#0000008a;transition:opacity .1s}.overlay.state-ready:not(.auto){cursor:pointer}.overlay.playing:not(.hover):hover{cursor:none}.overlay.hover,.overlay.state-ready:focus-within,.overlay.state-ready:not(.playing){opacity:1}.overlay.hover .button,.overlay.state-ready:focus-within .button,.overlay.state-ready:not(.playing) .button{scale:1;transition:scale .1s ease-out}.overlay.state-loading,.overlay.state-error{opacity:1;transition:opacity 1s}.overlay.state-ready.auto{opacity:0}.button{width:50%;max-width:96px;aspect-ratio:1;scale:.5;transition:scale .1s ease-in,opacity .1s;background-color:transparent;border:none;background-size:100% 100%;background-repeat:no-repeat;opacity:.54;cursor:inherit;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiB3aWR0aD0iMjRweCIgZmlsbD0iI2ZmZmZmZiI+PHBhdGggZD0iTTAgMGgyNHYyNEgwVjB6IiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTEyIDJDNi40OCAyIDIgNi40OCAyIDEyczQuNDggMTAgMTAgMTAgMTAtNC40OCAxMC0xMFMxNy41MiAyIDEyIDJ6bS0yIDE0LjV2LTlsNiA0LjUtNiA0LjV6Ii8+PC9zdmc+)}.playing .button{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDI0IDI0IiBoZWlnaHQ9IjI0cHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0cHgiIGZpbGw9IiNmZmZmZmYiPjxnPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iMjQiIHdpZHRoPSIyNCIvPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iMjQiIHdpZHRoPSIyNCIvPjxyZWN0IGZpbGw9Im5vbmUiIGhlaWdodD0iMjQiIHdpZHRoPSIyNCIvPjwvZz48Zz48Zy8+PHBhdGggZD0iTTEyLDJDNi40OCwyLDIsNi40OCwyLDEyczQuNDgsMTAsMTAsMTBzMTAtNC40OCwxMC0xMFMxNy41MiwyLDEyLDJ6IE0xMSwxNkg5VjhoMlYxNnogTTE1LDE2aC0yVjhoMlYxNnoiLz48L2c+PC9zdmc+)}.button:focus,.overlay:hover .button{opacity:.87}.auto .button{display:none}.canvas{width:100%;display:block;opacity:0;transition:opacity .1s}.canvas.state-ready{opacity:1}.message{font-family:JetBrains Mono,sans-serif;text-align:center;font-size:20px;padding:8px 16px;margin:16px;border-radius:4px;color:#fff9;background-color:#000000de}.loader{width:50%;max-width:96px;display:none;rotate:-90deg;animation:stroke 2s cubic-bezier(.5,0,.5,1) infinite,rotate 2s linear infinite}@keyframes stroke{0%{stroke-dasharray:5.6548667765px 50.8938009883px;stroke-dashoffset:2.8274333882px}50%{stroke-dasharray:50.8938009883px 5.6548667765px;stroke-dashoffset:-2.8274333882px}to{stroke-dasharray:5.6548667765px 50.8938009883px;stroke-dashoffset:-53.7212343766px}}@keyframes rotate{0%{rotate:-110deg}to{rotate:250deg}}
6
- `, I = `<div class="overlay" part="overlay">
7
- <button
8
- part="play-button"
9
- title="Play / Pause"
10
- class="button ready"
11
- tabindex="0"
12
- ></button>
1
+ var p = Object.defineProperty;
2
+ var y = (h, r, t) =>
3
+ r in h
4
+ ? p(h, r, {enumerable: !0, configurable: !0, writable: !0, value: t})
5
+ : (h[r] = t);
6
+ var e = (h, r, t) => (y(h, typeof r != 'symbol' ? r + '' : r, t), t);
7
+ import {Stage as M, Vector2 as b, Player as m} from '@revideo/core';
8
+ const v = `.initial{display:none}.state-initial .initial{display:block}.loading{display:none}.state-loading .loading{display:block}.ready{display:none}.state-ready .ready{display:block}.error{display:none}.state-error .error{display:block}:host{position:relative;display:block}.controls{position:absolute;left:0;right:0;display:flex;align-items:center;justify-content:space-between;bottom:0%;height:10%;background:rgba(0,0,0,0)}.timeline-container{height:100%;width:calc(100% - 32px);top:0%;position:absolute;z-index:5}.timeline{position:absolute;-webkit-appearance:none;-moz-appearance:none;appearance:none;margin-left:16px;margin-right:16px;width:100%;background:transparent;cursor:pointer;background-size:100% 40px;background-repeat:no-repeat;bottom:10px;z-index:10}.timeline::-webkit-slider-runnable-track{width:100%;height:5px;background:white;background:var(--webkit-track, white)}.timeline:hover::-webkit-slider-runnable-track{width:100%;height:5px;background:white;background:var(--webkit-track, white)}.timeline::-moz-range-track{width:100%;height:5px;background:white;background:var(--moz-track, white)}.timeline::-ms-track{width:100%;height:4px;background:white;background:var(--ms-track, rgb(201, 199, 199))}.timeline::-webkit-slider-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:16px;height:16px;background:#fff;border-radius:50%;cursor:pointer;opacity:0;transition:opacity .2s ease;margin-top:-6px}.timeline::-moz-range-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:16px;height:16px;background:#fff;border-radius:50%;cursor:pointer;opacity:0;transition:opacity .2s ease;margin-top:-6px}.timeline::-ms-thumb{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:16px;height:16px;background:#fff;border-radius:50%;cursor:pointer;opacity:0;transition:opacity .2s ease;margin-top:-6px}.timeline:hover::-webkit-slider-thumb{opacity:1;background:#fff}.timeline:hover::-moz-range-thumb{opacity:1;background:#fff}.timeline:hover::-ms-thumb{opacity:1;background:#fff}.overlay{position:absolute;left:0;right:0;top:0;bottom:0;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .1s;z-index:0}.overlay.state-ready:not(.auto){cursor:pointer}.overlay.playing:not(.hover):hover{cursor:none}.overlay.hover,.overlay.state-ready:focus-within,.overlay.state-ready:not(.playing){opacity:1}.overlay.state-loading,.overlay.state-error{opacity:1;transition:opacity 1s}.overlay.state-ready.auto{opacity:0}.button{width:16px;position:absolute;bottom:25px;left:14px;height:14px;transition:scale .1s ease-in,opacity .1s;background-color:transparent;border:none;background-size:100% 100%;background-repeat:no-repeat;cursor:inherit;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTEiIGhlaWdodD0iMTMiIHZpZXdCb3g9IjAgMCAxMSAxMyIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTAgMS4wMDE0VjExLjM2MTRDMCAxMi4xNTE0IDAuODcgMTIuNjMxNCAxLjU0IDEyLjIwMTRMOS42OCA3LjAyMTRDMTAuMyA2LjYzMTQgMTAuMyA1LjczMTQgOS42OCA1LjMzMTRMMS41NCAwLjE2MTQwNUMwLjg3IC0wLjI2ODU5NiAwIDAuMjExNDA1IDAgMS4wMDE0WiIgZmlsbD0id2hpdGUiLz4KPC9zdmc+Cg==)}.playing .play-button{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTQiIHZpZXdCb3g9IjAgMCAxMiAxNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTIgMEMxLjQ2OTU3IDAgMC45NjA4NTkgMC4yMTA3MTQgMC41ODU3ODYgMC41ODU3ODZDMC4yMTA3MTQgMC45NjA4NTkgMCAxLjQ2OTU3IDAgMlYxMkMwIDEyLjUzMDQgMC4yMTA3MTQgMTMuMDM5MSAwLjU4NTc4NiAxMy40MTQyQzAuOTYwODU5IDEzLjc4OTMgMS40Njk1NyAxNCAyIDE0QzIuNTMwNDMgMTQgMy4wMzkxNCAxMy43ODkzIDMuNDE0MjEgMTMuNDE0MkMzLjc4OTI5IDEzLjAzOTEgNCAxMi41MzA0IDQgMTJWMkM0IDEuNDY5NTcgMy43ODkyOSAwLjk2MDg1OSAzLjQxNDIxIDAuNTg1Nzg2QzMuMDM5MTQgMC4yMTA3MTQgMi41MzA0MyAwIDIgMFpNMTAgMEM5LjQ2OTU3IDAgOC45NjA4NiAwLjIxMDcxNCA4LjU4NTc5IDAuNTg1Nzg2QzguMjEwNzEgMC45NjA4NTkgOCAxLjQ2OTU3IDggMlYxMkM4IDEyLjUzMDQgOC4yMTA3MSAxMy4wMzkxIDguNTg1NzkgMTMuNDE0MkM4Ljk2MDg2IDEzLjc4OTMgOS40Njk1NyAxNCAxMCAxNEMxMC41MzA0IDE0IDExLjAzOTEgMTMuNzg5MyAxMS40MTQyIDEzLjQxNDJDMTEuNzg5MyAxMy4wMzkxIDEyIDEyLjUzMDQgMTIgMTJWMkMxMiAxLjQ2OTU3IDExLjc4OTMgMC45NjA4NTkgMTEuNDE0MiAwLjU4NTc4NkMxMS4wMzkxIDAuMjEwNzE0IDEwLjUzMDQgMCAxMCAwWiIgZmlsbD0id2hpdGUiLz4KPC9zdmc+Cg==)}.auto .play-button{display:none}.current-time{position:absolute;left:44px;bottom:25px;color:#fff;font-family:Arial,sans-serif;font-size:14px;line-height:14px}.canvas{width:100%;display:block;opacity:0;transition:opacity .1s}.canvas.state-ready{opacity:1}.message{font-family:JetBrains Mono,sans-serif;text-align:center;font-size:20px;padding:8px 16px;margin:16px;border-radius:4px;color:#fff9;background-color:#000000de}.loader{width:50%;max-width:96px;display:none;rotate:-90deg;animation:stroke 2s cubic-bezier(.5,0,.5,1) infinite,rotate 2s linear infinite}@keyframes stroke{0%{stroke-dasharray:5.6548667765px 50.8938009883px;stroke-dashoffset:2.8274333882px}50%{stroke-dasharray:50.8938009883px 5.6548667765px;stroke-dashoffset:-2.8274333882px}to{stroke-dasharray:5.6548667765px 50.8938009883px;stroke-dashoffset:-53.7212343766px}}@keyframes rotate{0%{rotate:-110deg}to{rotate:250deg}}
9
+ `,
10
+ k = `<div class="overlay" part="overlay">
11
+ <div class="controls">
12
+ <button
13
+ part="play-button"
14
+ title="Play / Pause"
15
+ class="button play-button ready"
16
+ tabindex="0"
17
+ ></button>
18
+ <!-- New button to the right -->
19
+ <span class="current-time" part="current-time">0:00 / 0:00</span>
20
+ <div class="timeline-container">
21
+ <input
22
+ type="range"
23
+ class="timeline"
24
+ value="0"
25
+ min="0"
26
+ max="100"
27
+ step="1"
28
+ />
29
+ </div>
30
+ </div>
13
31
  <div part="message" class="message error">
14
32
  An error occurred while loading the animation.
15
33
  </div>
@@ -20,165 +38,267 @@ const f = `.initial{display:none}.state-initial .initial{display:block}.loading{
20
38
  stroke="#ffffff"
21
39
  stroke-width="2"
22
40
  fill="transparent"
23
- >
24
- <circle cx="12" cy="12" r="9" />
25
- </svg>
41
+ ></svg>
26
42
  </div>
27
- `, M = `<style>${f}</style>${I}`, c = "revideo-player";
28
- class w extends HTMLElement {
43
+ `,
44
+ f = `<style>${v}</style>${k}`,
45
+ d = 'revideo-player';
46
+ class x extends HTMLElement {
29
47
  constructor() {
30
48
  super();
31
- e(this, "root");
32
- e(this, "canvas");
33
- e(this, "overlay");
34
- e(this, "button");
35
- e(this, "state", "initial");
36
- e(this, "project", null);
37
- e(this, "player", null);
38
- e(this, "defaultSettings");
39
- e(this, "abortController", null);
40
- e(this, "mouseMoveId", null);
41
- e(this, "finished", !1);
42
- e(this, "playing", !1);
43
- e(this, "connected", !1);
44
- e(this, "stage", new v());
45
- e(this, "handleMouseMove", () => {
46
- this.mouseMoveId && clearTimeout(this.mouseMoveId), this.hover && !this.playing && this.setPlaying(!0), this.mouseMoveId = window.setTimeout(() => {
47
- this.mouseMoveId = null, this.updateClass();
48
- }, 2e3), this.updateClass();
49
+ e(this, 'root');
50
+ e(this, 'canvas');
51
+ e(this, 'overlay');
52
+ e(this, 'button');
53
+ e(this, 'state', 'initial');
54
+ e(this, 'project', null);
55
+ e(this, 'player', null);
56
+ e(this, 'defaultSettings');
57
+ e(this, 'abortController', null);
58
+ e(this, 'mouseMoveId', null);
59
+ e(this, 'finished', !1);
60
+ e(this, 'playing', !1);
61
+ e(this, 'connected', !1);
62
+ e(this, 'stage', new M());
63
+ e(this, 'timeline');
64
+ e(this, 'handleTimelineChange', t => {
65
+ var s, o;
66
+ const a = t.target,
67
+ i = parseFloat(a.value);
68
+ ((s = this.player) == null ? void 0 : s.playback.duration) &&
69
+ ((o = this.player) == null || o.requestSeek(i));
49
70
  });
50
- e(this, "handleMouseLeave", () => {
51
- this.hover && this.setPlaying(!1), this.mouseMoveId && (clearTimeout(this.mouseMoveId), this.mouseMoveId = null, this.updateClass());
71
+ e(this, 'handleMouseMove', () => {
72
+ this.mouseMoveId && clearTimeout(this.mouseMoveId),
73
+ this.hover && !this.playing && this.setPlaying(!0),
74
+ (this.mouseMoveId = window.setTimeout(() => {
75
+ (this.mouseMoveId = null), this.updateClass();
76
+ }, 2e3)),
77
+ this.updateClass();
52
78
  });
53
- e(this, "handleMouseDown", (t) => {
54
- t.preventDefault();
79
+ e(this, 'handleMouseLeave', () => {
80
+ this.hover && this.setPlaying(!1),
81
+ this.mouseMoveId &&
82
+ (clearTimeout(this.mouseMoveId),
83
+ (this.mouseMoveId = null),
84
+ this.updateClass());
55
85
  });
56
- e(this, "handleClick", () => {
57
- this.auto || (this.handleMouseMove(), this.setPlaying(!this.playing), this.button.animate(
58
- [
59
- { scale: "0.9" },
60
- {
61
- scale: "1",
62
- easing: "ease-out"
63
- }
64
- ],
65
- { duration: 200 }
66
- ));
86
+ e(this, 'handleMouseDown', t => {
87
+ t.target.closest('.timeline') || t.preventDefault();
67
88
  });
68
- e(this, "render", async () => {
69
- this.player && await this.stage.render(
70
- this.player.playback.currentScene,
71
- this.player.playback.previousScene
72
- );
89
+ e(this, 'handleClick', t => {
90
+ t.target.closest('.timeline') ||
91
+ this.auto ||
92
+ (this.handleMouseMove(),
93
+ this.setPlaying(!this.playing),
94
+ this.button.animate(
95
+ [
96
+ {scale: '0.9'},
97
+ {
98
+ scale: '1',
99
+ easing: 'ease-out',
100
+ },
101
+ ],
102
+ {duration: 200},
103
+ ));
73
104
  });
74
- this.root = this.attachShadow({ mode: "open" }), this.root.innerHTML = M, this.overlay = this.root.querySelector(".overlay"), this.button = this.root.querySelector(".button"), this.canvas = this.stage.finalBuffer, this.canvas.classList.add("canvas"), this.root.prepend(this.canvas), this.overlay.addEventListener("click", this.handleClick), this.overlay.addEventListener("mousemove", this.handleMouseMove), this.overlay.addEventListener("mouseleave", this.handleMouseLeave), this.button.addEventListener("mousedown", this.handleMouseDown), this.setState(
75
- "initial"
76
- /* Initial */
77
- );
105
+ e(this, 'render', async () => {
106
+ var t;
107
+ if (this.player) {
108
+ await this.stage.render(
109
+ this.player.playback.currentScene,
110
+ this.player.playback.previousScene,
111
+ ),
112
+ this.timeline.setAttribute('min', '0'),
113
+ this.timeline.setAttribute('step', '1'),
114
+ this.timeline.setAttribute(
115
+ 'max',
116
+ (t = this.player) == null ? void 0 : t.playback.duration.toString(),
117
+ );
118
+ const a = this.player.status.time,
119
+ i = this.player.status.framesToSeconds(this.player.playback.duration);
120
+ if (i) {
121
+ const n = this.player.status.secondsToFrames(a);
122
+ this.timeline.value = n.toString();
123
+ const s = `linear-gradient(to right, rgb(180, 180, 180) 0%, rgb(180, 180, 180) ${(100 * n) / this.player.status.secondsToFrames(i)}%, white ${(100 * n) / this.player.status.secondsToFrames(i)}%, white 100%)`;
124
+ (this.timeline.style.background = s),
125
+ this.timeline.style.setProperty('--webkit-track', s),
126
+ this.timeline.style.setProperty('--moz-track', s),
127
+ this.timeline.style.setProperty('--ms-track', s);
128
+ const o = this.formatTime(a),
129
+ c = this.formatTime(i),
130
+ l = this.root.querySelector('.current-time');
131
+ l && (l.textContent = `${o} / ${c}`);
132
+ }
133
+ }
134
+ });
135
+ (this.root = this.attachShadow({mode: 'open'})),
136
+ (this.root.innerHTML = f),
137
+ (this.overlay = this.root.querySelector('.overlay')),
138
+ (this.button = this.root.querySelector('.button')),
139
+ (this.canvas = this.stage.finalBuffer),
140
+ this.canvas.classList.add('canvas'),
141
+ this.root.prepend(this.canvas),
142
+ (this.timeline = this.root.querySelector('.timeline')),
143
+ this.timeline.addEventListener('input', this.handleTimelineChange),
144
+ this.timeline.addEventListener('change', this.handleTimelineChange),
145
+ this.button.addEventListener('click', this.handleClick),
146
+ this.button.addEventListener('mousedown', this.handleMouseDown),
147
+ this.overlay.addEventListener('click', this.handleClick),
148
+ this.overlay.addEventListener('mousemove', this.handleMouseMove),
149
+ this.overlay.addEventListener('mouseleave', this.handleMouseLeave),
150
+ this.overlay.addEventListener('mousedown', this.handleMouseDown),
151
+ this.setState(
152
+ 'initial',
153
+ /* Initial */
154
+ );
78
155
  }
79
156
  static get observedAttributes() {
80
- return ["src", "quality", "width", "height", "auto", "variables"];
157
+ return ['src', 'quality', 'width', 'height', 'auto', 'variables'];
81
158
  }
82
159
  get auto() {
83
- return !!this.getAttribute("auto");
160
+ return !!this.getAttribute('auto');
84
161
  }
85
162
  get hover() {
86
- return this.getAttribute("auto") === "hover";
163
+ return this.getAttribute('auto') === 'hover';
87
164
  }
88
165
  get quality() {
89
- const t = this.getAttribute("quality");
166
+ const t = this.getAttribute('quality');
90
167
  return t ? parseFloat(t) : this.defaultSettings.resolutionScale;
91
168
  }
92
169
  get width() {
93
- const t = this.getAttribute("width");
170
+ const t = this.getAttribute('width');
94
171
  return t ? parseFloat(t) : this.defaultSettings.size.width;
95
172
  }
96
173
  get height() {
97
- const t = this.getAttribute("height");
174
+ const t = this.getAttribute('height');
98
175
  return t ? parseFloat(t) : this.defaultSettings.size.height;
99
176
  }
100
177
  get variables() {
101
178
  try {
102
- const t = this.getAttribute("variables");
179
+ const t = this.getAttribute('variables');
103
180
  return t ? JSON.parse(t) : {};
104
181
  } catch {
105
- return this.project.logger.warn("Project variables could not be parsed."), {};
182
+ return (
183
+ this.project.logger.warn('Project variables could not be parsed.'), {}
184
+ );
106
185
  }
107
186
  }
108
187
  setState(t) {
109
- this.state = t, this.setPlaying(this.playing);
188
+ (this.state = t), this.setPlaying(this.playing);
110
189
  }
111
190
  setPlaying(t) {
112
191
  var a, i;
113
- this.state === "ready" && (t || this.auto && !this.hover) ? ((a = this.player) == null || a.togglePlayback(!0), this.playing = !0) : ((i = this.player) == null || i.togglePlayback(!1), this.playing = !1), this.updateClass();
192
+ this.state === 'ready' && (t || (this.auto && !this.hover))
193
+ ? ((a = this.player) == null || a.togglePlayback(!0), (this.playing = !0))
194
+ : ((i = this.player) == null || i.togglePlayback(!1),
195
+ (this.playing = !1)),
196
+ this.updateClass();
114
197
  }
115
198
  updateClass() {
116
- this.overlay.className = `overlay state-${this.state}`, this.canvas.className = `canvas state-${this.state}`, this.overlay.classList.toggle("playing", this.playing), this.overlay.classList.toggle("auto", this.auto), this.overlay.classList.toggle("hover", this.mouseMoveId !== null), this.connected && (this.mouseMoveId !== null || !this.playing ? this.dataset.overlay = "" : delete this.dataset.overlay);
199
+ (this.overlay.className = `overlay state-${this.state}`),
200
+ (this.canvas.className = `canvas state-${this.state}`),
201
+ this.overlay.classList.toggle('playing', this.playing),
202
+ this.overlay.classList.toggle('auto', this.auto),
203
+ this.overlay.classList.toggle('hover', this.mouseMoveId !== null),
204
+ this.connected &&
205
+ (this.mouseMoveId !== null || !this.playing
206
+ ? (this.dataset.overlay = '')
207
+ : delete this.dataset.overlay);
117
208
  }
118
209
  async updateSource(t) {
119
- var r, l, h, d;
210
+ var n, s, o, c;
120
211
  this.setState(
121
- "initial"
212
+ 'initial',
122
213
  /* Initial */
123
- ), (r = this.abortController) == null || r.abort(), this.abortController = new AbortController();
214
+ ),
215
+ (n = this.abortController) == null || n.abort(),
216
+ (this.abortController = new AbortController());
124
217
  let a;
125
218
  try {
126
- const n = import(
127
- /* webpackIgnore: true */
128
- /* @vite-ignore */
129
- t
130
- ), y = new Promise((u) => setTimeout(u, 200));
131
- await Promise.any([y, n]), this.setState(
132
- "loading"
133
- /* Loading */
134
- ), a = (await n).default;
135
- } catch (n) {
136
- console.error(n), this.setState(
137
- "error"
138
- /* Error */
139
- );
219
+ const l = import(
220
+ /* webpackIgnore: true */
221
+ /* @vite-ignore */
222
+ t
223
+ ),
224
+ u = new Promise(g => setTimeout(g, 200));
225
+ await Promise.any([u, l]),
226
+ this.setState(
227
+ 'loading',
228
+ /* Loading */
229
+ ),
230
+ (a = (await l).default);
231
+ } catch (l) {
232
+ console.error(l),
233
+ this.setState(
234
+ 'error',
235
+ /* Error */
236
+ );
140
237
  return;
141
238
  }
142
239
  this.defaultSettings = a.meta.getFullRenderingSettings();
143
- const i = new b(a);
144
- i.setVariables(this.variables), this.finished = !1, (l = this.player) == null || l.onRender.unsubscribe(this.render), (h = this.player) == null || h.togglePlayback(!1), (d = this.player) == null || d.deactivate(), this.project = a, this.player = i, this.updateSettings(), this.player.onRender.subscribe(this.render), this.player.togglePlayback(this.playing), this.setState(
145
- "ready"
146
- /* Ready */
147
- );
240
+ const i = new m(a);
241
+ i.setVariables(this.variables),
242
+ (this.finished = !1),
243
+ (s = this.player) == null || s.onRender.unsubscribe(this.render),
244
+ (o = this.player) == null || o.togglePlayback(!1),
245
+ (c = this.player) == null || c.deactivate(),
246
+ (this.project = a),
247
+ (this.player = i),
248
+ this.updateSettings(),
249
+ this.player.onRender.subscribe(this.render),
250
+ this.player.togglePlayback(this.playing),
251
+ this.setState(
252
+ 'ready',
253
+ /* Ready */
254
+ );
148
255
  }
149
256
  attributeChangedCallback(t, a, i) {
150
- var r;
257
+ var n, s;
151
258
  switch (t) {
152
- case "auto":
259
+ case 'auto':
153
260
  this.setPlaying(this.playing);
154
261
  break;
155
- case "src":
262
+ case 'src':
156
263
  this.updateSource(i);
157
264
  break;
158
- case "quality":
159
- case "width":
160
- case "height":
265
+ case 'quality':
266
+ case 'width':
267
+ case 'height':
161
268
  this.updateSettings();
162
269
  break;
163
- case "variables":
164
- (r = this.player) == null || r.setVariables(this.variables);
270
+ case 'variables':
271
+ (n = this.player) == null || n.setVariables(this.variables),
272
+ (s = this.player) == null ||
273
+ s.requestSeek(this.player.playback.frame);
165
274
  }
166
275
  }
167
276
  disconnectedCallback() {
168
277
  var t, a;
169
- this.connected = !1, (t = this.player) == null || t.deactivate(), (a = this.player) == null || a.onRender.unsubscribe(this.render);
278
+ (this.connected = !1),
279
+ (t = this.player) == null || t.deactivate(),
280
+ (a = this.player) == null || a.onRender.unsubscribe(this.render);
170
281
  }
171
282
  connectedCallback() {
172
283
  var t, a;
173
- this.connected = !0, (t = this.player) == null || t.activate(), (a = this.player) == null || a.onRender.subscribe(this.render);
284
+ (this.connected = !0),
285
+ (t = this.player) == null || t.activate(),
286
+ (a = this.player) == null || a.onRender.subscribe(this.render);
174
287
  }
175
288
  updateSettings() {
176
289
  const t = {
177
290
  ...this.defaultSettings,
178
- size: new m(this.width, this.height),
179
- resolutionScale: this.quality
291
+ size: new b(this.width, this.height),
292
+ resolutionScale: this.quality,
180
293
  };
181
294
  this.stage.configure(t), this.player.configure(t);
182
295
  }
296
+ formatTime(t) {
297
+ const a = Math.floor(t / 60),
298
+ i = Math.floor(t % 60),
299
+ n = a.toString().padStart(2, '0'),
300
+ s = i.toString().padStart(2, '0');
301
+ return `${n}:${s}`;
302
+ }
183
303
  }
184
- customElements.get(c) || customElements.define(c, w);
304
+ customElements.get(d) || customElements.define(d, x);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revideo/player",
3
- "version": "0.2.2",
3
+ "version": "0.2.4-alpha.894+1d33331",
4
4
  "description": "A custom element for displaying animations made with revideo",
5
5
  "main": "dist/main.js",
6
6
  "types": "types/main.d.ts",
@@ -22,9 +22,9 @@
22
22
  "types"
23
23
  ],
24
24
  "devDependencies": {
25
- "@revideo/core": "^0.2.2",
25
+ "@revideo/core": "^0.2.4-alpha.894+1d33331",
26
26
  "sass": "^1.58.0",
27
27
  "terser": "^5.16.1"
28
28
  },
29
- "gitHead": "aed6717a2c1364b37c99315a099bab56d8017e99"
29
+ "gitHead": "1d33331ab697434bac6acb926243f641e4106b18"
30
30
  }