使用Haxe寻求嵌入式FLV

时间:2014-10-29 10:05:35

标签: flash bytearray haxe netstream

在以{10}为目标的Haxe项目中,我想寻求嵌入式FLV。我尝试使用NetStream类和appendBytes方法执行此操作,但我发现此方法无法工作,因为seek方法在调用时刷新缓冲区。有没有办法实现这一目标:嵌入式flv中寻找

package;

import flash.utils.ByteArray;
import flash.display.Sprite;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.events.NetStatusEvent;
import flash.events.Event;


// Embedding the video in the SWF here
@:file("Assets/v1.flv") class Vid1 extends  ByteArray {}

class TestProject extends Sprite {

    public var vid:Video;
    public var nc:NetConnection;
    public var ns:NetStream;

    public function new()
    { 
        super();
        addEventListener(Event.ADDED_TO_STAGE, mainSWFLoaded);
    }

    public function playVideo():Void
    {
        vid = new Video();

        nc = new NetConnection();
        nc.addEventListener(NetStatusEvent.NET_STATUS, onConnect);
        nc.connect(null);
    }

    public function onConnect(evt:NetStatusEvent):Void
    {
        if (evt.info.code == 'NetConnection.Connect.Success') {

            ns = new NetStream(nc);

            ns.client = {};
            ns.play(null);

            ns.appendBytes(new Vid1()); 
            vid.attachNetStream(ns);

            // With this line commented, the video plays until the end
            // but if I uncomment it, it will flush the buffer 
            // and the video won't play...
            // ns.seek(3);

            flash.Lib.current.addChild(vid);
        }
    }

    public function mainSWFLoaded(evt:Event):Void 
    {
        playVideo();
    }

    public static function main () 
    {
        flash.Lib.current.addChild(new TestProject());
    }

}

1 个答案:

答案 0 :(得分:1)

我很新,所以我无法让它发挥作用。但它看起来像flash一样,你必须在搜索刷新缓冲区后重新附加字节。这是我正在看的文章,希望这有帮助。

https://forums.adobe.com/thread/646900?tstart=0