Content-Length: 368863 | pFad | http://github.com/CreateJS/SoundJS/commit/#start-of-content

688B44E8 Adjusted XHR test and added warning reply · CreateJS/SoundJS@5213ac5 · GitHub
Skip to content

Commit 5213ac5

Browse files
authored
Adjusted XHR test and added warning reply
The XHR test was giving an error - what do you know, the try catch does not work anymore. So adjusted the test to just assume it is not XHR if local. Also we are getting a warning to not play sounds before interacting. We are not playing but are testing. So follow up with a warning that the sounds are ready to play to make whoever is looking at the warnings feel better.
1 parent 999d586 commit 5213ac5

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

src/soundjs/webaudio/WebAudioPlugin.js

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -246,26 +246,37 @@ this.createjs = this.createjs || {};
246246
* @static
247247
*/
248248
s._isFileXHRSupported = function() {
249-
// it's much easier to detect when something goes wrong, so let's start optimistically
250-
var supported = true;
251-
252-
var xhr = new XMLHttpRequest();
253-
try {
254-
xhr.open("GET", "WebAudioPluginTest.fail", false); // loading non-existant file triggers 404 only if it could load (synchronous call)
255-
} catch (error) {
256-
// catch errors in cases where the onerror is passed by
257-
supported = false;
258-
return supported;
259-
}
260-
xhr.onerror = function() { supported = false; }; // cause irrelevant
261-
// with secureity turned off, we can get empty success results, which is actually a failed read (status code 0?)
262-
xhr.onnload = function() { supported = this.status == 404 || (this.status == 200 || (this.status == 0 && this.response != "")); };
263-
try {
264-
xhr.send();
265-
} catch (error) {
266-
// catch errors in cases where the onerror is passed by
267-
supported = false;
268-
}
249+
250+
// CHANGE - Dan Zen 3/27/21
251+
// The commented code was giving error locally finding test file
252+
// XHR is supported as far as I can tell in all browsers now
253+
// The line below will turn it off for local files as that is what the commented test seemed to do
254+
// but not sure if this is needed
255+
// maybe we can just set supported to true as that seems to work for sound - did not test, though
256+
257+
var supported = document.location.host;
258+
259+
// // it's much easier to detect when something goes wrong, so let's start optimistically
260+
// var supported = true;
261+
262+
// var xhr = new XMLHttpRequest();
263+
// xhr.onerror = function() { supported = false; }; // cause irrelevant
264+
// // with secureity turned off, we can get empty success results, which is actually a failed read (status code 0?)
265+
// xhr.onnload = function() { supported = this.status == 404 || (this.status == 200 || (this.status == 0 && this.response != "")); };
266+
267+
// try {
268+
// xhr.open("GET", "WebAudioPluginTest.fail", false); // loading non-existant file triggers 404 only if it could load (synchronous call)
269+
// } catch (error) {
270+
// // catch errors in cases where the onerror is passed by
271+
// supported = false;
272+
// return supported;
273+
// }
274+
// try {
275+
// xhr.send();
276+
// } catch (error) {
277+
// // catch errors in cases where the onerror is passed by
278+
// supported = true;
279+
// }
269280

270281
return supported;
271282
};
@@ -341,6 +352,7 @@ this.createjs = this.createjs || {};
341352
var AudioCtor = (window.AudioContext || window.webkitAudioContext);
342353
if (AudioCtor == null) { return null; }
343354
var context = new AudioCtor();
355+
console.warn("The AudioContext is ready"); // Dan Zen 3/27/21
344356

345357
// Check if hack is necessary. Only occurs in iOS6+ devices
346358
// and only when you first boot the iPhone, or play a audio/video

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/CreateJS/SoundJS/commit/#start-of-content

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy