import flash.media.*; import flash.events.*; import flash.net.NetConnection; import flash.net.NetStream; import flash.utils.setTimeout; Allows video playback, live broadcast or recording .

mediastream allows applications to stream video from HTTP or RTMP servers. Classes like <videoview> use mediastreams to handle the connection to the server.

<canvas> <mediastream name="ms" autoplay="true" type="http" url="http://www.archive.org/download//JudgeMediaTestVideoFile_0/video.flv"/> <videoview type="http" autoplay="true" width="320" height="240" stream="canvas.ms"/> </canvas>
if (this._flashstream != null) { this._flashstream.play(false); this._flashstream.close(); this._flashstream = null; } //Debug.write("mediastream._handleAutoplay()"); if ((this.url == "") || (!this.autoplay)) { return; } this.play( this.autoplayStart, this.autoplayPause, this.autoplayLength, this.autoplayReset); //Debug.write("mediastream._activeTimeDel()", this); if (!this._timedel) { this._timedel = new LzDelegate(this, "_updateTime"); } this._timedel.unregisterAll(); this._timedel.register(lz.Idle, "onidle"); //Debug.write("mediastream._deactiveTimeDel()", this); if (this._timedel) { this._timedel.unregisterAll(); } 0)) { progress = bytesLoaded / bytesTotal; } break; } case "recording": { var time = ((new Date()).getTime() - this._basetime) / 1000; if (time != this.time) { this.setAttribute("time", time); } break; } default: { break; } } if (time != this.time) { this.setAttribute("time", time); } if (this.progress != progress) { this.setAttribute("progress", progress); } //Debug.write("_updateTime", this, "_flashstream", this._flashstream, "_pendingstreamname", _pendingstreamname); // Only update in playback mode. if (fps != this.fps) { this.setAttribute("fps", fps); } // Push totaltime up if time past end // (because we got the wrong totaltime somehow). if ((this.totaltime == 0) || isNaN(this.totaltime) || (this.totaltime < this.time)) { this.setAttribute("totaltime", this.time); } // Keep playing while we're recording, // or while we're playing, // or while we're still downloading. // (So the download progress bar updates while we pause playing.) if ((this.mode != "recording") && (this.mode != "playing") && (progress == 1.0)) { this._deactivateTimeDel(); } ]]> //Debug.write("pause", this, "p", p, "p == null", p == null, "this['paused']", this['paused']); var val = (p == null) ? !this['paused'] : p; if (val != this.paused) this.setAttribute("paused", val) //Debug.write("mediastream.close()"); //Debug.write("FLASHSTREAM CLOSE", this, this._flashstream); if (this._flashstream == null) { return; } this.stop(); if ($as2) { this._flashstream.attachVideo(null); } this._flashstream.attachAudio(null); this._flashstream.close(); this._flashstream = null; //this._flushnc() //Debug.write("mediastream._flushnc()"); if (this._nc == null) { return; } //Debug.write('_flushnc', this, this.type, this._nc); this._nc = null; //the following does not compile in swf9 since error is undefined //not sure where that used to come from //if ($debug) Debug.warn("mediastream _onSecurityError() " + error); this._nc.connect(this._srcurl,rtmp.connParams); //the following does not compile in swf9 since error is undefined //not sure where that used to come from //if ($debug) Debug.warn("mediastream _onAsyncError() " + error); //Debug.debug("_flashstreamSetup netstream=%w", netstream); this.setAttribute("_flashstream", netstream); //this._flashstream.setBufferTime(this.bufferTime); if ($as3) { this._flashstream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, this._onAsyncError); this._flashstream.addEventListener(NetStatusEvent.NET_STATUS, this._onNetStatusAS3); var attachPoint = {}; } else { var attachPoint = this._flashstream; } var _this = this; attachPoint.onStatus = function(info) { _this._onStatus(info); }; attachPoint.onCuePoint = function(info) { _this._onCuePoint(info); }; attachPoint.onPlayStatus = function(info) { _this._onPlayStatus(info); }; attachPoint.onMetaData = function(info) { _this._onMetaData(info); }; if ($as3) { this._flashstream.client = attachPoint; } //Debug.debug("_flashstreamSetup end"); //Debug.write("mediastream._onCuePoint()"); //Debug.write("ms onCuePoint", this, info); if (this.oncuepoint) { this.oncuepoint.sendEvent(info); } // TODO: should be conditionally compiled for debug // but I forget the syntax for that //Debug.write("mediastream._onstart()"); if (this.onstart) this.onstart.sendEvent(this); Debug.write("mediastream.oninsufficientbandwidth()"); if (this.oninsufficientbandwidth) { this.oninsufficientbandwidth.sendEvent(this); } this.cam = cam; if (this["oncam"]) this.oncam.sendEvent(); this.mic = mic; if (this["onmic"]) this.onmic.sendEvent(); this._flashstream.attachAudio(this.muteaudio ? false : this.mic._dev);