chore: 基线 — 已发布壁纸现状原样入库(未做任何改动)
dist/ 为 Wallpaper Engine 网页壁纸「【崩坏:星穹铁道】昔涟」(workshopid 3604974793, version 2), 含两套预设 xilian / kv37,总计 105.1MB。本次提交不做任何修改,仅作为后续优化的对拍基线。
This commit is contained in:
commit
d8c7e492f7
35 files changed
+193916
No files matched your search
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
export default class AudioController {
|
||||
constructor(audioId, options = {}) {
|
||||
this.audio = document.getElementById(audioId);
|
||||
this.audio.src = options.source;
|
||||
this.audio.volume = options.volume;
|
||||
this.audio.loop = true;
|
||||
this.isPlaying = false;
|
||||
this.isChangingSource = false;
|
||||
this.previousSource = null;
|
||||
}
|
||||
play() {
|
||||
if (this.isPlaying) {
|
||||
return;
|
||||
}
|
||||
if (this.isChangingSource) {
|
||||
return;
|
||||
}
|
||||
if (this.audio) {
|
||||
setTimeout(() => {
|
||||
this.isPlaying = true;
|
||||
this.audio.play().catch((error) => {
|
||||
this.isPlaying = false;
|
||||
this.changeSource(this.previousSource);
|
||||
});
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
pause() {
|
||||
this.audio.pause();
|
||||
this.isPlaying = false;
|
||||
}
|
||||
changeSource(newSource) {
|
||||
if (this.isChangingSource) {
|
||||
return;
|
||||
}
|
||||
if (this.audio) {
|
||||
this.isChangingSource = true;
|
||||
this.pause();
|
||||
this.previousSource = this.audio.src;
|
||||
this.audio.src = newSource;
|
||||
this.isChangingSource = false;
|
||||
this.play();
|
||||
}
|
||||
}
|
||||
changeVolume(newVolume) {
|
||||
const clampedVolume = Math.max(0, Math.min(1, newVolume));
|
||||
this.audio.volume = clampedVolume;
|
||||
this.changeStateByVolume();
|
||||
}
|
||||
changeStateByVolume() {
|
||||
const currentVolume = this.audio.volume;
|
||||
if (currentVolume > 0 && !this.isPlaying) {
|
||||
this.play();
|
||||
} else if (currentVolume <= 0 && this.isPlaying) {
|
||||
this.pause();
|
||||
}
|
||||
}
|
||||
changeOptions(newOptions) {
|
||||
const newSource = newOptions.source;
|
||||
const newVolume = newOptions.volume;
|
||||
this.changeSource(newSource);
|
||||
this.changeVolume(newVolume);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user