mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Media Overlay: add volume setting
This commit is contained in:
@@ -272,6 +272,7 @@ class MediaOverlay extends EventTarget {
|
||||
#audioIndex
|
||||
#itemIndex
|
||||
#audio
|
||||
#volume = 1
|
||||
#rate = 1
|
||||
constructor(book, loadXML) {
|
||||
super()
|
||||
@@ -356,6 +357,7 @@ class MediaOverlay extends EventTarget {
|
||||
})
|
||||
audio.addEventListener('canplaythrough', () => {
|
||||
audio.currentTime = this.#activeItem.begin ?? 0
|
||||
audio.volume = this.#volume
|
||||
audio.playbackRate = this.#rate
|
||||
audio.play().catch(e => this.#error(e))
|
||||
})
|
||||
@@ -395,6 +397,10 @@ class MediaOverlay extends EventTarget {
|
||||
next() {
|
||||
this.#play(this.#audioIndex, this.#itemIndex + 1)
|
||||
}
|
||||
setVolume(volume) {
|
||||
this.#volume = volume
|
||||
if (this.#audio) this.#audio.volume = volume
|
||||
}
|
||||
setRate(rate) {
|
||||
this.#rate = rate
|
||||
if (this.#audio) this.#audio.playbackRate = rate
|
||||
|
||||
Reference in New Issue
Block a user