@twick/live-player 0.15.16 → 0.15.18

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.
@@ -5705,12 +5705,14 @@ var Player = class {
5705
5705
  const state = await this.prepare();
5706
5706
  const previousState = this.playback.state;
5707
5707
  this.playback.state = state.paused ? 2 : 0;
5708
+ let didSeekWhilePaused = false;
5708
5709
  if (state.seek >= 0 || !this.isInUserRange(this.status.frame)) {
5709
5710
  const seekFrame = state.seek < 0 ? this.status.frame : state.seek;
5710
5711
  const clampedFrame = this.clampRange(seekFrame);
5711
5712
  this.logger.profile("seek time");
5712
5713
  await this.playback.seek(clampedFrame);
5713
5714
  this.logger.profile("seek time");
5715
+ didSeekWhilePaused = state.paused;
5714
5716
  } else if (state.paused) {
5715
5717
  if (state.render || state.paused && previousState !== 2) {
5716
5718
  await this.render.dispatch();
@@ -5726,6 +5728,9 @@ var Player = class {
5726
5728
  }
5727
5729
  await this.render.dispatch();
5728
5730
  this.frame.current = this.playback.frame;
5731
+ if (didSeekWhilePaused) {
5732
+ this.requestRender();
5733
+ }
5729
5734
  this.request();
5730
5735
  }
5731
5736
  request() {
@@ -6051,13 +6056,13 @@ var TwickPlayer = class extends HTMLElement {
6051
6056
  __publicField(this, "player", null);
6052
6057
  __publicField(this, "defaultSettings");
6053
6058
  __publicField(this, "abortController", null);
6054
- __publicField(this, "playing", false);
6059
+ __publicField(this, "_playing", false);
6055
6060
  __publicField(this, "stage", new Stage());
6056
6061
  __publicField(this, "time", 0);
6057
6062
  __publicField(this, "duration", 0);
6058
6063
  // in frames
6059
- __publicField(this, "looping", true);
6060
- __publicField(this, "volume", 1);
6064
+ __publicField(this, "_looping", true);
6065
+ __publicField(this, "_volume", 1);
6061
6066
  __publicField(this, "volumeChangeRequested", true);
6062
6067
  /**
6063
6068
  * Triggered by the timeline.
@@ -6068,8 +6073,10 @@ var TwickPlayer = class extends HTMLElement {
6068
6073
  return;
6069
6074
  }
6070
6075
  const e2 = event;
6071
- this.time = e2.detail;
6072
- (_a = this.player) == null ? void 0 : _a.requestSeek(e2.detail * this.player.playback.fps);
6076
+ const timeSec = e2.detail;
6077
+ const frame = timeSec * this.player.playback.fps;
6078
+ this.time = timeSec;
6079
+ (_a = this.player) == null ? void 0 : _a.requestSeek(frame);
6073
6080
  this.volumeChangeRequested = true;
6074
6081
  });
6075
6082
  __publicField(this, "handleVolumeChange", (event) => {
@@ -6078,8 +6085,8 @@ var TwickPlayer = class extends HTMLElement {
6078
6085
  return;
6079
6086
  }
6080
6087
  const e2 = event;
6081
- this.volume = e2.detail;
6082
- (_a = this.player) == null ? void 0 : _a.playback.currentScene.adjustVolume(this.volume);
6088
+ this._volume = e2.detail;
6089
+ (_a = this.player) == null ? void 0 : _a.playback.currentScene.adjustVolume(this._volume);
6083
6090
  });
6084
6091
  /**
6085
6092
  * Triggered by the player.
@@ -6091,7 +6098,7 @@ var TwickPlayer = class extends HTMLElement {
6091
6098
  }
6092
6099
  this.time = frame / this.player.playback.fps;
6093
6100
  if (this.volumeChangeRequested || frame === 0) {
6094
- (_a = this.player) == null ? void 0 : _a.playback.currentScene.adjustVolume(this.volume);
6101
+ (_a = this.player) == null ? void 0 : _a.playback.currentScene.adjustVolume(this._volume);
6095
6102
  this.volumeChangeRequested = false;
6096
6103
  }
6097
6104
  });
@@ -6144,11 +6151,21 @@ var TwickPlayer = class extends HTMLElement {
6144
6151
  const attr = this.getAttribute("fps");
6145
6152
  return attr ? parseFloat(attr) : ((_a = this.defaultSettings) == null ? void 0 : _a.fps) ?? 60;
6146
6153
  }
6154
+ set fps(value) {
6155
+ if (value != null && Number.isFinite(value)) {
6156
+ this.setAttribute("fps", String(value));
6157
+ }
6158
+ }
6147
6159
  get quality() {
6148
6160
  var _a;
6149
6161
  const attr = this.getAttribute("quality");
6150
6162
  return attr ? parseFloat(attr) : ((_a = this.defaultSettings) == null ? void 0 : _a.resolutionScale) ?? 1;
6151
6163
  }
6164
+ set quality(value) {
6165
+ if (value != null && Number.isFinite(value)) {
6166
+ this.setAttribute("quality", String(value));
6167
+ }
6168
+ }
6152
6169
  get width() {
6153
6170
  var _a;
6154
6171
  const attr = this.getAttribute("width");
@@ -6179,26 +6196,46 @@ var TwickPlayer = class extends HTMLElement {
6179
6196
  return {};
6180
6197
  }
6181
6198
  }
6199
+ get volume() {
6200
+ return this._volume;
6201
+ }
6202
+ set volume(value) {
6203
+ if (value != null) {
6204
+ this.setAttribute("volume", String(value));
6205
+ }
6206
+ }
6207
+ set playing(value) {
6208
+ this.setAttribute(
6209
+ "playing",
6210
+ value === true || value === "true" ? "true" : "false"
6211
+ );
6212
+ }
6213
+ set looping(value) {
6214
+ this.setAttribute(
6215
+ "looping",
6216
+ value === true || value === "true" ? "true" : "false"
6217
+ );
6218
+ }
6182
6219
  setProject(project) {
6183
6220
  this.updateProject(project);
6184
6221
  }
6185
6222
  setState(state) {
6186
6223
  this.state = state;
6187
- this.setPlaying(this.playing);
6224
+ this.setPlaying(this._playing);
6188
6225
  }
6189
6226
  setPlaying(value) {
6190
6227
  var _a, _b;
6191
6228
  if (this.state === "ready" && value) {
6192
6229
  (_a = this.player) == null ? void 0 : _a.togglePlayback(true);
6193
- this.playing = true;
6230
+ this._playing = true;
6194
6231
  } else {
6195
6232
  (_b = this.player) == null ? void 0 : _b.togglePlayback(false);
6196
- this.playing = false;
6233
+ this._playing = false;
6197
6234
  }
6198
6235
  }
6199
6236
  async updateProject(project) {
6200
6237
  var _a, _b, _c, _d, _e;
6201
- const playing = this.playing;
6238
+ const playing = this._playing;
6202
6239
  this.setState(
6203
6240
  "initial"
6204
6241
  /* Initial */
@@ -6209,7 +6246,7 @@ var TwickPlayer = class extends HTMLElement {
6209
6246
  this.defaultSettings = getFullPreviewSettings(this.project);
6210
6247
  const player = new Player(this.project);
6211
6248
  player.setVariables(this.variables);
6212
- player.toggleLoop(this.looping);
6249
+ player.toggleLoop(this._looping);
6213
6250
  (_b = this.player) == null ? void 0 : _b.onRender.unsubscribe(this.render);
6214
6251
  (_c = this.player) == null ? void 0 : _c.onFrameChanged.unsubscribe(this.handleFrameChanged);
6215
6252
  (_d = this.player) == null ? void 0 : _d.togglePlayback(false);
@@ -6237,7 +6274,7 @@ var TwickPlayer = class extends HTMLElement {
6237
6274
  (_c = this.player) == null ? void 0 : _c.playback.reload();
6238
6275
  break;
6239
6276
  case "looping":
6240
- this.looping = newValue === "true";
6277
+ this._looping = newValue === "true";
6241
6278
  (_d = this.player) == null ? void 0 : _d.toggleLoop(newValue === "true");
6242
6279
  break;
6243
6280
  case "fps":
@@ -6247,7 +6284,7 @@ var TwickPlayer = class extends HTMLElement {
6247
6284
  this.updateSettings();
6248
6285
  break;
6249
6286
  case "volume":
6250
- this.volume = newValue;
6287
+ this._volume = newValue;
6251
6288
  this.volumeChangeRequested = true;
6252
6289
  }
6253
6290
  }
@@ -6290,4 +6327,4 @@ var TwickPlayer = class extends HTMLElement {
6290
6327
  if (!customElements.get(ID)) {
6291
6328
  customElements.define(ID, TwickPlayer);
6292
6329
  }
6293
- //# sourceMappingURL=internal-KYB5ZQ5E-Be1ZlZZg.mjs.map
6330
+ //# sourceMappingURL=internal-LKI2GAXH-C1j65akX.mjs.map