@readium/navigator 2.4.0-beta.3 → 2.4.0-beta.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.
- package/dist/index.js +17 -18
- package/dist/index.umd.cjs +3 -3
- package/package.json +1 -1
- package/src/audio/AudioNavigator.ts +8 -8
- package/src/audio/engine/AudioEngine.ts +0 -5
- package/src/audio/engine/WebAudioEngine.ts +7 -4
- package/src/preferences/Types.ts +1 -1
- package/types/src/audio/AudioNavigator.d.ts +1 -0
- package/types/src/audio/engine/AudioEngine.d.ts +0 -4
- package/types/src/audio/engine/WebAudioEngine.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -3622,7 +3622,7 @@ const Ct = class Ct extends bt {
|
|
|
3622
3622
|
), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
|
|
3623
3623
|
value: {
|
|
3624
3624
|
name: "readium-ts-toolkit",
|
|
3625
|
-
version: "2.4.0-beta.
|
|
3625
|
+
version: "2.4.0-beta.5",
|
|
3626
3626
|
hasFeature: (n, r = "") => {
|
|
3627
3627
|
switch (n) {
|
|
3628
3628
|
case "dom-manipulation":
|
|
@@ -4685,7 +4685,7 @@ const ht = {
|
|
|
4685
4685
|
step: 0.1
|
|
4686
4686
|
}, te = {
|
|
4687
4687
|
range: [0.5, 2],
|
|
4688
|
-
step: 0.
|
|
4688
|
+
step: 0.1
|
|
4689
4689
|
}, et = {
|
|
4690
4690
|
range: [5, 60],
|
|
4691
4691
|
step: 5
|
|
@@ -10083,7 +10083,7 @@ class Be {
|
|
|
10083
10083
|
}
|
|
10084
10084
|
class _s {
|
|
10085
10085
|
constructor(t) {
|
|
10086
|
-
this.audioContext = null, this.sourceNode = null, this.gainNode = null, this.listeners = {}, this.currentPlaybackRate = 1, this.isMutedValue = !1, this.isPlayingValue = !1, this.isPausedValue = !1, this.isLoadingValue = !1, this.isLoadedValue = !1, this.isEndedValue = !1, this.isStoppedValue = !1, this.worklet = null, this.webAudioActive = !1, this.boundOnCanPlayThrough = this.onCanPlayThrough.bind(this), this.boundOnTimeUpdate = this.onTimeUpdate.bind(this), this.boundOnError = this.onError.bind(this), this.boundOnEnded = this.onEnded.bind(this), this.boundOnStalled = this.onStalled.bind(this), this.boundOnEmptied = this.onEmptied.bind(this), this.boundOnSuspend = this.onSuspend.bind(this), this.boundOnWaiting = this.onWaiting.bind(this), this.boundOnLoadedMetadata = this.onLoadedMetadata.bind(this), this.boundOnSeeking = this.onSeeking.bind(this), this.boundOnSeeked = this.onSeeked.bind(this), this.boundOnPlay = this.onPlay.bind(this), this.boundOnPlaying = this.onPlaying.bind(this), this.boundOnPause = this.onPause.bind(this), this.boundOnProgress = this.onProgress.bind(this), this.playback = t.playback, this.mediaElement = document.createElement("audio"), this.
|
|
10086
|
+
this.audioContext = null, this.sourceNode = null, this.gainNode = null, this.listeners = {}, this.currentVolume = 1, this.currentPlaybackRate = 1, this.isMutedValue = !1, this.isPlayingValue = !1, this.isPausedValue = !1, this.isLoadingValue = !1, this.isLoadedValue = !1, this.isEndedValue = !1, this.isStoppedValue = !1, this.worklet = null, this.webAudioActive = !1, this.boundOnCanPlayThrough = this.onCanPlayThrough.bind(this), this.boundOnTimeUpdate = this.onTimeUpdate.bind(this), this.boundOnError = this.onError.bind(this), this.boundOnEnded = this.onEnded.bind(this), this.boundOnStalled = this.onStalled.bind(this), this.boundOnEmptied = this.onEmptied.bind(this), this.boundOnSuspend = this.onSuspend.bind(this), this.boundOnWaiting = this.onWaiting.bind(this), this.boundOnLoadedMetadata = this.onLoadedMetadata.bind(this), this.boundOnSeeking = this.onSeeking.bind(this), this.boundOnSeeked = this.onSeeked.bind(this), this.boundOnPlay = this.onPlay.bind(this), this.boundOnPlaying = this.onPlaying.bind(this), this.boundOnPause = this.onPause.bind(this), this.boundOnProgress = this.onProgress.bind(this), this.playback = t.playback, this.mediaElement = document.createElement("audio"), this.mediaElement.addEventListener("canplaythrough", this.boundOnCanPlayThrough), this.mediaElement.addEventListener("timeupdate", this.boundOnTimeUpdate), this.mediaElement.addEventListener("error", this.boundOnError), this.mediaElement.addEventListener("ended", this.boundOnEnded), this.mediaElement.addEventListener("stalled", this.boundOnStalled), this.mediaElement.addEventListener("emptied", this.boundOnEmptied), this.mediaElement.addEventListener("suspend", this.boundOnSuspend), this.mediaElement.addEventListener("waiting", this.boundOnWaiting), this.mediaElement.addEventListener("loadedmetadata", this.boundOnLoadedMetadata), this.mediaElement.addEventListener("seeking", this.boundOnSeeking), this.mediaElement.addEventListener("seeked", this.boundOnSeeked), this.mediaElement.addEventListener("play", this.boundOnPlay), this.mediaElement.addEventListener("playing", this.boundOnPlaying), this.mediaElement.addEventListener("pause", this.boundOnPause), this.mediaElement.addEventListener("progress", this.boundOnProgress), this.mediaElement.currentTime = this.playback.state.currentTime;
|
|
10087
10087
|
}
|
|
10088
10088
|
/**
|
|
10089
10089
|
* Adds an event listener to the audio engine.
|
|
@@ -10109,15 +10109,15 @@ class _s {
|
|
|
10109
10109
|
* */
|
|
10110
10110
|
loadAudio(t) {
|
|
10111
10111
|
if (this.isLoadingValue = !0, this.isLoadedValue = !1, this.isPlayingValue = !1, this.isPausedValue = !1, this.webAudioActive) {
|
|
10112
|
-
this.mediaElement.crossOrigin = "anonymous", this.mediaElement.src = t, this.mediaElement.load();
|
|
10112
|
+
this.mediaElement.crossOrigin = "anonymous", this.mediaElement.src = t, this.mediaElement.load(), this.mediaElement.playbackRate = this.currentPlaybackRate;
|
|
10113
10113
|
const e = () => {
|
|
10114
10114
|
this.mediaElement.removeEventListener("error", i), this.mediaElement.removeEventListener("canplaythrough", n);
|
|
10115
10115
|
}, i = () => {
|
|
10116
|
-
e(), this.deactivateWebAudio(), this.mediaElement.removeAttribute("crossOrigin"), this.mediaElement.src = t, this.mediaElement.load();
|
|
10116
|
+
e(), this.deactivateWebAudio(), this.mediaElement.removeAttribute("crossOrigin"), this.mediaElement.src = t, this.mediaElement.load(), this.mediaElement.playbackRate = this.currentPlaybackRate;
|
|
10117
10117
|
}, n = () => e();
|
|
10118
10118
|
this.mediaElement.addEventListener("error", i), this.mediaElement.addEventListener("canplaythrough", n);
|
|
10119
10119
|
} else
|
|
10120
|
-
this.mediaElement.src = t, this.mediaElement.load();
|
|
10120
|
+
this.mediaElement.src = t, this.mediaElement.load(), this.mediaElement.playbackRate = this.currentPlaybackRate;
|
|
10121
10121
|
}
|
|
10122
10122
|
deactivateWebAudio() {
|
|
10123
10123
|
this.worklet && (this.worklet.destroy(), this.worklet = null), this.sourceNode && (this.sourceNode.disconnect(), this.sourceNode = null), this.gainNode && (this.gainNode.disconnect(), this.gainNode = null), this.webAudioActive = !1;
|
|
@@ -10127,7 +10127,7 @@ class _s {
|
|
|
10127
10127
|
* @param element The HTML audio element to use.
|
|
10128
10128
|
*/
|
|
10129
10129
|
setMediaElement(t) {
|
|
10130
|
-
this.mediaElement.pause(), this.isPlayingValue = !1, this.isPausedValue = !1, this.sourceNode && (this.sourceNode.disconnect(), this.sourceNode = null), this.mediaElement.removeEventListener("canplaythrough", this.boundOnCanPlayThrough), this.mediaElement.removeEventListener("timeupdate", this.boundOnTimeUpdate), this.mediaElement.removeEventListener("error", this.boundOnError), this.mediaElement.removeEventListener("ended", this.boundOnEnded), this.mediaElement.removeEventListener("stalled", this.boundOnStalled), this.mediaElement.removeEventListener("emptied", this.boundOnEmptied), this.mediaElement.removeEventListener("suspend", this.boundOnSuspend), this.mediaElement.removeEventListener("waiting", this.boundOnWaiting), this.mediaElement.removeEventListener("loadedmetadata", this.boundOnLoadedMetadata), this.mediaElement.removeEventListener("seeking", this.boundOnSeeking), this.mediaElement.removeEventListener("seeked", this.boundOnSeeked), this.mediaElement.removeEventListener("play", this.boundOnPlay), this.mediaElement.removeEventListener("playing", this.boundOnPlaying), this.mediaElement.removeEventListener("pause", this.boundOnPause), this.mediaElement.removeEventListener("progress", this.boundOnProgress), this.mediaElement = t, this.mediaElement.addEventListener("canplaythrough", this.boundOnCanPlayThrough), this.mediaElement.addEventListener("timeupdate", this.boundOnTimeUpdate), this.mediaElement.addEventListener("error", this.boundOnError), this.mediaElement.addEventListener("ended", this.boundOnEnded), this.mediaElement.addEventListener("stalled", this.boundOnStalled), this.mediaElement.addEventListener("emptied", this.boundOnEmptied), this.mediaElement.addEventListener("suspend", this.boundOnSuspend), this.mediaElement.addEventListener("waiting", this.boundOnWaiting), this.mediaElement.addEventListener("loadedmetadata", this.boundOnLoadedMetadata), this.mediaElement.addEventListener("seeking", this.boundOnSeeking), this.mediaElement.addEventListener("seeked", this.boundOnSeeked), this.mediaElement.addEventListener("play", this.boundOnPlay), this.mediaElement.addEventListener("playing", this.boundOnPlaying), this.mediaElement.addEventListener("pause", this.boundOnPause), this.mediaElement.addEventListener("progress", this.boundOnProgress), this.mediaElement.volume = this.isMutedValue ? 0 : this.
|
|
10130
|
+
this.mediaElement.pause(), this.isPlayingValue = !1, this.isPausedValue = !1, this.sourceNode && (this.sourceNode.disconnect(), this.sourceNode = null), this.mediaElement.removeEventListener("canplaythrough", this.boundOnCanPlayThrough), this.mediaElement.removeEventListener("timeupdate", this.boundOnTimeUpdate), this.mediaElement.removeEventListener("error", this.boundOnError), this.mediaElement.removeEventListener("ended", this.boundOnEnded), this.mediaElement.removeEventListener("stalled", this.boundOnStalled), this.mediaElement.removeEventListener("emptied", this.boundOnEmptied), this.mediaElement.removeEventListener("suspend", this.boundOnSuspend), this.mediaElement.removeEventListener("waiting", this.boundOnWaiting), this.mediaElement.removeEventListener("loadedmetadata", this.boundOnLoadedMetadata), this.mediaElement.removeEventListener("seeking", this.boundOnSeeking), this.mediaElement.removeEventListener("seeked", this.boundOnSeeked), this.mediaElement.removeEventListener("play", this.boundOnPlay), this.mediaElement.removeEventListener("playing", this.boundOnPlaying), this.mediaElement.removeEventListener("pause", this.boundOnPause), this.mediaElement.removeEventListener("progress", this.boundOnProgress), this.mediaElement = t, this.mediaElement.addEventListener("canplaythrough", this.boundOnCanPlayThrough), this.mediaElement.addEventListener("timeupdate", this.boundOnTimeUpdate), this.mediaElement.addEventListener("error", this.boundOnError), this.mediaElement.addEventListener("ended", this.boundOnEnded), this.mediaElement.addEventListener("stalled", this.boundOnStalled), this.mediaElement.addEventListener("emptied", this.boundOnEmptied), this.mediaElement.addEventListener("suspend", this.boundOnSuspend), this.mediaElement.addEventListener("waiting", this.boundOnWaiting), this.mediaElement.addEventListener("loadedmetadata", this.boundOnLoadedMetadata), this.mediaElement.addEventListener("seeking", this.boundOnSeeking), this.mediaElement.addEventListener("seeked", this.boundOnSeeked), this.mediaElement.addEventListener("play", this.boundOnPlay), this.mediaElement.addEventListener("playing", this.boundOnPlaying), this.mediaElement.addEventListener("pause", this.boundOnPause), this.mediaElement.addEventListener("progress", this.boundOnProgress), this.mediaElement.volume = this.isMutedValue ? 0 : this.currentVolume, this.mediaElement.playbackRate = this.currentPlaybackRate, this.mediaElement.readyState >= 1 && this.onLoadedMetadata(new Event("loadedmetadata")), this.mediaElement.seekable.length > 0 && this.onProgress(), this.mediaElement.readyState >= 4 ? this.onCanPlayThrough() : (this.isLoadingValue = !0, this.isLoadedValue = !1);
|
|
10131
10131
|
}
|
|
10132
10132
|
// Ensure AudioContext is running
|
|
10133
10133
|
async ensureAudioContextRunning() {
|
|
@@ -10219,14 +10219,14 @@ class _s {
|
|
|
10219
10219
|
*/
|
|
10220
10220
|
setVolume(t) {
|
|
10221
10221
|
if (t < 0) {
|
|
10222
|
-
this.mediaElement.volume = 0, this.gainNode && (this.gainNode.gain.value = 0), this.isMutedValue = !0
|
|
10222
|
+
this.currentVolume = 0, this.mediaElement.volume = 0, this.gainNode && (this.gainNode.gain.value = 0), this.isMutedValue = !0;
|
|
10223
10223
|
return;
|
|
10224
10224
|
}
|
|
10225
10225
|
if (t > 1) {
|
|
10226
10226
|
this.setVolume(t / 100);
|
|
10227
10227
|
return;
|
|
10228
10228
|
}
|
|
10229
|
-
this.mediaElement.volume = t, this.gainNode && (this.gainNode.gain.value = t)
|
|
10229
|
+
this.currentVolume = t, this.mediaElement.volume = t, this.gainNode && (this.gainNode.gain.value = t);
|
|
10230
10230
|
}
|
|
10231
10231
|
/**
|
|
10232
10232
|
* Skips [seconds] either forward or backward if [seconds] is negative.
|
|
@@ -10641,7 +10641,7 @@ class Os extends hr {
|
|
|
10641
10641
|
preferences: {},
|
|
10642
10642
|
defaults: {}
|
|
10643
10643
|
}) {
|
|
10644
|
-
if (super(), this.positionPollInterval = null, this.navigationId = 0, this._preferencesEditor = null, this._navigatorProtector = null, this._keyboardPeripheralsManager = null, this._suspiciousActivityListener = null, this._keyboardPeripheralListener = null, this.pub = t, this.listeners = Ls(e), this._preferences = new oe(n.preferences), this._defaults = new Ps(n.defaults), this._settings = new Fi(this._preferences, this._defaults), i)
|
|
10644
|
+
if (super(), this.positionPollInterval = null, this.navigationId = 0, this._preferencesEditor = null, this._mediaSessionEnabled = !1, this._navigatorProtector = null, this._keyboardPeripheralsManager = null, this._suspiciousActivityListener = null, this._keyboardPeripheralListener = null, this.pub = t, this.listeners = Ls(e), this._preferences = new oe(n.preferences), this._defaults = new Ps(n.defaults), this._settings = new Fi(this._preferences, this._defaults), i)
|
|
10645
10645
|
this.currentLocation = this.ensureLocatorLocations(i);
|
|
10646
10646
|
else {
|
|
10647
10647
|
const u = this.pub.readingOrder.items[0];
|
|
@@ -10661,8 +10661,7 @@ class Os extends hr {
|
|
|
10661
10661
|
playback: {
|
|
10662
10662
|
state: {
|
|
10663
10663
|
currentTime: a,
|
|
10664
|
-
duration: 0
|
|
10665
|
-
volume: this._settings.volume
|
|
10664
|
+
duration: 0
|
|
10666
10665
|
},
|
|
10667
10666
|
playWhenReady: !1,
|
|
10668
10667
|
index: o
|
|
@@ -10678,7 +10677,7 @@ class Os extends hr {
|
|
|
10678
10677
|
m === "context_menu" ? this.listeners.contextMenu(y) : this.listeners.contentProtection(m, y);
|
|
10679
10678
|
}, window.addEventListener(st, this._suspiciousActivityListener)), c.length > 0 && (this._keyboardPeripheralsManager = new He({ keyboardPeripherals: c }), this._keyboardPeripheralListener = (u) => {
|
|
10680
10679
|
this.listeners.peripheral(u.detail);
|
|
10681
|
-
}, window.addEventListener(ot, this._keyboardPeripheralListener)), this.setupEventListeners(), this.
|
|
10680
|
+
}, window.addEventListener(ot, this._keyboardPeripheralListener)), this.setupEventListeners(), this.applyPreferences(), this.pool.setCurrentAudio(o, "forward"), this.waitForLoadedAndSeeked(a).then(() => {
|
|
10682
10681
|
this.listeners.trackLoaded(this.pool.audioEngine.getMediaElement()), this.listeners.positionChanged(this.currentLocator);
|
|
10683
10682
|
}).catch(() => {
|
|
10684
10683
|
});
|
|
@@ -10693,8 +10692,7 @@ class Os extends hr {
|
|
|
10693
10692
|
this._preferences = this._preferences.merging(t), this.applyPreferences();
|
|
10694
10693
|
}
|
|
10695
10694
|
applyPreferences() {
|
|
10696
|
-
|
|
10697
|
-
this._settings = new Fi(this._preferences, this._defaults), this._preferencesEditor !== null && (this._preferencesEditor = new Ni(this._preferences, this.settings)), this.pool.audioEngine.setVolume(this._settings.volume), this.pool.audioEngine.setPlaybackRate(this._settings.playbackRate, this._settings.preservePitch), this._settings.enableMediaSession && !t.enableMediaSession ? this.setupMediaSession() : !this._settings.enableMediaSession && t.enableMediaSession && this.destroyMediaSession();
|
|
10695
|
+
this._settings = new Fi(this._preferences, this._defaults), this._preferencesEditor !== null && (this._preferencesEditor = new Ni(this._preferences, this.settings)), this.pool.audioEngine.setVolume(this._settings.volume), this.pool.audioEngine.setPlaybackRate(this._settings.playbackRate, this._settings.preservePitch), this._settings.enableMediaSession && !this._mediaSessionEnabled ? (this._mediaSessionEnabled = !0, this.setupMediaSession()) : !this._settings.enableMediaSession && this._mediaSessionEnabled && (this._mediaSessionEnabled = !1, this.destroyMediaSession());
|
|
10698
10696
|
}
|
|
10699
10697
|
get publication() {
|
|
10700
10698
|
return this.pub;
|
|
@@ -10812,11 +10810,12 @@ class Os extends hr {
|
|
|
10812
10810
|
}
|
|
10813
10811
|
updateMediaSessionMetadata() {
|
|
10814
10812
|
if (!("mediaSession" in navigator)) return;
|
|
10815
|
-
const t = this.currentTrackIndex(), e = this.pub.readingOrder.items[t];
|
|
10813
|
+
const t = this.currentTrackIndex(), e = this.pub.readingOrder.items[t], i = this.pub.getCover();
|
|
10816
10814
|
navigator.mediaSession.metadata = new MediaMetadata({
|
|
10817
10815
|
title: e?.title || `Track ${t + 1}`,
|
|
10818
|
-
artist: this.pub.metadata.authors ? this.pub.metadata.authors.items.map((
|
|
10819
|
-
album: this.pub.metadata.title.getTranslation()
|
|
10816
|
+
artist: this.pub.metadata.authors ? this.pub.metadata.authors.items.map((n) => n.name.getTranslation()).join(", ") : void 0,
|
|
10817
|
+
album: this.pub.metadata.title.getTranslation(),
|
|
10818
|
+
artwork: i ? [{ src: i.href, type: i.type }] : void 0
|
|
10820
10819
|
});
|
|
10821
10820
|
}
|
|
10822
10821
|
startPositionPolling() {
|