3

Windows 7 で Adob​​e Media Server 5 (スターター) を起動して実行しています

サーバー上にHelloWorldアプリケーションがあり、それに接続するクライアント フラッシュ ファイルがあります。

このアプリケーションを変更して、サーバーに配置したビデオをストリーミングしたい

それを実現するために、以下に貼り付けたコードをいくつか書きました。重要なビットはnetConnectionHandler関数の下にあります。

NetStream私が今投稿したのは私にエラーStreamNotFoundを与えます

私のビデオへのパスは

C:\Program Files\Adobe\Adobe Media Server 5\applications\HelloWorld\sample.mp4

nc.connectサーバーパスはrtmp://localhost/HelloWorld

これを行うためにこれらの公式の指示に従っていますが、これを機能させることができません。

ns.play以下のようにすると、SteamNotFoundエラーが発生します。ただし、入力すると、次のようns.play("sample")になります。

ns event.info.code: NetStream.Play.Start
ReferenceError: Error #1069: Property onMetaData not found on flash.net.NetStream and there is no default value.

 package {
    import flash.display.MovieClip;
    import flash.net.Responder;
    import flash.net.NetConnection;
    import flash.events.NetStatusEvent;
    import flash.events.MouseEvent;
    import flash.net.URLRequest;
    import flash.net.URLLoader;
    import flash.events.Event;
    import flash.net.NetStream;
    import flash.media.Video;


    public class HelloWorld extends MovieClip {
         private var nc:NetConnection;
         private var myResponder:Responder = new Responder(onReply);
         private var server:String;



        public function HelloWorld(){
            textLbl.text = "";
            connectBtn.label = "Connect";
            connectBtn.addEventListener(MouseEvent.CLICK, connectHandler);
        }

        public function connectHandler(event:MouseEvent):void{
            if(connectBtn.label=="Connect") {
                var myLoader:URLLoader = new URLLoader();
                myLoader.load(new URLRequest("config.xml"));
                myLoader.addEventListener(Event.COMPLETE, function(e:Event):void{
                var serviceXML = new XML(e.target.data);                    
                trace("Connecting...");
                nc = new NetConnection();
                nc.addEventListener(NetStatusEvent.NET_STATUS,netConnectionHandler);
                //Connect to the server
                nc.connect(serviceXML.ServerPath.text());//Which is "rtmp://localhost/HelloWorld"

                //Call the server's client function 'serverHelloMsg' in HellowWorld.asc
                nc.call("serverHelloMsg",myResponder,"World");
                connectBtn.label="Disconnect";
                });

            }else{
                trace("Disconnecting...");
                //Close the connection.
                nc.close();
                connectBtn.label = "Connect";
                textLbl.text = "";
            }
        }

        private function onReply(result:Object):void{
            trace("onReply recieved value: " + result);
            textLbl.text = String(result);
        }

        private function showXML(e:Event):void{
            XML.ignoreWhitespace=true;
            var config:XML = new XML(e.target.data);
            trace(config.serverpath.text());
            server = config.serverpath.text();

        }
        public function netStatusHandler(event:NetStatusEvent):void { 
            trace("ns connected is: " + nc.connected ); 
            trace("ns event.info.level: " + event.info.level); 
            trace("ns event.info.code: " + event.info.code); 
        }

        public function netConnectionHandler(event:NetStatusEvent):void { 
            trace("connected is: " + nc.connected ); 
            trace("event.info.level: " + event.info.level); 
            trace("event.info.code: " + event.info.code); 
            switch (event.info.code) 
            { 
                case "NetConnection.Connect.Success": 
                    var v:Video = new Video();
                    v.width=200;
                    v.height=200;
                    v.x=0;
                    v.y=0;
                    v.visible=true;
                    v.opaqueBackground=false;
                    stage.addChild(v);

                    var ns:NetStream = new NetStream(nc);
                    ns.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
                    v.attachNetStream(ns);
                    ns.play("rtmp://localhost/HelloWorld/sample.flv");

                    break; 
                case "NetConnection.Connect.Rejected": 
                    trace ("Oops! the connection was rejected"); 
                    // try to connect again 
                    break; 
                case "NetConnection.Connect.Failed": 
                    trace("The server may be down or unreachable"); 
                    // display a message for the user 
                    break; 
                case "NetConnection.Connect.Closed": 
                    trace("The connection was closed successfully - goodbye"); 
                    // display a reconnect button 
                    break; 
            } 
        }
    }


}

コンソール出力:

Connecting...
connected is: true
event.info.level: status
event.info.code: NetConnection.Connect.Success
onReply recieved value: Hello, World!
ns connected is: true
ns event.info.level: error
ns event.info.code: NetStream.Play.StreamNotFound
ns connected is: true
ns event.info.level: status
ns event.info.code: NetStream.Play.Stop
4

1 に答える 1

1

あなたの問題はおそらくあなたのURLのフォーマットです。

ns.play("rtmp://localhost/HelloWorld/media/sample.flv");

これにより、Adobe Media Server は、次の名前の HelloWorld アプリケーションのインスタンスをロードするように指示されますmedia 。Adobe メディア サーバーでは、接続時にメディアのパスを渡さないでください。渡されたメディアのストリーム フォルダーを検索します。Application.xml ファイル (またはメイン構成ファイル) を使用して、メディアを検索する他のディレクトリを追加することもできます。

これを機能させる最も簡単な方法は、メディア フォルダの名前を「streams」に変更することです。次に、次のように接続します。

ns.play("rtmp://localhost/HelloWorld/sample.flv");

.flv を省略しても問題なく動作するはずです。_definst_という名前のストリーム フォルダーにサブフォルダーを作成し、その中にメディアを配置する必要がある場合があります。

それでも機能しない場合は、Application.xmlに問題がある可能性があります。


アプリケーション ディレクトリに Application.xml ファイルを作成してみてください。以下を使用します。

<Application> 
    <StreamManager> 
        <VirtualDirectory> 
            <!-- Specifies application specific virtual directory mapping for recorded 
            streams.   --> 
            <Streams>/;C:\Program Files\Adobe\Adobe Media Server 5\applications\HelloWorld\</Streams> 
        </VirtualDirectory> 
    </StreamManager> 
</Application>
于 2013-07-05T16:23:55.933 に答える