简体   繁体   English

流视频播放器/在动作脚本3中将视频(非摄像机)附加到NetStream

[英]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? 我是ActionScript的新手,基本上我是在尝试流式视频播放器,但是我们不能在as3中使用attachVideo,所以在下面的代码中我可以用什么代替attachVideo? Im using flash builder/flex 4.6 . 我正在使用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 错误:1061:通过静态类型的引用调用可能未定义的方法attachVideo

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

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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