0 Replies Latest reply on Jun 15, 2010 5:27 AM by r.saran

    how to use multiple video files??

    r.saran

      hi all,

       

      i am using flex 4 ...

      now i have designed video player..

      i used single flv file for execution..

       

      how to use more flv files in tis program???

       

      i have included program also..

       

      can any one reply for this...

       

      thanks in advance...

       

       

      regards,

      saran r

       

       

       

       

      video.mxml:

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()" height="700" >
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
         
          <fx:Script>
              <![CDATA[
                  import mx.core.UIComponent;
                  import flash.events.NetStatusEvent;
                  import flash.media.Video;
                  import flash.net.NetConnection;
                  import flash.net.NetStream;
                  private var nc:NetConnection;
                  private var stream:NetStream;
                  public var videoDuration:Number;
                  public var nsClient:Object = new Object();
                  private var videoComp:Video = new Video();
                  private var meta:Object = new Object();
                  private var timer:Timer = new Timer(100);
                  private var uiComp:UIComponent = new UIComponent();
                  private function init():void
                  {
                      nc = new NetConnection();
                      nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                      nc.connect("rtmp://localhost/saran");                 
                      this.addElement(uiComp);
                      uiComp.addChild(videoComp);
                      timer.addEventListener(TimerEvent.TIMER,timerHandler);
                      timer.start();
                  }
                  private function netStatusHandler(event:NetStatusEvent):void
                  {
                      trace("Code ===>>>    "+event.info.code);
                      if(event.info.code == "NetConnection.Connect.Success")
                          connectStream(nc);
                  }
                  private function connectStream(nc:NetConnection):void {
                      stream = new NetStream(nc);
                      videoComp.attachNetStream(stream);
                      stream.play("Terminator")
                      // stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
                      stream.client = nsClient//new CustomClient();
                      nsClient.onMetaData = metadataHandler;
                      trace("stream ===>>>    "+stream.currentFPS);
                      //responder = new Responder(onResult);
                      // nc.call("getStreamLength", responder, "bikes" );
                  }
                  private function metadataHandler(metadataObj:Object):void
                  {
                      meta = metadataObj;
                      videoComp.width = metadataObj.width;
                      videoComp.height = metadataObj.height;
                      //positionBar.move(videoComp.x, ((videoComp.y + videoComp.height)+20));
                      //positionBar.width = videoComp.width;
                      trace("Duration ====>>>>   "+meta.duration);
                  }
                  private function timerHandler(event:TimerEvent):void
                  {
                      //trace("Timer called.........."+stream.time);
                      //positionBar.setProgress(stream.time, meta.duration);
                  }
                 
              ]]>
          </fx:Script>
         
      </s:Application>