# NetStream.client && NetConnection.client

**URL:** <https://forum.kirupa.com/t/netstream-client-netconnection-client/329086>\
**Category:** flash\
**Created:** [July 18, 2012, 9:04pm UTC](https://forum.kirupa.com/t/netstream-client-netconnection-client/329086 "2012-07-18T21:04:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freddythunder](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@Freddythunder](https://forum.kirupa.com/u/Freddythunder)\
**Post date:** [July 18, 2012, 9:04pm UTC](https://forum.kirupa.com/t/netstream-client-netconnection-client/329086/1 "2012-07-18T21:04:29Z")

</div>

Hello Kirupians.

Question for curiosity as it is currently working as I want it to, but I don’t understand how I need to assign the client object to both the netstream & the netconnection to get my desired results… I’m making a video player in AS3 (actually a video player as part of a much larger Flash application). I’m not a fan of AS3 as things that should work simply don’t.

Here’s my code from the **package** :

```auto

public function playVideo():void
{
	var client:Object = new Object();
	client.onBWDone = function(e){ trace(e); }
	client.onMetaData = doMetaData;
	client.onCuePoint = function(e){ trace(e); }

	var myVideo:Video = new Video;
	addChild(myVideo);
	var nc:NetConnection = new NetConnection();
	nc.connect(null);
	var ns:NetStream = new NetStream(nc);
	ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorEventHandler);
	ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
	myVideo.attachNetStream(ns);
	nc.client = client;
	ns.client = client;
	ns.play("http://www.viewtry.com/ad_images/breathalyzer.mp4");
			
} 
		
public function doMetaData(infoObject:Object):void
{
	var key:String;
	for(key in infoObject){
		trace(key+": "+infoObject[key]);
	}
}
		
public function netStatusHandler(evt:NetStatusEvent):void
{
	trace(evt.info.code);
		if(evt.info.code == "NetStream.Play.Stop"){
			trace("your movie has stopped");
		}
	}
										
		
public function asyncErrorEventHandler(event:AsyncErrorEvent):void
{
	//ignore - brillant. Get a couple errors without this here.
}

```

I struggled for a while to get the metadata from the video that I’m pulling in… I was told that I could just use the n **c**.client to go back to the client object and have the onMetaData handler trace that out. But I never got any metadata - HOWEVER, the netStatusHandler will never read “NetStream.Play.Stop” unless I have that n **c**.client line in there - which I need to know when it stops.

Only one thing told me n **c**.client, all others were n **s**.client. When I simply changed it, I could see all my metadata from the function doMetaData - but then the “NetStream.Play.Stop” would not fire. I would still get the .Play.Start, .Buffer.Full, and .Buffer.Flush (which seems useless).

Only when I would put the two lines together (which makes no programming sense to me whatsoever:

```auto

nc.client = client;
ns.client = client;

```

will both things work correctly as it is now.  
What gives?
