How can I embed a wav into as3/flash builder?
I have:
[Embed(source="assets/sounds/claps.wav")]
public var testSound:Class;
private var blahsound:Sound = Sound(new testSound());
But no luck...
You can't. Well, not directly.
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.
You either need to convert it to an mp3 before embedding it. Or embed it as a ByteArray, and then try to use SampleDataEvent.SAMPLE_DATA to fill the sound buffer manually with the bytes from the wav file, but you are going to have to do some finagling.
It's possible, but hacky. As #32bitkid said, FP doesn't directly support loading sound files other than mp3. The solution is to load the wav as a ByteArray, construct a SWF in memory (as using the Flash IDE, you can add wav files), then access the Sound object from this SWF.
Check out http://richapps.de/?p=97
You can try the open source library, as3wavsound (AWS). It supports embedding .wav files and playing them natively.
Related
I have about 125MB worth of video files that I need to play from an expansion file (OBB). The OBB file itself is in place and is successfully 'mounted' using a 3rd party native extension, so I can access the files using traditional methods, like the File class, the Loader class, etc.
I use the NetStream and NetConnection classes to play the video file, but the problem is that for the stream to play, the video file needs to be in the same folder as the SWF that is trying to play it (or a subfolder). This is also in the Adobe documentation:
Play a local file
In Flash Player and in AIR content outside the application security
sandbox, you can play local video files that are stored in the same
directory as the SWF file or in a subdirectory; however, you can't
navigate to a higher-level directory.
I tried to play the stream nevertheless, just out of curiosity, and it throws a StreamNotFound error (as it should, because the video file is not in the same folder/subfolder as the SWF). My hunch is that this is some security sandbox thing, and there's a way around it, but I can't find it.
Any help is appreciated.
Eventually I was able to play a video file from the mounted obb using the built-in as3 VideoPlayer class, which it seems is able to play video from any folder.
I'm generating a 44100hz dynamic audio stream in Flash using a flash.media.Sound object and the SAMPLE_DATA event. I'd like to be able to analyze the output instead of just listening to it.
What would be the most straightforward way of converting my Flash stream of float samples to an audio file, in a standard format that can be opened by an audio editor? Is there any audio format that would be particularly suitable for this?
If you don't want to listen to it, there's no need to use Sound or the Event.SAMPLE_DATA at all. Just create the numbers and store them in a ByteArray or other data structure.
Is there any audio format that would be particularly suitable for this?
A format that can be opened by your audio editor would be preferable.
Otherwise, this totally depends on what you want to do with the sound data.
What would be the most straightforward way of converting my Flash stream of float samples to an audio file, in a standard format that can be opened by an audio editor?
To use an existing library that encodes the data into the specified format.
tonfall supports "various audio formats Wav AIFF RAW PCM (no header) "Encoder/Decoder
WaveEncoder from Nicolas Bretin apparently encodes to WAV
Of course, if you know the specification, you can write your own encoder.
Is it possible to play locally saved flv file like mp3 using the Sound class in AS3?
Or in any case I have to use NetStream object and NetConnection.
you'll have to use NetStream anyway
however you'll need just netConnection.connect(null); before passing it to a NetStream constructor (like here but with local/relative path)
I have an mpg file which I want to convert to flv format, but I have a requirement that while converting the mpg file, I also have to simultaneously play the converted flv file in the flash cs3. How to do it? I am using cs3 and as3.
If you want to convert your files programmaticly then use ffmpeg. This is a commandline tool which can convert video files to nearly everything. You have to execute ffmpeg with the correct params and wait until the video is ready. This works only on serverside. Means the flash client loads up the video file to the server. There it gets converted. You can execute ffmpeg with any serverside language like php.
Sadly I have no idea if it is possible to watch the video while converting. I think not but maybe someone else knows more.
Well, i am recording the voice from heaphone and the sound data is stored in ByteArray at runtime, now can i stored as mp3 ??
i want to save as mp3 file on the client system.. For that, i think i have to use air application.. Am i right?
I found this link where someone used Alchemy to convert to MP3.