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
|
#audioIndex
|
||||||
#itemIndex
|
#itemIndex
|
||||||
#audio
|
#audio
|
||||||
|
#volume = 1
|
||||||
#rate = 1
|
#rate = 1
|
||||||
constructor(book, loadXML) {
|
constructor(book, loadXML) {
|
||||||
super()
|
super()
|
||||||
@@ -356,6 +357,7 @@ class MediaOverlay extends EventTarget {
|
|||||||
})
|
})
|
||||||
audio.addEventListener('canplaythrough', () => {
|
audio.addEventListener('canplaythrough', () => {
|
||||||
audio.currentTime = this.#activeItem.begin ?? 0
|
audio.currentTime = this.#activeItem.begin ?? 0
|
||||||
|
audio.volume = this.#volume
|
||||||
audio.playbackRate = this.#rate
|
audio.playbackRate = this.#rate
|
||||||
audio.play().catch(e => this.#error(e))
|
audio.play().catch(e => this.#error(e))
|
||||||
})
|
})
|
||||||
@@ -395,6 +397,10 @@ class MediaOverlay extends EventTarget {
|
|||||||
next() {
|
next() {
|
||||||
this.#play(this.#audioIndex, this.#itemIndex + 1)
|
this.#play(this.#audioIndex, this.#itemIndex + 1)
|
||||||
}
|
}
|
||||||
|
setVolume(volume) {
|
||||||
|
this.#volume = volume
|
||||||
|
if (this.#audio) this.#audio.volume = volume
|
||||||
|
}
|
||||||
setRate(rate) {
|
setRate(rate) {
|
||||||
this.#rate = rate
|
this.#rate = rate
|
||||||
if (this.#audio) this.#audio.playbackRate = rate
|
if (this.#audio) this.#audio.playbackRate = rate
|
||||||
|
|||||||
Reference in New Issue
Block a user