Standard Flash Player ACTIONSCRIPT3 statement that plays a flash publish rtmp stream,
Netconnection--->netstream--->play--->attachnetstream
The project, however, has been in a state of stalling.
Later added a sentence
Nsplayer.buffertime = 0.1;
I don't even have a card.
The help document says:
The default value is 0.1 (One-tenth of a second). To determine the number of seconds currently in the buffer with the Bufferlength property.
Unlike actually, I tested nsplayer.buffertime = 0; it was a stutter, not a setup. This means that the default is 0 instead of 0.1.
All the code is as follows:
Package{import Flash.display.sprite;import Flash.display.stagealign;import Flash.display.stagescalemode;import Flash.events.event;import Flash.events.netstatusevent;import Flash.external.externalinterface;import Flash.media.camera;import Flash.media.video;import Flash.net.netconnection;import Flash.net.NetStream;import Flash.system.security;import Flash.ui.contextmenu;import Flash.utils.settimeout;import Flash.text.TextField; public class User extends sprite{private var nc:netconnection;private var nsplayer:netstream;private var vidplayer:video ;p rivate var cam:camera;private var flashvars:object;private var rtmpurl:string;private var screen_w:int=640;private var screen_h:int=;public function User () {if (!this.stage) {This.addeventlistener (Event.added_to_stage, This.system_on_add_to_stage);} else {this.system_on_add_to_stage (null);}} /** * System Event callback, when the this control added to stage. * The main function. */private function System_on_add_to_stage (evt:event): void {This.removeeVentlistener (Event.added_to_stage, this.system_on_add_to_stage); Trace ("[Jeffer] JS not ready, try later."); This.stage.align = Stagealign.top_left;this.stage.scalemode = Stagescalemode.no_scale;this.contextmenu = new ContextMenu (); This.contextMenu.hideBuiltInItems (); flashvars = This.root.loaderinfo.parameters;if (! Flashvars.hasownproperty ("id")) {//throw new Error ("must specifies the id");} This.rtmpurl = Flashvars.rtmpurl; Security.allowdomain ("*"); Security.allowinsecuredomain ("*"); Flash.utils.setTimeout (This.system_on_js_ready, 500);} /** * System Callack event, when JS ready, register callback for JS. * The actual main function. */private function System_on_js_ready (): void {if (!flash.external.externalinterface.available) {Trace ("[Jeffer] js Not ready, try later. "); Flash.utils.setTimeout (This.system_on_js_ready, +); return;} var Label:textfield = new TextField (); label.x = 20;label.y = 20;label.width = 400;label.text= "Pull-stream Address:" + (Rtmpurl==null? "": Rtmpurl); addChild (label); if (rtmpurl! = null){var tcpurl:string = rtmpurl.substr (0, Rtmpurl.lastindexof ("/")), NC = new Netconnection (); nc.client = {}; Nc.client.onBWDone = function (): void {};nc.addeventlistener (netstatusevent.net_status, onnetstatus); Nc.connect ( Tcpurl); Note the IP address of the server ... Otherwise it doesn't show up trace ("Output debug information.");}} Private Function Onnetstatus (event:netstatusevent): Void{trace (Event.info.code); if (Event.info.code = = " NetConnection.Connect.Success ") {Displayplaybackvideo ();}} Private Function Displayplaybackvideo (): Void{var streamname:string = This.rtmpUrl.substr (This.rtmpUrl.lastIndexOf (" /")), Streamname.replace ("/"," "); Nsplayer = new NetStream (NC); nsplayer.buffertime = 0;nsplayer.play (streamname); Vidplayer = new Video (Screen_w, screen_h); vidplayer.x = 0;vidplayer.y = 0;vidplayer.attachnetstream (nsPlayer); addChild (Vidplayer);}}}
NetStream playing rtmp live stream stutter