Symmetri Developer Blog

February 14, 2008

Weird security problems with SoundMixer.computeSpectrum()

Flash/Flex - By Shourov Bhattacharya

Ever tried to use SoundMixer.computeSpectrum() on a dynamically loaded audio file in AS3? I have run into some strange security problems. In my Flash CS3 IDE, it works fine the first time I run the movie, but then shutting down the movie and running it again throws a security exception “SecurityError: Error #2121: Security sandbox violation: SoundMixer.computeSpectrum: ... cannot access .” This is despite the fact that the Flash movie definitely has explicit access to the local filesystem, and there is no real violation of the sandbox model as far as I can see.

Running the same movie in the browser, I find that IE7 with Flash Player 9 runs everything fine, but Flash Player in Firefox throws the same error.

I haven’t yet found a solution, other than catching the exception and trying to do something intelligent at that point. In my case I am using the spectrum to animate an “equalizer” type waveform clip; if the computeSpectrum() call fails, I simply fake the waveform instead (it looks surprisingly good with random data).

There is also a (probably) related problem that does not allow two separate Flash movies within the same browser process to access sound files for manipulation simultaneously - this webpage suggests that we are probably looking at a Flash Player bug for an explanation of that one. I have a feeling what I am seeing is a bug as well …

2 Comments »

  1. I am having the same issue with computeSpectrum() and loading audio files all within the localTrusted security sandbox. Have you found a solution for this problem? I tried writing a crossdomain.xml file and still got the error. I also tried delaying calls to the method until well after the sounds were playing. Any advice would be greatly appreciated.

    Thanks

    Comment by Jeremy — October 12, 2008 @ 5:19 am

  2. I have run into the same problem. I was writing a simple streaming mp3 player and it seems to range from when the file begins downloading to once the file is buffered that the computeSpectrum likes to throw a fit. I simply restart the song. It’s good enough for me right now, but I wish I knew of a working solution for this.

    I hope you figure it out.

    Comment by Gerald P. — February 17, 2009 @ 1:34 am

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.

Get free blog up and running in minutes with Blogsome
Theme designed by Janis Joseph