News for hackers. Stuff that matters.

Ask HN: How to load a sound in JavaScript from external URL

Hi, can anyone help me, please? This code works fine:

var CrossfadeSample = function() { loadSounds(this, { drums: 'drums.wav', organ: 'organ.wav' }); this.isPlaying = false; }

But when I put the external URLs, it stops working:

var CrossfadeSample = function() { loadSounds(this, { drums: 'http://anothersite.com/sounds/drums.wav', organ: 'http://anothersite.com/sounds/organ.wav' }); this.isPlaying = false; }

Thank you.

( 3 comments | on HN )
Re:Ask HN: How to load a sound in JavaScript from external URL by thangngoc89 on Monday July 17, 2017 @12:43PM (#14790184)
It's because of CORS. But anyway, ask this on Stack Overflow
Re:Ask HN: How to load a sound in JavaScript from external URL by optikals on Monday July 17, 2017 @12:44PM (#14790192)
Thank you, Sir.
Re:Ask HN: How to load a sound in JavaScript from external URL by gargravarr on Monday July 17, 2017 @12:39PM (#14790130)
Sorry, you want StackOverflow for this.