2014-08-28 65 views
0

我不知道爲什麼我收到以下錯誤。你能否建議在我的舞臺上成功播放rtmp流所需的代碼中有什麼變化? 錯誤:錯誤#2044:未處理的NetStatusEvent

NetConnection.Connect.Success Error #2044: Unhandled NetStatusEvent:. level=error, code=NetStream.Play.StreamNotFound at main/attachnetstream()[/Users/user/Desktop/ojotha/main.as:24] Debug session terminated.

package { 
    import flash.display.MovieClip; 
    import flash.net.*; 
    import flash.events.NetStatusEvent; 
    import flash.media.Video; 

    public class main extends MovieClip { 
    public var streamserver:String="rtmp://216.245.200.114/live"; 
    public var streamname:String="shomoy"; 
    public var netconnection:NetConnection=new NetConnection(); 

     public function main() { 
      netconnection.connect(streamserver); 
      netconnection.addEventListener(NetStatusEvent.NET_STATUS, attachnetstream); 




     } 
     public function attachnetstream(event:NetStatusEvent):void{ 
      trace(event.info.code); 
      switch (event.info.code) { 
       case "NetConnection.Connect.Success": 
       var netstream:NetStream=new NetStream(netconnection); 
       var video:Video=new Video(); 
       video.attachNetStream(netstream); 
       netstream.play(streamname); 
       video.height=480; 
       video.width=640; 
       addChild(video); 

       break; 
       case "NetStream.Play.StreamNotFound": 
       trace("stream not found"); 
       break; 
      } 
       } 


      } 

    } 
+0

你嘗試'RTMP:// 216.245.200.114 /現場/'我的意思是結尾斜線,我有同樣的問題,前段時間,並且解決它 – 2014-08-28 21:30:40

+0

看到這也可以幫助http://stackoverflow.com/questions/24233131/dynamic-rtmp-streaming-with-jwplayer – 2014-08-28 21:37:05

+0

我已經嘗試過斜線,但結果相同: 錯誤#2044:未處理的NetStatusEvent :. level = error,code = NetStream.Play.StreamNotFound \t at main/attachnetstream()[/ Users/user/Desktop/ojotha/main.as:25] 調試會話終止。 – oyshee 2014-08-28 21:45:18

回答

-1

您應該添加NetStatusEvent事件偵聽器,您的流爲好。

stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); 

看那docs

您可能還需要設置另一個事件偵聽器,哪怕是空的,以防止一些其他的運行時錯誤。

stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); 
相關問題