@shotstack/shotstack-studio 2.19.4 → 2.19.5

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.
@@ -11,7 +11,7 @@ import "pixi.js/text-html";
11
11
  import "pixi.js/sprite-tiling";
12
12
  import "pixi.js/filters";
13
13
  import "pixi.js/mesh";
14
- const GI = "2.19.3", qI = {
14
+ const GI = "2.19.4", qI = {
15
15
  version: GI
16
16
  };
17
17
  function av(e, t, i) {
@@ -42502,11 +42502,13 @@ class _K extends Mi {
42502
42502
  this.volumeKeyframeBuilder = new ia(r.volume ?? 1, this.getLength()), this.syncTimer = 0, this.activeSyncTimer = 0, this.skipVideoUpdate = !1;
42503
42503
  }
42504
42504
  async load() {
42505
- await super.load();
42505
+ this.skipVideoUpdate = !0, await super.load();
42506
42506
  try {
42507
42507
  await this.loadVideo(), this.configureKeyframes();
42508
42508
  } catch (t) {
42509
42509
  console.warn(`[VideoPlayer.load] FAILED clipId=${this.clipId}:`, t), this.createFallbackGraphic();
42510
+ } finally {
42511
+ this.skipVideoUpdate = !1;
42510
42512
  }
42511
42513
  }
42512
42514
  createFallbackGraphic() {
@@ -42516,10 +42518,10 @@ class _K extends Mi {
42516
42518
  update(t, i) {
42517
42519
  if (super.update(t, i), this.skipVideoUpdate || (this.syncTimer += i, !this.texture))
42518
42520
  return;
42519
- const r = this.getAssetSpeed(), n = this.getSourceTime(), s = this.edit.isPlaying && this.isActive() && r > 0;
42520
- s && (this.isPlaying || (this.isPlaying = !0, this.activeSyncTimer = 0, this.texture.source.resource.volume = this.getVolume(), this.texture.source.resource.currentTime = n, this.texture.source.resource.play().catch(console.error)), this.texture.source.resource.volume !== this.getVolume() && (this.texture.source.resource.volume = this.getVolume()), this.texture.source.resource.playbackRate !== r && (this.texture.source.resource.playbackRate = r), this.activeSyncTimer += i, this.activeSyncTimer > 1e3 && (this.activeSyncTimer = 0, Math.abs(this.texture.source.resource.currentTime - n) > 0.3 && (this.texture.source.resource.currentTime = n))), !s && this.isPlaying && (this.isPlaying = !1, this.texture.source.resource.pause());
42521
- const a = this.syncTimer > 100;
42522
- (!this.edit.isPlaying || r === 0) && this.isActive() && a && (this.syncTimer = 0, this.texture.source.resource.currentTime = n);
42521
+ const r = this.getAssetSpeed(), n = this.getSourceTime(), s = this.edit.isPlaying && this.isActive() && r > 0, a = 0.3;
42522
+ s && (this.isPlaying || (this.isPlaying = !0, this.activeSyncTimer = 0, this.texture.source.resource.volume = this.getVolume(), Math.abs(this.texture.source.resource.currentTime - n) > a && (this.texture.source.resource.currentTime = n), this.texture.source.resource.play().catch(console.error)), this.texture.source.resource.volume !== this.getVolume() && (this.texture.source.resource.volume = this.getVolume()), this.texture.source.resource.playbackRate !== r && (this.texture.source.resource.playbackRate = r), this.activeSyncTimer += i, this.activeSyncTimer > 1e3 && (this.activeSyncTimer = 0, Math.abs(this.texture.source.resource.currentTime - n) > a && (this.texture.source.resource.currentTime = n))), !s && this.isPlaying && (this.isPlaying = !1, this.texture.source.resource.pause());
42523
+ const o = this.syncTimer > 100;
42524
+ (this.edit.playbackTime < this.getStart() || (!this.edit.isPlaying || r === 0) && this.isActive() && o) && (this.syncTimer = 0, Math.abs(this.texture.source.resource.currentTime - n) > 0.01 && (this.texture.source.resource.currentTime = n));
42523
42525
  }
42524
42526
  dispose() {
42525
42527
  this.disposeVideo(), this.clearPlaceholder(), super.dispose();
@@ -42560,12 +42562,27 @@ class _K extends Mi {
42560
42562
  throw new Error(`Invalid video source '${i}'.`);
42561
42563
  this.clearPlaceholder(), s.source.alphaMode = "no-premultiply-alpha", this.texture = this.createCroppedTexture(s);
42562
42564
  const a = this.texture.source.resource;
42563
- a instanceof HTMLVideoElement && a.readyState < 2 && await new Promise((o) => {
42565
+ if (a instanceof HTMLVideoElement && a.readyState < 2 && await new Promise((o) => {
42564
42566
  const l = () => {
42565
42567
  a.removeEventListener("loadeddata", l), o();
42566
42568
  };
42567
42569
  a.addEventListener("loadeddata", l), a.readyState >= 2 && o();
42568
- }), this.sprite = new X.Sprite(this.texture), this.contentContainer.addChild(this.sprite), this.texture.source.resource.volume = this.getVolume(), this.texture.source.resource.preservesPitch = !1;
42570
+ }), a instanceof HTMLVideoElement) {
42571
+ const o = this.getSourceTime();
42572
+ if (Math.abs(a.currentTime - o) > 0.01) {
42573
+ const l = await new Promise((u) => {
42574
+ const c = ["seeked", "abort", "emptied", "error"], d = (f) => {
42575
+ for (const h of c) a.removeEventListener(h, d);
42576
+ u(f?.type);
42577
+ };
42578
+ for (const f of c) a.addEventListener(f, d);
42579
+ a.currentTime = o, a.seeking || d();
42580
+ });
42581
+ if (this.texture?.source.resource !== a || l === "abort" || l === "emptied") return;
42582
+ if (l === "error") throw new Error("Video seeking failed.");
42583
+ }
42584
+ }
42585
+ this.sprite = new X.Sprite(this.texture), this.contentContainer.addChild(this.sprite), this.texture.source.resource.volume = this.getVolume(), this.texture.source.resource.preservesPitch = !1;
42569
42586
  }
42570
42587
  disposeVideo() {
42571
42588
  this.texture?.source?.resource && (this.texture.source.resource.pause(), this.texture.source.resource.src = "", this.texture.source.resource.load()), this.sprite && (this.contentContainer.removeChild(this.sprite), this.sprite.destroy(), this.sprite = null), this.texture && (this.texture.destroy(!0), this.texture = null);
@@ -45286,7 +45303,7 @@ class GX {
45286
45303
  if (d) {
45287
45304
  const f = this.updatePlayer(d, u, a);
45288
45305
  f === "recreate" ? (this.disposePlayer(c), i.push(this.createPlayer(u, c, a, l)), r.disposed.push(c), r.created.push(c)) : f && r.updated.push(c);
45289
- } else this.enableCreation && (this.createPlayer(u, c, a, l), r.created.push(c));
45306
+ } else this.enableCreation && (i.push(this.createPlayer(u, c, a, l)), r.created.push(c));
45290
45307
  }
45291
45308
  }
45292
45309
  }