Posted By

SmpleJohn on 01/12/09


Tagged

flash flv video netconnection netstream


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

SmpleJohn
KDR
iamgowan
motionmediasolutions
estevancarlos
dubogii
arnsoares


Flash NetConnection


 / Published in: ActionScript 3
 

  1. var video:Video = new Video(VIDEOWIDTH, VIDEOHEIGHT);
  2. addChild(video);
  3.  
  4. var nc:NetConnection = new NetConnection();
  5. nc.connect(null);
  6.  
  7. var ns:NetStream = new NetStream(nc);
  8. ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);
  9.  
  10. function onStatusEvent(stat:Object):void
  11. {
  12. trace(stat.info.code);
  13. }
  14.  
  15. var meta:Object = new Object();
  16. meta.onMetaData = function(meta:Object)
  17. {
  18. trace(meta.duration);
  19. }
  20.  
  21. ns.client = meta;
  22.  
  23. video.attachNetStream(ns);
  24.  
  25. ns.play("yoursource.flv");

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: asuser on August 25, 2009

Nice and simple, thanks. For something more in-depth. this code snippet handles NetConnection errors: http://help.adobe.com/enUS/AS3LCR/Flash10.0/flash/net/NetConnection.html

Posted By: asuser on August 25, 2009

Here's the link.

Posted By: MaRmAR on March 29, 2011

I would add also: meta.onBWDone = function():void {}

You need to login to post a comment.