I've been googling around to find out how you might do this and as it was SUCH a pain i thought i'd share
enjoy a MP3Streamer class package { import flash.display.*; import flash.events.*; import flash.external.*; import flash.media.*; import flash.net.*; /** * case study to create mp3 player with NetStream * using the akamai test mp3 streaming url * rtmp:// cp67126.edgefcs.net/ondemand/mediapm/ovp/content/test/video/nocc_small.mp3 * @author Allandt Bik-Elliott */ public class MP3Streamer extends Sprite { private var _nc : NetConnection; private var _ns : NetStream; private var _player : Video; /** * standard flashdevelop setup */ public function MP3Streamer():void { if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener(Event.ADDED_TO_STAGE, init); createConnection(); } /** * create the NetConnection and add the callback client, this gives us scope to create the NetStream in this class later */ private function createConnection():void { _nc = new NetConnection(); // this is super important although you could add it to an anonymous object, I prefer to do stuff in classes _nc.client = this; _nc.addEventListener(NetStatusEvent.NET_STATUS, handleStatusEvents); _nc.addEventListener(IOErrorEvent.IO_ERROR, handleErrors); _nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, handleErrors); _nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, handleErrors); // connect to the stream server / application _nc.connect("rtmp://cp67126.edgefcs.net/ondemand/"); } /** * callback function - this is needed and the NetConnection will error without it * it also gives us a convenient jumping off point to add the NetStream object */ public function onBWDone():void { _ns = new NetStream(_nc); // note the structure of this: 'mp3:' at the start and no file suffix at the end _ns.play("mp3:mediapm/ovp/content/test/video/nocc_small"); // add a player to output this stuff - you could add this in a view and pull the netstream from your model _player = new Video(); _player.attachNetStream(_ns); } /** * output errors * @param e */ private function handleErrors(e:Event):void { trace("Error: " + e); // output to javascript console if in browser if (ExternalInterface.available) ExternalInterface.call("console.log", e.toString()); } /** * this isn't necessary for this simple application but is worthwhile to see what the player is doing * @param e */ private function handleStatusEvents(e:NetStatusEvent):void { trace(e); for (var prop:String in e.info) { trace(prop + " is " + e.info[prop]); } } } } _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders