ealbinu

as3 VideoStream

Nov 17th, 2011
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. package utilidades {
  3.     import flash.display.Sprite;
  4.     import flash.media.Video;
  5.     import flash.net.NetConnection;
  6.     import flash.net.NetStream;
  7.     import flash.events.NetStatusEvent;
  8.     public class VideoStream extends Sprite {
  9.         public var videow:Video;
  10.         private var conexion:NetConnection;
  11.         public var flujo:NetStream;
  12.         private var datos:Object;
  13.         private var nombre:String;
  14.         private var inicio:Number;
  15.         public function VideoStream(videoname:String, valor:Number, Vwidth:uint, Vheight:uint ) {
  16.             nombre=videoname;
  17.             inicio=valor;
  18.             videow=new Video(Vwidth,Vheight);
  19.             addChild(videow);
  20.             conexion=new NetConnection  ;
  21.             conexion.connect(null);
  22.             flujo=new NetStream(conexion);
  23.             videow.attachNetStream(flujo);
  24.             datos=new Object  ;
  25.             datos.onMetaData=function(info:Object):void{};
  26.             datos.onCuePoint=function(info:Object):void{
  27.                 flujo.seek(inicio);
  28.             };
  29.             flujo.client=datos;
  30.             flujo.play(nombre);
  31.             flujo.addEventListener(NetStatusEvent.NET_STATUS, Estatus);
  32.         }
  33.         public function Estatus(e:NetStatusEvent):void {
  34.             if (e.info.code=="NetStream.Play.Stop") {
  35.                  
  36.                 /*
  37.                 //NOT LOOP
  38.                 flujo.pause();
  39.                 flujo.close();
  40.                 flujo=null;
  41.                 conexion.close();
  42.                 conexion=null;
  43.                 removeChild(videow);
  44.                 videow=null;
  45.                 */
  46.                
  47.                 // AUTO LOOP (fix papervision3D)
  48.                 flujo.seek(inicio);
  49.  
  50.             }
  51.             if (e.info.code=="NetStream.Play.Start") {
  52.                 flujo.seek(inicio);
  53.             }
  54.         }
  55.     }
  56. }
Add Comment
Please, Sign In to add comment