mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Media Overlay: don't seek in canplaythrough
So this is what was causing the `canplaythrough` loop in Chromium and Firefox.
This commit is contained in:
@@ -456,6 +456,9 @@ class MediaOverlay extends EventTarget {
|
||||
const url = URL.createObjectURL(await this.book.loadBlob(src))
|
||||
const audio = new Audio(url)
|
||||
this.#audio = audio
|
||||
audio.currentTime = this.#activeItem.begin ?? 0
|
||||
audio.volume = this.#volume
|
||||
audio.playbackRate = this.#rate
|
||||
audio.addEventListener('timeupdate', () => {
|
||||
if (audio.paused) return
|
||||
const t = audio.currentTime
|
||||
@@ -481,12 +484,8 @@ class MediaOverlay extends EventTarget {
|
||||
this.#audio = null
|
||||
this.#play(audioIndex + 1, 0).catch(e => this.#error(e))
|
||||
})
|
||||
audio.addEventListener('canplaythrough', () => {
|
||||
audio.currentTime = this.#activeItem.begin ?? 0
|
||||
audio.volume = this.#volume
|
||||
audio.playbackRate = this.#rate
|
||||
audio.play().catch(e => this.#error(e))
|
||||
}, { once: true })
|
||||
audio.addEventListener('canplaythrough', () =>
|
||||
audio.play().catch(e => this.#error(e)), { once: true })
|
||||
}
|
||||
async start(sectionIndex, filter = () => true) {
|
||||
this.#audio?.pause()
|
||||
|
||||
Reference in New Issue
Block a user