avbridge 2.9.0 → 2.10.0

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.
@@ -32808,6 +32808,10 @@ var AudioOutput = class {
32808
32808
  _volume = 1;
32809
32809
  /** User-set muted flag. When true, gain is forced to 0. */
32810
32810
  _muted = false;
32811
+ /** Playback rate. Scales the media clock and each AudioBufferSourceNode's
32812
+ * playbackRate so audio pitches up/down accordingly (same as native
32813
+ * <video>.playbackRate). Default 1. */
32814
+ _rate = 1;
32811
32815
  constructor() {
32812
32816
  this.ctx = new AudioContext();
32813
32817
  this.gain = this.ctx.createGain();
@@ -32829,6 +32833,20 @@ var AudioOutput = class {
32829
32833
  getMuted() {
32830
32834
  return this._muted;
32831
32835
  }
32836
+ /** Set playback rate. Scales the media clock and pitches audio output
32837
+ * (same as native <video>.playbackRate — speed without pitch correction).
32838
+ * Rebases the anchor so the clock transition is seamless. */
32839
+ setPlaybackRate(rate) {
32840
+ if (rate === this._rate) return;
32841
+ const t = this.now();
32842
+ this.mediaTimeOfAnchor = t;
32843
+ this.ctxTimeAtAnchor = this.ctx.currentTime;
32844
+ this.wallAnchorMs = performance.now();
32845
+ this._rate = rate;
32846
+ }
32847
+ getPlaybackRate() {
32848
+ return this._rate;
32849
+ }
32832
32850
  applyGain() {
32833
32851
  const target = this._muted ? 0 : this._volume;
32834
32852
  try {
@@ -32849,12 +32867,12 @@ var AudioOutput = class {
32849
32867
  now() {
32850
32868
  if (this.noAudio) {
32851
32869
  if (this.state === "playing") {
32852
- return this.mediaTimeOfAnchor + (performance.now() - this.wallAnchorMs) / 1e3;
32870
+ return this.mediaTimeOfAnchor + (performance.now() - this.wallAnchorMs) / 1e3 * this._rate;
32853
32871
  }
32854
32872
  return this.mediaTimeOfAnchor;
32855
32873
  }
32856
32874
  if (this.state === "playing") {
32857
- return this.mediaTimeOfAnchor + (this.ctx.currentTime - this.ctxTimeAtAnchor);
32875
+ return this.mediaTimeOfAnchor + (this.ctx.currentTime - this.ctxTimeAtAnchor) * this._rate;
32858
32876
  }
32859
32877
  return this.mediaTimeOfAnchor;
32860
32878
  }
@@ -32906,7 +32924,8 @@ var AudioOutput = class {
32906
32924
  const node3 = this.ctx.createBufferSource();
32907
32925
  node3.buffer = buffer;
32908
32926
  node3.connect(this.gain);
32909
- let ctxStart = this.ctxTimeAtAnchor + (this.mediaTimeOfNext - this.mediaTimeOfAnchor);
32927
+ if (this._rate !== 1) node3.playbackRate.value = this._rate;
32928
+ let ctxStart = this.ctxTimeAtAnchor + (this.mediaTimeOfNext - this.mediaTimeOfAnchor) / this._rate;
32910
32929
  if (ctxStart < this.ctx.currentTime) {
32911
32930
  this.ctxTimeAtAnchor = this.ctx.currentTime;
32912
32931
  this.mediaTimeOfAnchor = this.mediaTimeOfNext;
@@ -33738,6 +33757,14 @@ async function createHybridSession(ctx, target, transport) {
33738
33757
  get: () => ctx.duration ?? NaN
33739
33758
  });
33740
33759
  }
33760
+ Object.defineProperty(target, "playbackRate", {
33761
+ configurable: true,
33762
+ get: () => audio.getPlaybackRate(),
33763
+ set: (v) => {
33764
+ audio.setPlaybackRate(v);
33765
+ target.dispatchEvent(new Event("ratechange"));
33766
+ }
33767
+ });
33741
33768
  Object.defineProperty(target, "readyState", {
33742
33769
  configurable: true,
33743
33770
  get: () => {
@@ -33848,6 +33875,7 @@ async function createHybridSession(ctx, target, transport) {
33848
33875
  delete target.muted;
33849
33876
  delete target.readyState;
33850
33877
  delete target.seekable;
33878
+ delete target.playbackRate;
33851
33879
  } catch {
33852
33880
  }
33853
33881
  },
@@ -34386,6 +34414,14 @@ async function createFallbackSession(ctx, target, transport) {
34386
34414
  get: () => ctx.duration ?? NaN
34387
34415
  });
34388
34416
  }
34417
+ Object.defineProperty(target, "playbackRate", {
34418
+ configurable: true,
34419
+ get: () => audio.getPlaybackRate(),
34420
+ set: (v) => {
34421
+ audio.setPlaybackRate(v);
34422
+ target.dispatchEvent(new Event("ratechange"));
34423
+ }
34424
+ });
34389
34425
  Object.defineProperty(target, "readyState", {
34390
34426
  configurable: true,
34391
34427
  get: () => {
@@ -34517,6 +34553,7 @@ async function createFallbackSession(ctx, target, transport) {
34517
34553
  delete target.muted;
34518
34554
  delete target.readyState;
34519
34555
  delete target.seekable;
34556
+ delete target.playbackRate;
34520
34557
  } catch {
34521
34558
  }
34522
34559
  },