加载进度事件

This commit is contained in:
AncTe committed 2023-06-17 17:25:55 +08:00
1 parent 754edac71a
commit 6eacff68d3
4 files changed
+45 -34

No files matched your search

+2 -1
View File
@@ -25,8 +25,8 @@ export class SoundEffect extends AudioPlayer {
}
set stereo(value: boolean) {
if (value !== this._stereo) this.initAudio(value);
this._stereo = value;
this.initAudio(value);
}
get stereo(): boolean {
return this._stereo;
@@ -55,6 +55,7 @@ export class SoundEffect extends AudioPlayer {
* 不启用立体声:source -> gain -> destination
* 启用立体声:source -> panner -> gain --> destination
* 单声道立体声:source -> merger -> panner -> gain -> destination
* 单声道立体声指音源为单声道,合成为双声道后模拟为立体声
* ```
* @param stereo 是否启用立体声
*/
+12 -2
View File
@@ -147,7 +147,12 @@ export class Resource<
) {
this.emit('loadstart');
this.request = axios
.get(data, { responseType: this.format })
.get(data, {
responseType: this.format,
onDownloadProgress: e => {
this.emit('progress', e);
}
})
.then(v => {
this.resource = v.data;
this.loaded = true;
@@ -157,7 +162,12 @@ export class Resource<
} else if (this.format === 'zip') {
this.emit('loadstart');
this.request = axios
.get(data, { responseType: 'arraybuffer' })
.get(data, {
responseType: 'arraybuffer',
onDownloadProgress: e => {
this.emit('progress', e);
}
})
.then(v => {
this.resource = new ZippedResource(v.data);
this.loaded = true;