1

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

ketan
  • 19,129
  • 42
  • 60
  • 98
shefali
  • 85
  • 1
  • 9
  • Never seen "attachVideo" method before. Are you trying to create some kind of live webcam sharing app? If you're just trying to stream video you can accomplish this without attachVideo. – Code Whisperer Sep 20 '13 at 13:30
  • no, i am not trying to attach cam , i want to play .mp4 video from my local machine and stream it p2p to other person. – shefali Sep 20 '13 at 14:51
  • attachVideo method http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001694.html but it can't be used in actionscript 3 – shefali Sep 20 '13 at 14:59
  • There's your answer, fishbulb. – Code Whisperer Sep 20 '13 at 17:38
  • i am able to play video but i want to stream it to other person using adobe cirrus.. and we can't use attachVideo in actionscript 3.0 – shefali Sep 20 '13 at 18:11
  • I think you want to use the `attachNetStream()` method of the `Video` object, as shown [here in the documentation](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Video.html#attachNetStream()). – Sunil D. Sep 24 '13 at 23:25
  • when i use streamOut.attachNetStream(ns); in above code (in as3) it gives error 1061: Call to a possibly undefined method attachNetStream through a reference with static type flash.net:NetStream. I doubt if we can join two NetStream !! – shefali Sep 25 '13 at 07:50

1 Answers1

0

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){

}
anixrud
  • 184
  • 3
  • 11
  • this code will play t.mp4 in swf/browser , i am able to do that but what i am asking is i want to stream this video to other peer using cirrus, so i want to attach this video to streamOut (NetStream to cirrus) in actionScript 3, so i ll have to use like streamOut.attachNetStream(ns); but u cant attach two netStreams i guess... so is there any other way? – shefali Sep 25 '13 at 10:03