2012-01-23 13 views
2

以下は、as3 flash.Aの簡単なビデオストリーミングの例で、rtmp red5を使用した場合の基本的なコードビットです。しかし、私はストリームに接続する際に問題が発生しているようです。私は、red5サーバーのデモインストールで与えられたのと同じビデオファイルを使用しています。(私は、適切に実行してoflaのインストール済みデモを確認しました) 私の出力トレースは、接続の成功とビデオファイルの再生開始を示します。しかし、私はそのメタデータを取得することができないか、実際に再生することはできません。as3 rtmp video stream on localhost red5 path issue

netStatusHandlerはNetConnection.Connect.Success

netStatusHandler NetStream.Play.Reset

netStatusHandler NetStream.Play.Start

私はパスを与えることに関してはここで何をしないのですビデオファイルに?これらはデフォルトのred5インストールに付属する同じデモサンプルフォルダにあります。

package 
{ 
    import flash.display.*; 
    import flash.events.*; 
    import flash.media.*; 
    import flash.net.* 



    public class NetConnectionExample extends MovieClip 
    { 
     private var videoURL:String = "rtmp://localhost/oflaDemo/streams"; 
     private var connection:NetConnection; 
     private var stream:NetStream; 
     public function NetConnectionExample() 
     { 
      // constructor code 
      connection = new NetConnection(); 
      connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); 
      connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); 
      connection.connect(videoURL, true); 
     } 
     private function netStatusHandler(event:NetStatusEvent):void 
     { 
      trace("netStatusHandler",event.info.code); 
      switch (event.info.code) 
      { 
       case "NetConnection.Connect.Success": 
        connectStream(); 
        break; 
       case "NetStream.Play.StreamNotFound": 
        trace("Stream not found: " + videoURL); 
        break; 
       case "NetStream.Play.Start": 
       break; 
      } 
     } 

     private function securityErrorHandler(event:SecurityErrorEvent):void 
     { 
      trace("securityErrorHandler: " + event); 
     } 

     private function connectStream():void 
     { 
      stream = new NetStream(this.connection); 
      stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); 
      stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler) 
      stream.client = new CustomClient(); 
      var video:Video = new Video(); 
      video.attachNetStream(stream); 
      stream.play(videoURL+"avatar.flv"); 
      addChild(video); 
     } 
     function asyncErrorHandler(event:AsyncErrorEvent):void { 
      // ignore AsyncErrorEvent events. 
     } 

    } 
} 

class CustomClient { 
public function onMetaData(info:Object):void 
{ 
    trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate); 
} 
public function onCuePoint(info:Object):void 
{ 
    trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type); 
} 
} 

編集: 関連 Where do I place a FLV file to stream on a local Red5 server?

+0

が不十分エンコードされたFLVのように私には聞こえ作品の映像はそのメタが正しく追加されていないメタデータがヘッダ –

+0

であることを確認します。私はこれがパスの問題であることを理解しました。 –

答えて

2

これは、パスの問題でした。 oflaDemoという名前のアプリケーションのrtmpビデオフォルダはストリームと呼ばれます。 ストリームを接続した後、その

private var videoURL:String = "rtmp://localhost/oflaDemo"; 

と直接ファイル名のようなパスを与えます。

stream.play("avatar.flv");