cacophony 0.5.21 → 0.5.22

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.
@@ -167,7 +167,6 @@ class u extends d {
167
167
  loopCount = 0;
168
168
  currentLoop = 0;
169
169
  buffer;
170
- playing = !1;
171
170
  /**
172
171
  * Gets the stereo panning value.
173
172
  * @returns {number | null} The current stereo pan value, or null if stereo panning is not applicable.
@@ -230,10 +229,10 @@ class u extends d {
230
229
  handleLoop = () => {
231
230
  if (!(!this.source || !this.panner)) {
232
231
  if (this.loopCount !== "infinite" && this.currentLoop > this.loopCount) {
233
- this.playing = !1;
232
+ this.stop();
234
233
  return;
235
234
  }
236
- this.loopCount !== "infinite" && this.currentLoop++, this.buffer ? (this.source = this.context.createBufferSource(), this.source.buffer = this.buffer, this.source.connect(this.panner), this.source.onended = this.handleLoop.bind(this), (this.loopCount === "infinite" || this.currentLoop <= this.loopCount) && this.source.start(0)) : this.seek(0), this.playing = !0;
235
+ this.loopCount !== "infinite" && this.currentLoop++, this.buffer ? (this.source = this.context.createBufferSource(), this.source.buffer = this.buffer, this.source.connect(this.panner), this.source.onended = this.handleLoop.bind(this), (this.loopCount === "infinite" || this.currentLoop <= this.loopCount) && this.source.start(0)) : this.seek(0);
237
236
  }
238
237
  };
239
238
  /**
@@ -244,7 +243,7 @@ class u extends d {
244
243
  play() {
245
244
  if (!this.source)
246
245
  throw new Error("Cannot play a sound that has been cleaned up");
247
- return "mediaElement" in this.source && this.source.mediaElement ? this.source.mediaElement.play() : "start" in this.source && this.source.start && this.source.start(), this.playing = !0, [this];
246
+ return "mediaElement" in this.source && this.source.mediaElement ? this.source.mediaElement.play() : "start" in this.source && this.source.start && this.source.start(), [this];
248
247
  }
249
248
  /**
250
249
  * Gets the 3D audio options if HRTF panning is used.
@@ -409,7 +408,7 @@ class u extends d {
409
408
  isPlaying() {
410
409
  if (!this.source)
411
410
  throw new Error("Cannot check if a sound is playing that has been cleaned up");
412
- return this.playing;
411
+ return "mediaElement" in this.source && this.source.mediaElement ? !this.source.mediaElement.paused : "playbackState" in this.source ? this.source.playbackState === "running" : !1;
413
412
  }
414
413
  /**
415
414
  * Cleans up resources used by the Playback instance.
@@ -443,7 +442,7 @@ class u extends d {
443
442
  stop() {
444
443
  if (!this.source)
445
444
  throw new Error("Cannot stop a sound that has been cleaned up");
446
- this.isPlaying() && ("stop" in this.source && this.source.stop(), "mediaElement" in this.source && this.source.mediaElement && (this.source.mediaElement.pause(), this.source.mediaElement.currentTime = 0), this.playing = !1);
445
+ this.isPlaying() && ("stop" in this.source && this.source.stop(), "mediaElement" in this.source && this.source.mediaElement && (this.source.mediaElement.pause(), this.source.mediaElement.currentTime = 0));
447
446
  }
448
447
  /**
449
448
  * Pauses the audio playback.