@d-i-t-a/reader 2.0.0-beta.12 → 2.0.0-beta.13

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.
package/dist/esm/index.js CHANGED
@@ -52688,7 +52688,7 @@ var MediaOverlayModule = class {
52688
52688
  console.log("ontimeupdate");
52689
52689
  this.trackCurrentTime();
52690
52690
  };
52691
- this.ensureOnTimeUpdate = (remove) => {
52691
+ this.ensureOnTimeUpdate = (remove, replace) => {
52692
52692
  if (this.audioElement) {
52693
52693
  if (remove) {
52694
52694
  if (this.__ontimeupdate) {
@@ -52697,8 +52697,11 @@ var MediaOverlayModule = class {
52697
52697
  cancelAnimationFrame(this.myReq);
52698
52698
  }
52699
52699
  } else {
52700
- if (!this.__ontimeupdate) {
52700
+ if (!this.__ontimeupdate || replace) {
52701
52701
  this.__ontimeupdate = true;
52702
+ if (replace) {
52703
+ this.audioElement.removeEventListener("timeupdate", this.ontimeupdate);
52704
+ }
52702
52705
  this.audioElement.addEventListener("timeupdate", this.ontimeupdate);
52703
52706
  }
52704
52707
  }
@@ -52742,7 +52745,7 @@ var MediaOverlayModule = class {
52742
52745
  async playLink() {
52743
52746
  let link = this.currentLinks[this.currentLinkIndex];
52744
52747
  if (link?.Properties?.MediaOverlay) {
52745
- this.ensureOnTimeUpdate(false);
52748
+ this.ensureOnTimeUpdate(false, false);
52746
52749
  const moUrl = link.Properties?.MediaOverlay;
52747
52750
  const moUrlObjFull = new URL(moUrl, this.publication.manifestUrl);
52748
52751
  const moUrlFull = moUrlObjFull.toString();
@@ -53110,25 +53113,22 @@ var MediaOverlayModule = class {
53110
53113
  if (IS_DEV) {
53111
53114
  console.log("playMediaOverlaysAudio() - playClip() - _currentAudioElement.play()");
53112
53115
  }
53113
- this.ensureOnTimeUpdate(false);
53116
+ this.ensureOnTimeUpdate(false, false);
53114
53117
  this.audioElement.playbackRate = this.settings.rate;
53115
53118
  this.audioElement.volume = this.settings.volume;
53116
53119
  if (this.settings.playing) {
53117
- if (!initial) {
53118
- let checkReady = function() {
53119
- if (!self2.settings.resourceReady) {
53120
- setTimeout(checkReady, 200);
53121
- } else {
53122
- setTimeout(async () => {
53123
- await self2.audioElement.play();
53124
- }, self2.settings.wait * 1200);
53125
- }
53126
- };
53127
- let self2 = this;
53128
- checkReady();
53129
- } else {
53130
- await this.audioElement.play();
53131
- }
53120
+ let checkReady = function() {
53121
+ if (!self2.settings.resourceReady) {
53122
+ setTimeout(checkReady, 200);
53123
+ } else {
53124
+ setTimeout(async () => {
53125
+ await self2.audioElement.play();
53126
+ self2.ensureOnTimeUpdate(false, true);
53127
+ }, self2.settings.wait * 1200);
53128
+ }
53129
+ };
53130
+ let self2 = this;
53131
+ checkReady();
53132
53132
  }
53133
53133
  } else {
53134
53134
  if (IS_DEV) {
@@ -53139,26 +53139,23 @@ var MediaOverlayModule = class {
53139
53139
  if (IS_DEV) {
53140
53140
  console.log("playMediaOverlaysAudio() - playClip() - ontimeupdateSeeked - .play()");
53141
53141
  }
53142
- this.ensureOnTimeUpdate(false);
53142
+ this.ensureOnTimeUpdate(false, false);
53143
53143
  if (this.audioElement) {
53144
53144
  this.audioElement.playbackRate = this.settings.rate;
53145
53145
  this.audioElement.volume = this.settings.volume;
53146
53146
  if (this.settings.playing) {
53147
- if (!initial) {
53148
- let checkReady = function() {
53149
- if (!self2.settings.resourceReady) {
53150
- setTimeout(checkReady, 200);
53151
- } else {
53152
- setTimeout(async () => {
53153
- await self2.audioElement.play();
53154
- }, self2.settings.wait * 1200);
53155
- }
53156
- };
53157
- let self2 = this;
53158
- checkReady();
53159
- } else {
53160
- await this.audioElement.play();
53161
- }
53147
+ let checkReady = function() {
53148
+ if (!self2.settings.resourceReady) {
53149
+ setTimeout(checkReady, 200);
53150
+ } else {
53151
+ setTimeout(async () => {
53152
+ await self2.audioElement.play();
53153
+ self2.ensureOnTimeUpdate(false, true);
53154
+ }, self2.settings.wait * 1200);
53155
+ }
53156
+ };
53157
+ let self2 = this;
53158
+ checkReady();
53162
53159
  }
53163
53160
  }
53164
53161
  };
@@ -53167,7 +53164,7 @@ var MediaOverlayModule = class {
53167
53164
  }
53168
53165
  } else {
53169
53166
  const contiguous = this.previousAudioUrl === this.currentAudioUrl && typeof this.previousAudioEnd !== "undefined" && this.previousAudioEnd > timeToSeekTo - 0.02 && this.previousAudioEnd <= timeToSeekTo && this.audioElement.currentTime >= timeToSeekTo - 0.1;
53170
- this.ensureOnTimeUpdate(false);
53167
+ this.ensureOnTimeUpdate(false, false);
53171
53168
  if (contiguous) {
53172
53169
  if (IS_DEV) {
53173
53170
  console.log("playMediaOverlaysAudio() - playClip() - ensureOnTimeUpdate");