views:

917

answers:

3

The Flash IDE is capable of embedding many types of uncompressed sound files, including wav, and offers optional compression when publishing.

However, the [Embed] tag, only seems to allow embedding of mp3 files. Is it truly impossible to embed an uncompressed wav file, or am I missing some magic, undocumented mimeType?

I was hoping for something like:

[Embed source="../../audio/wibble.wav" mimeType="audio/wav"]

...but I get

no transcoder registered for mimeType 'audio/wav'

It's possible to embed wav or other format as an octet-stream and parse at runtime, but that's pretty heavy handed I think.

I'm surprised that even though the Flash IDE can embed uncompressed sound data, [Embed] cannot, given that the swf spec can contain uncompressed sound data.

Any takers?

A: 

The Flash player doesn't know how to directly play wav files. It's true that you can import them to the authoring tool, but when you publish the SWF your audio will be converted to mp3 or adpcm or whatever you select in your publish settings. Even if you read in a wav at runtime, the only way to play it is by parsing the binary stream, so naturally the same limitation applies if you embed the file.

Some related info at this question. Which curiously you seem to have commented on last year! :)

fenomas
Small world, huh? Well, you're right about wavs being encoded no matter what you do, but I guess what frustrates me is that you can't have an as3 app embed RAW sound data (or indeed anything except mp3), and play it using Flash's "native" sound player (ie, not using the SAMPLE_DATA event). Dig?
aaaidan
+1  A: 

From the LiveDocs - Basics of working with sound:

[...] Although there are various sound file formats used to encode digital audio, ActionScript 3.0, Flash Player and AIR support sound files that are stored in the mp3 format. They cannot directly load or play sound files in other formats like WAV or AIFF. [...]

But apparently there's a workaround. Check post #3 in this thread from actionscript.org:

Replying to myself in case anyone has the same question in the future and is searching for an answer.

I couldn't find any direct support for embedding WAV files in a Flex Builder 3 / ActionScript 3 application. What I did try and was delighted to see it works is to create a Flash Movie in Flash CS 3 (you will need to own that or get an evaluation) and import your sounds to the library and link them to be exported by ActionScript. Export the Flash CS3 project to a SWF movie and save it in your project (I added it to a "lib folder").

Your ActionScript code to create and play the sound should be:

[Embed(source="lib/Sounds.swf", symbol="BigShipSound")]
private static var BigShipSound: Class;
...
var bigShipSound : Sound = BigShipSound as Sound;
bigShipSound.play(0, 20);
Baelnorn
Ah damn... well, although it's clearly a "no, you can't" that's about as good a solution as I'll get. Cheers Baelnorn!
aaaidan
A: 

Does it have to be Flash Pro CS3? I tried this with CS5 but the swf file doesn't play.

Can anyone give me a sample .fla file? Maybe I'm just doing it wrong on the file.

Naze Kimi