Play flv locally - actionscript-3

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)

Related

AIR/Android - play video from mounted OBB/expansion file

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.

Exporting AS3 animation to FLV using AS3

Is it possible to export an animation consisting of AS3 etc etc into a FLV file type using AS3 Code to do it rather than using manual progression
File > Export etc etc
Thanks
Aiden
It is a long shot, but depending on the conditions (CPU power, resolution, memory) it could work.
You should be able to make a BitmapData for every frame in your movie using bitmapData.draw(displayObject);. Then store all those bitmaps in an array, and then encode to flv using some external library such as this one.
Here's a tutorial on how to convert a displayObject into a BitmapData.
If instead of using Flash Player you compile to Adobe Air for desktop, you could save the frames as files in the hard drive, and then encode the sequence using a multitude of programs (such as After Effects) to any video format you want.
You can look into this codebase, it may save you some time:
http://www.zeropointnine.com/blog/simpleflvwriteras-as3-class-to-create-flvs/
var myWriter:SimpleFlvWriter = SimpleFlvWriter.getInstance();
myWriter.createFile(myFile, 320,240, 30, 120);
myWriter.saveFrame( myBitmapData1 );
myWriter.saveFrame( myBitmapData2 );
myWriter.saveFrame( myBitmapData3 ); // ... etc.
myWriter.closeFile();

Converting Mpeg file to flv and simultaneously playing the converted file in flash cs3 using as3

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.

Embed a wav as3

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.

ActionScript: How read only part of local file?

How read only part of local file? So that not to load the whole file into memory.
If you are using AIR you can use the readBytes() method of the FileStream API to specify an offset of the file where you want to start reading.
For a SWF that is running in the browser, the only method in the Flash Player 10 is the load() method of the FileReference class and that one doesn't allow you to specify an offset.