简体   繁体   中英

streaming video player / attaching video(not camera) to NetStream in actionscript 3

I am new to actionscript, basically i am trying to stream video player but we can't use attachVideo in as3 so what can i use instead of attachVideo in following code? Im using flash builder/flex 4.6 . If you could suggest link/tutorial for streaming video player it would be great help. Thank you!

   private function initOutStream():void
            {     /* streamOut is NetStream to adobe cirrus , 
                    conn is making connection to adobe cirrus */    
          trace("initOutStream");
          streamOut = new NetStream(conn,NetStream.DIRECT_CONNECTIONS);
          streamOut.addEventListener(NetStatusEvent.NET_STATUS,streamStatus);
          streamOut.publish("media");

                  // mp4 file from local machine

                  nc = new NetConnection();                           
                  nc.connect(null); 
                  ns = new NetStream(nc);
                  ns.play("t.mp4");
                  ns.client = this;

                  var vid:Video = new Video;
                  vid.attachNetStream(ns);

          // streaming vid to media server

                  streamOut.attachVideo(vid);

         var streamOutClient:Object = new Object(); 
         streamOutClient.onPeerConnect = function(farStream:NetStream):Boolean
                   {   
                     return true;         
                   }       
              }

error: 1061: Call to a possibly undefined method attachVideo through a reference with static type

This is a code i wrote lately for a business job. i hope it helps...

var vid:Video = new Video();
vid.width = 640; vid.height = 480;
addChild(vid);

var cnn:NetConnection = new NetConnection();
cnn.connect(null);

var ns:NetStream = new NetStream(cnn);

ns.play("t.mp4");

vid.attachNetStream(ns);

ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, error);
ns.addEventListener(NetStatusEvent.NET_STATUS, streamStatus);

function streamStatus(e:NetStatusEvent){
    //trace(e.info.code);
    if(e.info.code == "NetStream.Play.Stop"){

    }
}

function error(e){

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM