TwelvestoneFlash

flash as3: custom client for netstream, anyone?


Sign in

  • Waiting for Godot ( 720 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 4.8 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.8 k posts )
    general front end design an...
  • Back End ( 9.6 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
derrickito
 
2010-01-22

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
 
2010-01-23

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
 
2010-01-23

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

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

flash as3: custom client for netstream, anyone?