fix playback modes

This commit is contained in:
SrGooglo 2023-08-03 07:19:53 +00:00
parent 3a57b1b5fb
commit 7a3d11eba7

View File

@ -65,7 +65,7 @@ export default class Player extends Core {
track_manifest: null, track_manifest: null,
playback_mode: AudioPlayerStorage.get("mode") ?? "repeat", playback_mode: AudioPlayerStorage.get("mode") ?? "normal",
playback_status: "stopped", playback_status: "stopped",
}) })
@ -509,6 +509,7 @@ export default class Player extends Core {
} }
this.track_instance.media.muted = this.state.muted this.track_instance.media.muted = this.state.muted
this.track_instance.media.loop = this.state.playback_mode === "repeat"
// try to preload next audio // try to preload next audio
if (this.track_next_instances.length > 0) { if (this.track_next_instances.length > 0) {
@ -778,6 +779,14 @@ export default class Player extends Core {
} }
this.state.playback_mode = mode this.state.playback_mode = mode
if (this.track_instance) {
this.track_instance.media.loop = this.state.playback_mode === "repeat"
}
AudioPlayerStorage.set("mode", mode)
return mode
} }
duration() { duration() {
@ -850,7 +859,7 @@ export default class Player extends Core {
toggleMute(to) { toggleMute(to) {
if (typeof to !== "boolean") { if (typeof to !== "boolean") {
to = !this.state.muted to = !this.state.muted
} }
return this.mute(to) return this.mute(to)