Compare commits

...

2 Commits

Author SHA1 Message Date
f014befbbd feat: 获取音量大小接口 2025-01-20 18:30:50 +08:00
e32ffd2cc9 fix: 播放结束后Route的状态不对 2025-01-20 16:14:23 +08:00
4 changed files with 24 additions and 2 deletions

View File

@ -78,6 +78,13 @@ export class BgmController<
this.mainGain.setVolume(volume);
}
/**
*
*/
getVolume() {
return this.mainGain.getVolume();
}
/**
*
* @param enabled

View File

@ -376,6 +376,16 @@ export class AudioRoute
) {
super();
this.output = source.output;
source.on('end', () => {
if (this.status === AudioStatus.Playing) {
this.status = AudioStatus.Stoped;
}
});
source.on('play', () => {
if (this.status !== AudioStatus.Playing) {
this.status = AudioStatus.Playing;
}
});
}
/**

View File

@ -45,6 +45,13 @@ export class SoundPlayer<
this.gain.setVolume(volume);
}
/**
*
*/
getVolume() {
return this.gain.getVolume();
}
/**
*
* @param id

View File

@ -385,8 +385,6 @@ export class AudioStreamSource extends AudioSource implements IStreamReader {
this.createSourceNode(this.buffer);
this.output.start(0, when);
this.playing = true;
console.log(when);
this.output.addEventListener('ended', () => {
this.playing = false;
this.emit('end');