2 Replies Latest reply on Feb 15, 2007 8:31 PM by rica_help

    RTMP and AS3

    rica_help Level 1
      I'm trying to stream an flv from FMS using AS3. I found AS3 code on the Flex site, but it throws the following errors on trace:

      Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback onBWDone. error=ReferenceError: Error #1069: Property onBWDone not found on flash.net.NetConnection and there is no default value.
      at VideoTest$iinit()
      metadata: duration=570.2330000000001 width=796 height=536 framerate=30

      Can someone please help me fix the above? I've been everywhere pretty much but no go. I also posted the question on the FMS forum and would gladly delete it from there if I can please get an answer here.

      Thanks

      =================================



      package {
      import flash.display.Sprite;
      import flash.events.NetStatusEvent;
      import flash.events.SecurityErrorEvent;
      import flash.media.Video;
      import flash.net.NetConnection;
      import flash.net.NetStream;
      import flash.events.Event;
      import flash.net.ObjectEncoding;

      public class VideoTest extends Sprite{
      private var videoURL:String = "1";
      private var connection:NetConnection;
      private var stream:NetStream;

      public function VideoTest():void {
      ////NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
      connection = new NetConnection();
      connection.objectEncoding = flash.net.ObjectEncoding.AMF0;
      connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
      connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
      connection.connect("rtmp://.../videosource/");
      }



      private function netStatusHandler(event:NetStatusEvent):void
      {
      switch (event.info.code)
      {
      case "NetConnection.Connect.Success":
      connectStream();
      break;
      case "NetStream.Play.StreamNotFound":
      trace("Stream not found: " + videoURL);
      break;
      }
      }

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

      private function connectStream():void
      {
      var stream:NetStream = new NetStream(connection);
      stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
      stream.client = new CustomClient();
      var video:Video = new Video();
      video.attachNetStream(stream);
      stream.play(videoURL);
      addChild(video);
      }
      }
      }

      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);
      }
      }
        • 1. Re: RTMP and AS3
          TheOutlander
          Did you find a solution yet??? This is the code from the books ... what folder are you running this from???
          • 2. RTMP and AS3
            rica_help Level 1
            Nope. I have not found a solution to this problem yet. I posted a querry in FMS and did receive a reply there but have not had the chance to try it yet.

            There are errors in all of th AS3 stuff I've tried. Actionscript 3.0 Cookbook from O'Reiley needs a big overhaul. So does the Lynda version. Even the Flex 2 things from Total Training have unresolved errors in them. Other people are complaining about the same things elsewhere, so I know I'm not alone on this one.

            If you find a solution, please do post it here. Would be nice if an Adobe Ace would come to the rescue on this video player issue.

            BTW, here is what was suggested by Nerdabilly from the FMS forum. Don't know if it will work.
            ==========================================
            Try putting an onBWdone handler into the custom client:

            public function onBWDone(info:Object):void{
            }