9 Replies Latest reply on Mar 24, 2011 3:41 AM by ceikss

    osmf player stutters with rmtp stream

    punknrollDD Level 1

      Hi, my player stutters with an rtmp stream and stops for some strange reasons when the stream of the fms loads anothter video. I used the HelloWorld example from the svn and made one sample with pure as3 code where the streams runs forever and doesn't stutter.

       

      HelloWorld.as

       

      package
      {
          import flash.display.Sprite;
         
          import org.osmf.containers.MediaContainer;
          import org.osmf.elements.VideoElement;
          import org.osmf.media.MediaPlayer;
          import org.osmf.media.URLResource;

       

          /**
           * The simplest OSMF application possible.
           *
           * The metadata sets the SWF size to match that of the video.
           **/
          [SWF(width="640", height="352")]
          public class HelloWorld extends Sprite
          {
              public function HelloWorld()
              {
                  // Create the container class that displays the media.
                   var container:MediaContainer = new MediaContainer();
                  addChild(container);

       

                  // Create the resource to play.
              var resource:URLResource = new URLResource("rtmp://xxxxxx");
        
                 
                  // Create the MediaElement and add it to our container class.
                  var videoElement:VideoElement =  new VideoElement(resource);

       

                  container.addMediaElement(videoElement);
                 
                  // Set the MediaElement on a MediaPlayer.  Because autoPlay
                  // defaults to true, playback begins immediately.
                  var mediaPlayer:MediaPlayer = new MediaPlayer();
      mediaPlayer.bufferTime=5;
                  mediaPlayer.media = videoElement;
      mediaPlayer.bufferTime=5;

       

              }
          }
      }

       

      HelloWorldPlain.as

       

      package
      {
          import flash.display.Sprite;

       

          import flash.events.NetStatusEvent;
          import flash.net.Responder;
          import flash.net.NetConnection;
          import flash.net.NetStream;

       

          import flash.media.Video;
          import flash.events.AsyncErrorEvent;
         
          [SWF(width="640", height="352")]
              public class HelloWorldPlain extends Sprite
              {
                  public function HelloWorldPlain()
                  {
                      nc=new NetConnection();
                      nc.connect("rtmp://xxxx");
                      nc.addEventListener(NetStatusEvent.NET_STATUS, onNetConnectionStatusEvent);
                      video = new Video();
                      addChild(video);

       

                  }
                  private function onNetConnectionStatusEvent(stats:NetStatusEvent):void
                  {
                      switch (stats.info.code)
                      {
                          case "NetConnection.Connect.Success":
                              ns=new NetStream(nc);
                              nc.client=ns;
                              ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStreamNetStatusEvent);
                              ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                              ns.bufferTime=5;
                              ns.play('MyVid');
                              video.attachNetStream(ns);
                          break;
                      }
                  }
                  private function onNetStreamNetStatusEvent(stats:NetStatusEvent):void
                  {
                      trace('stats'+stats);       
                      for (var propName:String in stats.info) {
                          trace('onStatus '+propName+" = "+stats.info[propName]);
                      }
                      trace('stats_info_code'+stats.info.code);

       

                      if(stats.info.code=='NetStream.Play.Start')
                      {
                          trace('call sendMsg FROM Play');
                      }
                      if(stats.info.code=='NetStream.Buffer.Full')
                      {
                          trace('call sendMsg');
                      }
                      if(stats.info.code=='NetStream.Play.Stop')
                      {
                     
                      }
                  }
                  private function asyncErrorHandler(event:AsyncErrorEvent):void {
                      trace(event.text);
                  }
                  private var nc:NetConnection;
                  private var ns:NetStream;
                  private var ro:Responder;
                  private var video:Video;
              }
      }

       

      I cand send the real URLs for testing via Email.

       

      Thanx for your help!