Forums: Flash:

 

flash as3: custom client for netstream, anyone?

first
 

derrickito flash as3: custom client for netstream, anyone?

I've got a feature-heavy video player for a client that needs to do pretty much EVERYTHING that flash video can do. Included in the to-do list is bandwidth sniffing for dynamic video switching, which I've managed to make happen using SimpleClient, a custom netstream client class that can pump out the the users bandwidth(see below). The problem with this client is that it didn't include an onMetaData function that can give me all the stats on the streaming flv.

In short, does anyone know how to add that functionality to the following .as file? Or, perhaps, does some have a netstream client that DOES have all the bells and whistles?

//SimpleClient.as

package com {
import com.BandwidthEvent;
import flash.events.EventDispatcher;
public class SimpleClient extends EventDispatcher {
public function SimpleClient() {

}
public function onBWCheck(... rest):Number {
return 0;
}
public function onBWDone(... rest):void {
var bitrate:Number;
bitrate = rest[0];
dispatchEvent(new BandwidthEvent(BandwidthEvent.BANDWIDTH_RECEIVED, bitrate));
}
}
}

//BandwidthEvent.as that is refered to above
package com {
import flash.events.Event;
public class BandwidthEvent extends Event {
static public var BANDWIDTH_RECEIVED:String = "bandwidthReceived";
public var bandwidth:int;
public function BandwidthEvent(type:String, thebandwidth:int, bubbles:Boolean=false, cancelable:Boolean=false) {
super(type, bubbles, cancelable);
bandwidth = thebandwidth;
}
}
}

 

lithium

Originally posted by: derrickito

//SimpleClient.as
package com {
import com.BandwidthEvent;
import flash.events.EventDispatcher;
public class SimpleClient extends EventDispatcher {
public function SimpleClient() {

}
public function onBWCheck(... rest):Number {
return 0;
}

public function onMetaData ( meta:Object ):void
{
for ( var i : String in meta )
{
trace ( i + " : " + meta[i] );
}
}


public function onBWDone(... rest):void {
var bitrate:Number;
bitrate = rest[0];
dispatchEvent(new BandwidthEvent(BandwidthEvent.BANDWIDTH_RECEIVED, bitrate));
}
}
}


You should also listen for an AsyncErrorEvent.ASYNC_ERROR on your netstream instance, to catch any unknown method invocations made by the service you're connecting to.



 

JLM

derrickito out of interest are you using FMS for switching or Red5?

 
first
 

Forums: Flash: flash as3: custom client for netstream, anyone?

 
New Post
 
You must be logged in to post