Allows connections to RTMP servers

rtmpconnection allows applications to connect to RTMP servers, like http://osflash.org/red5 or http://www.wowzamedia.com/. Note that you'll need a server running with the appropriate URLs set up for this example to work.

<canvas> <rtmpconnection src="rtmp://localhost:1935/simplevideostreaming/" autoconnect="true"/> <videoplayer url="Extremists.flv" type="rtmp" autoplay="true" width="320" height="240"/> </canvas>
import flash.net.NetConnection; import flash.events.ErrorEvent; import flash.events.StatusEvent; import flash.events.IOErrorEvent; import flash.events.NetStatusEvent; import flash.events.SecurityErrorEvent; import flash.events.AsyncErrorEvent; ` id: ", id); } **/ } /** the following code should work now, but it hasn't been tested, so I'll leave it commented out -sa this._nc.__resolve = function(name) { //_root.Debug.write("__resolve " , name, typeof(this[name])); //_root.Debug.write(" arguments.callee.name " , // arguments.callee.name); if (typeof(this.t[name]) == "function") { this.t[name].apply(arguments); } }; **/ if (this.autoconnect) { this.connect(); } ]]> var errstr = error + ''; if ($debug) Debug.warn("rtmpconnection _onSecurityError() " + errstr); if (this.onerror.ready) { this.onerror.sendEvent(errstr); } //Debug.write("rtmpconnection.connect, stage", this.stage); if (this.stage > 0) { return; // already connected or connecting } var src = this._usealtsrc ? this.altsrc : this.src; if (src == 'null') src = null; if (this.debug) { if ($debug) Debug.write("initiating connection to ", src); } if ($debug) { if (src == "") { Debug.write("no src url defined for", this); return; } else if (typeof(src) != "string") { Debug.write("src", src, "must be a string in", this); return; } } this._connecturl = src; this._createconnection(); this._nc.connect(src,this.connParams); // I think the only option is to ethereal this.setAttribute("status", "connecting"); this.setAttribute("stage", 1); if (! this['_connectionTimeoutDel']) this._connectionTimeoutDel = new LzDelegate(this, '_handleConnectionTimeout'); lz.Timer.addTimer( this._connectionTimeoutDel, this.connectiontimeout ); if ($as3) evt = evt.info; var code = evt.code; // only used for debugging var description = evt['description'] ? evt.description : ""; //Debug.write(evt); //Debug.write("rtmpconnection", this, "_onStatus", code, description); if (this.debug) { if ($debug) Debug.write("rtmpconnection", this, "_onStatus", code); } var msg = ""; var s = this.stage; switch (code) { case "NetConnection.Connect.AppShutdown": { // The application has been shut down // (for example, if the application is out of memory // resources and must be shut down to prevent the // server from crashing) or the server has been shut down. msg = "disconnected (error)"; s = 0; break; } case "NetConnection.Connect.Closed": { // The connection was successfully closed. msg = "disconnected"; s = 0; break; } case "NetConnection.Connect.Failed": { // The connection attempt failed; // for example, the server is not running. msg = "connection failed"; s = 0; break; } case "NetConnection.Connect.Rejected": { // The client does not have permission to connect // to the application, or the application expected // different parameters from those that were passed, // or the application specifically rejected the client. msg = "connection rejected"; s = 0; break; } case "NetConnection.Connect.Success": { // The connection attempt succeeded. msg = "connected"; s = 2; break; } default: { msg = code; break; } } this.setAttribute("status", msg); this.setAttribute("stage", s); lz.Timer.removeTimer(this._connectionTimeoutDel); if (s == 2) { if (this.debug) { if ($debug) Debug.write("connected to " + this._connecturl); } if (this.onconnect.ready) { this.onconnect.sendEvent(); } } else if (msg != 'disconnected') { // disconnection isn't a failure. this._handleConnectionFailure(msg); } if (this.debug) { if ($debug) Debug.write("callMethod: func, obj, params", func, obj, params); } this._nc.call(func, obj, params);