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 url = URL.createObjectURL(await this.book.loadBlob(src))
|
||||||
const audio = new Audio(url)
|
const audio = new Audio(url)
|
||||||
this.#audio = audio
|
this.#audio = audio
|
||||||
|
audio.currentTime = this.#activeItem.begin ?? 0
|
||||||
|
audio.volume = this.#volume
|
||||||
|
audio.playbackRate = this.#rate
|
||||||
audio.addEventListener('timeupdate', () => {
|
audio.addEventListener('timeupdate', () => {
|
||||||
if (audio.paused) return
|
if (audio.paused) return
|
||||||
const t = audio.currentTime
|
const t = audio.currentTime
|
||||||
@@ -481,12 +484,8 @@ class MediaOverlay extends EventTarget {
|
|||||||
this.#audio = null
|
this.#audio = null
|
||||||
this.#play(audioIndex + 1, 0).catch(e => this.#error(e))
|
this.#play(audioIndex + 1, 0).catch(e => this.#error(e))
|
||||||
})
|
})
|
||||||
audio.addEventListener('canplaythrough', () => {
|
audio.addEventListener('canplaythrough', () =>
|
||||||
audio.currentTime = this.#activeItem.begin ?? 0
|
audio.play().catch(e => this.#error(e)), { once: true })
|
||||||
audio.volume = this.#volume
|
|
||||||
audio.playbackRate = this.#rate
|
|
||||||
audio.play().catch(e => this.#error(e))
|
|
||||||
}, { once: true })
|
|
||||||
}
|
}
|
||||||
async start(sectionIndex, filter = () => true) {
|
async start(sectionIndex, filter = () => true) {
|
||||||
this.#audio?.pause()
|
this.#audio?.pause()
|
||||||
|
|||||||
Reference in New Issue
Block a user