|
483 | 483 | self._suspendTimer = null;
|
484 | 484 | self.state = 'suspending';
|
485 | 485 |
|
| 486 | + // Handle updating the state of the audio context after suspending. |
486 | 487 | var handleSuspension = function() {
|
487 | 488 | self.state = 'suspended';
|
488 | 489 |
|
|
492 | 493 | }
|
493 | 494 | };
|
494 | 495 |
|
495 |
| - // Either suspension is resolved or rejected (i.e. in case of interrupted state of audio context) |
496 |
| - // the Howler's 'suspending' state needs to be updated. |
| 496 | + // Either the state gets suspended or it is interrupted. |
| 497 | + // Either way, we need to update the state to suspended. |
497 | 498 | self.ctx.suspend().then(handleSuspension, handleSuspension);
|
498 | 499 | }, 30000);
|
499 | 500 |
|
|
583 | 584 | self._sprite = o.sprite || {};
|
584 | 585 | self._src = (typeof o.src !== 'string') ? o.src : [o.src];
|
585 | 586 | self._volume = o.volume !== undefined ? o.volume : 1;
|
586 |
| - self._xhrWithCredentials = o.xhrWithCredentials || false; |
587 |
| - self._xhrHeaders = o.xhrHeaders || null; |
| 587 | + self._xhr = { |
| 588 | + method: o.xhr && o.xhr.method ? o.xhr.method : 'GET', |
| 589 | + headers: o.xhr && o.xhr.headers ? o.xhr.headers : null, |
| 590 | + withCredentials: o.xhr && o.xhr.withCredentials ? o.xhr.withCredentials : false, |
| 591 | + }; |
588 | 592 |
|
589 | 593 | // Setup all other default properties.
|
590 | 594 | self._duration = 0;
|
|
2349 | 2353 | } else {
|
2350 | 2354 | // Load the buffer from the URL.
|
2351 | 2355 | var xhr = new XMLHttpRequest();
|
2352 |
| - xhr.open('GET', url, true); |
2353 |
| - xhr.withCredentials = self._xhrWithCredentials; |
| 2356 | + xhr.open(self._xhr.method, url, true); |
| 2357 | + xhr.withCredentials = self._xhr.withCredentials; |
2354 | 2358 | xhr.responseType = 'arraybuffer';
|
2355 | 2359 |
|
2356 | 2360 | // Apply any custom headers to the request.
|
2357 |
| - if (self._xhrHeaders) { |
2358 |
| - Object.keys(self._xhrHeaders).forEach(function(key) { |
2359 |
| - xhr.setRequestHeader(key, self._xhrHeaders[key]); |
| 2361 | + if (self._xhr.headers) { |
| 2362 | + Object.keys(self._xhr.headers).forEach(function(key) { |
| 2363 | + xhr.setRequestHeader(key, self._xhr.headers[key]); |
2360 | 2364 | });
|
2361 | 2365 | }
|
2362 | 2366 |
|
|
0 commit comments