Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Why doesn't it work in browser Chrome

Participant ,
Dec 09, 2018 Dec 09, 2018

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.

1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 10, 2018 Dec 10, 2018

then add your code to animate:

  1. var src = "fransk1.mp3"// set up our source 
  2. var soundInstance;      // the sound instance we create
  3. init();
  4. function init() { 
  5. createjs.Sound.on("fileload", handleLoad, this); // add an event listener for when load is completed 
  6. createjs.Sound.registerSound(src);  // register sound, which will preload automatically 
  7. function handleLoad(evt) { 
  8. startPlayback(); 
  9. function startPlayback(evt) { 
  10. if (soundInstance) { 
  11. return
  12. soundInstance = createjs.Sound.p
...
Translate
Community Expert ,
Dec 09, 2018 Dec 09, 2018

because there's no user interaction triggering the play. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 10, 2018 Dec 10, 2018

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 10, 2018 Dec 10, 2018

peor  wrote

i like listening to music with mp3 files in the Chrome browser.

Why, does it sound different from using a media player?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 10, 2018 Dec 10, 2018
LATEST

then add your code to animate:

  1. var src = "fransk1.mp3"// set up our source 
  2. var soundInstance;      // the sound instance we create
  3. init();
  4. function init() { 
  5. createjs.Sound.on("fileload", handleLoad, this); // add an event listener for when load is completed 
  6. createjs.Sound.registerSound(src);  // register sound, which will preload automatically 
  7. function handleLoad(evt) { 
  8. startPlayback(); 
  9. function startPlayback(evt) { 
  10. if (soundInstance) { 
  11. return
  12. soundInstance = createjs.Sound.play(src); 
  13. }
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines