there's no problem unless you have a security sandbox issue. then you need cross-domain security permissions.
I appreciate your response, but I may not have explained the issue correctly.
If a firefox user of my website already had a youtube tab open, my sound visualisations do not play
The problem occurs on your site also:
start playing a youtube video
open (in a new tab) http://www.kglad.com/ and go to Snippets > Sound Display
But in other browsers it works fine. Should I go bug firefox about this ?
Is there something to do with the HTML or the way the flash is embedded and the way different browsers have their security settings ?
that's a security sandbox issue.
SecurityError: Error #2122: Security sandbox violation: SoundMixer.computeSpectrum: http://www.kglad.com/items/soundDisplay.swf cannot access http://v20.lscache7.c.youtube.com/videoplayback?ip=0.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbi ts%2Citag%2Calgorithm%2Cburst%2Cfactor%2Coc%3AU0dWSlRPTl9FSkNNNl9MSVJF&algorithm=throttle- factor&itag=34&ipbits=0&burst=40&sver=3&expire=1275440400&key=yt1&signature=9575A52A6C6E72 CD89E7319A92ACD27A0F21F75E.62EE16ACB17B0265B373AA1473136399BB89BF61&factor=1.25&id=8e8eaf1 e6de66468&. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.
thankyou for taking the time to test this.
Is my only option to write a try/catch loop for this error, and ask the user to close other tabs ?
Can I make a change in either the SWF/HTML/crossdomainpolicyXML to change this behaviour?
http://bugs.adobe.com/jira/browse/FP-499 seems to address the issue, but I believe it still to be a problem
Again, this only happens in Firefox. Im trying to work out who is at fault here.
1 person found this helpful
i don't know what you can do about it. this is an adobe/browser issue.
cross-domain policy file(s) won't be helpful. they would need to be on every cross-domain a user could have open when viewing your site while computespectrum is executing.
thanks kglad. appreciate your time.
for other people searching this issue I found some related information
if you use soundtransform you need it to be accessing files in the
right security sandbox. if you access it in a subdirectory to your
own site, it is in the right sandbox. However, if you have another
flash-app open in another firefox-tab, these two will confuse each
So i put my mp3 in the same folder as the swf, and the behaviour changed slightly.
If i open youtube first, then my swf in a new tab, problem is still there.
If I open my swf first and its playing and visualising, THEN open youtube my visualisations slow down a lot.
when i close the youtube tab, it goes back to playing at the normal framerate.
So it looks like firefox just wont do this.
Some other things i found related to the topic as follows:
Accessing sound data
The following sound-related ActionScript 3.0 APIs have security restrictions:
The SoundMixer.computeSpectrum() method—Always permitted for SWF files that are in the same security sandbox as the sound file. For files in other sandboxes, there are security checks.
The SoundMixer.stopAll() method—Always permitted for SWF files that are in the same security sandbox as the sound file. For files in other sandboxes, there are security checks.
The id3 property of the Sound class—Always permitted for SWF files that are in the same security sandbox as the sound file. For files in other sandboxes, there are security checks.
Every sound has two kinds of sandboxes associated with it—a content sandbox and an owner sandbox:
The origin domain for the sound determines the content sandbox, and this determines whether data can be extracted from the sound via the id3 property of the sound and the SoundMixer.computeSpectrum() method.
The object that started the sound playing determines the owner sandbox, and this determines whether the sound can be stopped using the SoundMixer.stopAll() method.
Calling the computeSpectrum() method requires that every sound that is playing be either from the same sandbox as the object calling the method or from a source that has granted permission to the caller's sandbox; otherwise, a SecurityError exception is thrown. For sounds that were loaded from embedded sounds in a library in a SWF file, permission is granted with a call to the Security.allowDomain() method in the loaded SWF file. For sounds loaded from sources other than SWF files (originating from loaded mp3 files or from video files), a URL policy file on the source server grants access to data in loaded media. You cannot use the computeSpectrum() method if a sound is loaded from RTMP streams.
I also notice the same issue reported in http://bugs.adobe.com/jira/browse/FP-147 Status: Internal Review
Throws a security error
Shouldn't throw an error
Workaround (if any):
Check for security error and randomise graphic equaliser
Or we can use the Sound.extract() in FP10
The AS3 Livedocs have an example of how to use the function:
Unfortunately, this only gets the raw sound data, not the spectrum data (like when you do computeSpectrum with fftFlag of true ). So if you want to get the spectrum data, you'll have to do the FFT manually in your code. This is a bit of a pain, but there's a ton of info if you google for FFT algorithms. Try:
there's a component on the web that's supposed to convert from sound data to spectrum data. i can't remember its name, though. i have it on my home computer (and am at my office now).
but i couldn't get it to work for me and ended up having to adapt fft code to convert my data for a project that was used to demonstrate hearing loss accros several band-widths.