mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-27 03:53:07 +00:00
Merge pull request #899 from apasov/patch-3
fix: load base64 encoded sounds when baseUrl is not empty
This commit is contained in:
commit
a2a13dfe51
1 changed files with 4 additions and 0 deletions
|
@ -147,6 +147,10 @@ export class ToneAudioBuffers extends Tone {
|
||||||
onerror: (e: Error) => void = noOp,
|
onerror: (e: Error) => void = noOp,
|
||||||
): this {
|
): this {
|
||||||
if (isString(url)) {
|
if (isString(url)) {
|
||||||
|
// don't include the baseUrl if the url is a base64 encoded sound
|
||||||
|
if (this.baseUrl && url.trim().substring(0, 11).toLowerCase() === "data:audio/") {
|
||||||
|
this.baseUrl = "";
|
||||||
|
}
|
||||||
this._buffers.set(name.toString(), new ToneAudioBuffer(this.baseUrl + url, callback, onerror));
|
this._buffers.set(name.toString(), new ToneAudioBuffer(this.baseUrl + url, callback, onerror));
|
||||||
} else {
|
} else {
|
||||||
this._buffers.set(name.toString(), new ToneAudioBuffer(url, callback, onerror));
|
this._buffers.set(name.toString(), new ToneAudioBuffer(url, callback, onerror));
|
||||||
|
|
Loading…
Reference in a new issue