Copy link to clipboard
Copied
This code works in browser Microsoft Edge but not in browser Chrome with version 71.0.3578.80
<!DOCTYPE html>
<html>
<head>
<script src="https://code.createjs.com/1.0.0/createjs.min.js"></script>
</head>
<body onload="init()">
<script>
var src = "fransk1.mp3"; // set up our source
var soundInstance; // the sound instance we create
function init() {
createjs.Sound.on("fileload", handleLoad, this); // add an event listener for when load is completed
createjs.Sound.registerSound(src); // register sound, which will preload automatically
}
function handleLoad(evt) {
startPlayback();
}
function startPlayback(evt) {
if (soundInstance) {
return;
}
soundInstance = createjs.Sound.play(src);
}
</script>
</body>
</html>
In console in Chrome show this
createjs.min.js:18 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
c._isFileXHRSupported @ createjs.min.js:18
createjs.min.js:18 Access to XMLHttpRequest at 'file:///C:/Users/%C3%84garen/Documents/HTML5%20canvas/SoundJS-1.0.0/SoundJS-1.0.0/examples/WebAudioPluginTest.fail' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
c._isFileXHRSupported @ createjs.min.js:18
createjs.min.js:18 Uncaught (in promise) DOMException
What is causing the sound to not work in Chrome with this link: https://p5js.org/examples/sound-preload-soundfile.html
will work the sound in Chrome and why is it so. It must have a different code set in order for it to work Chrome.
then add your code to animate:
Copy link to clipboard
Copied
because there's no user interaction triggering the play.
Copy link to clipboard
Copied
Okay but why does this link work https://p5js.org/examples/sound-preload-soundfile.html and not code.createjs.com They should fix that i like listening to music with mp3 files in the Chrome browser.
Copy link to clipboard
Copied
peor wrote
i like listening to music with mp3 files in the Chrome browser.
Why, does it sound different from using a media player?
Copy link to clipboard
Copied
then add your code to animate:
Find more inspiration, events, and resources on the new Adobe Community
Explore Now