在一个以flash 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());
}
}
我很新,所以我无法让它工作。但它看起来和flash一样,只需要在seek刷新缓冲区后重新追加字节。这是我正在看的文章,希望能有所帮助。
https://forums.adobe.com/thread/646900?tstart=0