Flash swf to play PCM WAV files?

2019-05-23 01:01发布

问题:

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 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.

回答1:

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+.



回答2:

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.



标签: flash wav