2014-10-29 43 views
0

在一個Haxe項目與閃光燈10作爲唯一的目標,我想尋找一個嵌入式FLV。我試圖用NetStream類和appendBytes方法來做到這一點,但我發現這種方法不能工作,因爲seek方法在調用時刷新緩衝區。有沒有什麼辦法可以達到這個目的:尋求嵌入式flv尋找與Haxe嵌入式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

我很新,所以我不能得到它的工作。但它看起來像閃光燈一樣,在查找刷新緩衝區後,您只需重新追加字節即可。這是我正在看的文章,希望這有助於。

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

+0

是的,我一定會有所幫助。謝謝! – JuCachalot 2014-11-10 11:55:40