Advertisement
nanyobis

NsExampleVideoSizeEqualsStageSize6.as

Aug 9th, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import flash.accessibility.Accessibility;
  4.     import flash.display.Sprite;
  5.     import flash.events.*;
  6.     import flash.net.NetConnection;
  7.     import flash.net.NetStream;
  8.     import flash.media.Video;
  9.  
  10.     public class NsExample extends Sprite
  11.     {
  12.         private var nc:NetConnection;
  13.         private var ns:NetStream;
  14.         private var video:Video;
  15.        
  16.         public function NsExample()
  17.         {
  18.             video = new Video();
  19.             addChild(video);   
  20.            
  21.             nc = new NetConnection();
  22.             nc.client=this;
  23.             nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
  24.             nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onError);
  25.             nc.connect('rtmp://live.7cast.net/live');
  26.         }
  27.  
  28.         private function startStreaming()
  29.         {
  30.             ns = new NetStream(nc);
  31.             ns.client = this;
  32.             ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
  33.             ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onError);
  34.             ns.play("ovaxh37k9yep18z");
  35.             video.attachNetStream(ns);
  36.         }
  37.        
  38.         private function onNetStatus(event:NetStatusEvent):void
  39.         {
  40.             switch(event.info.code)
  41.             {
  42.                 case 'NetConnection.Connect.Success':
  43.                 trace('NetConnection.Connect.Success');
  44.                 startStreaming();
  45.                 break;
  46.                
  47.                 default:
  48.                 trace(event.info.code);
  49.             }
  50.         }
  51.         private function onError(event:AsyncErrorEvent):void
  52.         {
  53.             trace(event);
  54.         }
  55.         public function onMetaData(data)
  56.         {
  57.             for(var i in data){ trace(i + " = " + data[i])}
  58.             trace(video.width, video.height,stage.stageWidth,stage.stageHeight);
  59.             video.scaleY = video.scaleX;
  60.             video.width = stage.stageWidth
  61.             trace(video.scaleX,video.width, video.scaleY, video.height)
  62.             video.x = (stage.stageWidth - video.width)/2;
  63.             video.y = (stage.stageHeight - video.height)/2;
  64.         }
  65.         public function onBWDone ()
  66.         {
  67.             trace("on Bandwidth Done ");
  68.         }
  69.     }
  70. }
  71.  
  72. output
  73.  
  74. NetConnection.Connect.Success
  75. NetStream.Play.Reset
  76. NetStream.Play.Start
  77. videokeyframe_frequency = 10
  78. author =
  79. description =
  80. rating =
  81. creationdate = Fri Aug 09 21:10:36 2013
  82.  
  83. width = 320
  84. presetname = Custom
  85. videocodecid = VP62
  86. videodevice = ManyCam Virtual Webcam
  87. audiocodecid = .mp3
  88. audiodatarate = 18
  89. audioinputvolume = 75
  90. copyright =
  91. title =
  92. videodatarate = 32
  93. framerate = 10
  94. audiosamplerate = 11025
  95. keywords =
  96. audiochannels = 1
  97. audiodevice = Microphone (Avnex Virtual Audio
  98. height = 180
  99. 320 240 640 480
  100. 2 640 1 240
  101.  
  102. note
  103.  
  104. 16:9 is stretched to width of the player but still 16:9.
  105. it is centered.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement