Is it possible to play video from data that has been embedded in a swf at compile time (with the [Embed]
metatag)?
The "Import Video->Embed" feature provided by Flash CS3 etc. is not acceptable because it has many severe limitations (including sound synchronization issues, a maximum number of frames, and other caveats)
I'm interested in being able to bundle flv video data in a swf (along with other assets), which will be played by an AIR application.
I don't think it can be done. Anyone disagree?
As long as your video is an FLV, then the answer is yes - you can use NetStream.appendBytes()
to play the embedded ByteArray
:
public class Main extends MovieClip
{
[Embed(source="sample.flv", mimeType="application/octet-stream")]
private var SampleVideo:Class;
public function Main():void
{
var video:Video = new Video(320, 240);
addChild(video);
var netConnection:NetConnection = new NetConnection();
netConnection.connect(null);
var netStream:NetStream = new NetStream(netConnection);
netStream.client = {};
video.attachNetStream(netStream);
var byteArray:ByteArray = new SampleVideo();
netStream.play(null);
netStream.appendBytes(byteArray);
}
}