Flash swf to play PCM WAV files?
I am in need of a Flash swf that is capable of loading PCM WAV files via a url passed to it.
An example of the file can be found here: http://msdn.microsoft.com/en-us/library/ff512405.aspx
The swf does not need a visible interface, as it is meant for audio playing 开发者_JAVA技巧only and not user interaction.
The swf should have a simple javascript interface for page-level interactions. These include:
load(url): loads a PCM WAV file over the internet using the url that is passed through it. play(): Should play the PCM WAV file that was loaded stop(): Should stop playing the current file.
I can provide a sample audio file that matches the specifications if the developer is unable to obtain a url from the link posted above.
Flash does not natively support run-time playback of PCM encoded audio. This means that you'll need to parse the WAV container to get at the audio and feed it in (flash 10+).
http://www.kaourantin.net/2008/05/adobe-is-making-some-noise-part-3.html
Somewhat more significantly, you'll require crossdomain permission to be able to do so, because you need programmatic access the wave data.
Another option is to use some code I wrote a while back to bake the wave data into an in-memory swf, load it and extract a valid Sound object back out.
http://flashbrighton.org/?p=9
The article is quite old now, and the the silent-sound technique should be avoided, but you may be able to repurpose the code to do your bidding. Using this method will work with Flash 9+.
http://www.schillmania.com/projects/soundmanager2/
You can also use the HTML5 audio tag (however this does not use flash). See http://www.whatwg.org/ for some examples of that.
精彩评论