Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
591 views
in Technique[技术] by (71.8m points)

flash - Embedding binary video data in a swf file

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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);
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...