mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-28 04:56:32 +08:00
音乐从某个时刻开始播放
This commit is contained in:
1 parent
77efd767ee
commit
d4c03cdaec
3 files changed
+22
-15
No files matched your search
@@ -11,7 +11,7 @@ class BgmController extends ResourceController<HTMLAudioElement> {
|
||||
*/
|
||||
add(uri: string, data: HTMLAudioElement) {
|
||||
if (this.list[uri]) {
|
||||
console.warn(`Repeated bgm: '${uri}'`);
|
||||
console.warn(`Repeated bgm: '${uri}'.`);
|
||||
}
|
||||
this.list[uri] = data;
|
||||
data.loop = true;
|
||||
@@ -21,8 +21,12 @@ class BgmController extends ResourceController<HTMLAudioElement> {
|
||||
* 切换bgm
|
||||
* @param id bgm的id
|
||||
*/
|
||||
play(id: BgmIds) {
|
||||
play(id: BgmIds, when: number = 0) {
|
||||
if (this.playing === id) return;
|
||||
this.stop();
|
||||
const bgm = this.get(id);
|
||||
bgm.currentTime = when;
|
||||
bgm.play();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user