Monday, August 6, 2012

dont know wat hapen to my blog..... :(

Friday, September 30, 2011

Saturday, July 10, 2010

Flash Video Player Contd...

In AS3.0 custom FLV Player is Implemented by defining the NetConnection Object and passing null to its connect method. NetStream Object is created by passing in a reference to the aforementioned NetConnection object i.e.

  1. var nc:NetConnection=New NetConnection();
  2. nc.connect(null);
  3. var ns:NetStream=new NetStream(nc);
We can create an embedded video object using only code. e.g.

var vid:Video=new Video(320,240);
this.addChild(vid);


Once we have created the video object we now need to connect it to the NetStream object. In AS3.0 we do this by using a method called attachNetStream(). If you want to attach a webcam to the video object you would use the attachCamera() method. Once the NetStream is attached we can begin playing an external FLV the same as before by calling the NetStream.play() method. e.g.


vid.attachNetStream(ns);
ns.play("test.flv");


for responding the events from the NetStream class, First off, you have to provide a callback function for the on MetaData event or Flash will throw errors at you. You need to create an Object that will act as the NetStream's client for the callback event. Once you have setup the onMetaData function for this object you need to set the NetStream client property so it knows where to look. If your FLV contains embedded cue points then you will also need to create an onCuePoint function to handle that call back event.


var netClient:Object=new Object();
netClient.onMetaData=function(meta:Object)
{
   trace(meta.duration);
}
ns.client=netClient;


In order to recieve status messages we use the NetStream.addEventListener() method to define a listener functionto respond to this event. e.g.


ns.addEventListener(NetStatusEvent.NET_STATUS, netstat);


function netstat(stats:NetStatusEvent)
{
   trace(status.info.code);
}

Video Player In Flash

When you use the FLV file format as your distribution method for video content you have two options for serving the video over the Internet:

  1. Hyper Text Transfer Protocol (HTTP) and
  2. Real Time Messaging Protocol(RTMP).
You can use one or both protocols to serve video to your Internet audience.

HTTP is used for progressive video downloads.

RTMP is used for streaming videos.

Tuesday, July 6, 2010

URLStream Object

In some rare cases you will need to get access to the data that you are downloading before its done downloading. To do so, you use a URLStream object in place of a URLLoader.

URLVariables

In addition to loading XML or text files we can load URLVariables.

For loading URLVariables, we can set the property  of the URLLoader.dataFormat to "variable".

You can also use the URLVariables object to send data to a server with a URLRequest.
e.g.

var request:URLRequest=new URLRequest("http://script.php");
var urlVars:URLVariables=new URLVariables();
urlVars.name="josh";
urlVars.hometown="columbus";
request.data=urlVars;
var loader:URLLoader=new URLLoader(request);

Functionality of URLLoader Class

To get data from outside world into our swf we need "URLLoader" class.

The URLLoader takes a URLRequest Object and allows you to load information from that location or send and load information from that location. The URLLoader is an Event Dispatcher, so it uses events to notify any listeners

  • When it begins loading data.
  • If there's an error.
  • What the status of the http request is 
  • When there's any progress and finally
  • When its complete
Load Method is used for loading.