因胸联盟 发表于 2015-1-15 20:57:44

来一发FLVPlayer组件辨认非flv后缀视频-Flash动画基本

用于设计和编辑Flash文档。1996年11月,美国Macromedia公司收购了FutureWave,并将其改名为Flash。后又被Adobe公司收购。
背景
人人必定碰着过这类成绩,在当地测试播放乐成的flv视频在服务器上没法播放,而且间接会见flv文件原告知找不到文件,这是由于IIS6的默许设置中并没有flv后缀的mime映照,以是会发生404找不到文件的毛病.一般的做法是修正IIS设置,增加flv的mime映照,成绩是办理了,但假如由于某些前提限定没法修正设置怎样办,第一个想到的是修正成让他能够被辨认的后缀名,惋惜的是自带的组件默许情形下其实不同意你那末做,不然会呈报毛病
player.contentPath="water.swf";//player是舞台中FLVPlayer组件实例名,这里我把后缀名改成swf,以即可以让IIS辨认
援用:
报错
1005:Invalidxml:URL:"water.swf"Norootnodefound;iffileisanflvitmusthave.flvextension
办理:利用自界说的NCManager替换默许的NCManager
判别flv后缀的代码在NCManager的connectToURL办法中,我修正了他的完成从而跳过了这个步骤
NCManager.as262行处
原:
代码拷贝框
if(parseResults.streamName.slice(-4).toLowerCase()==".flv"){varcanReuse:Boolean=canReuseOldConnection(parseResults);_isRTMP=false;_streamName=parseResults.streamName;return(canReuse||connectHTTP());}else{_smilMgr=newSMILManager(this);return_smilMgr.connectXML(parseResults.streamName);}

现:
代码拷贝框
varcanReuse:Boolean=canReuseOldConnection(parseResults);_isRTMP=false;_streamName=parseResults.streamName;return(canReuse||connectHTTP());

我修正代码跳过了这个判别,如许即便不是flv后缀一样可以播放,固然带来的反作用就是没法利用SMIL了.
最初我把修正了的代码另存成HttpConnectionManager.as,同时类名也改成HttpConnectionManager,放到fla地点目次中
代码拷贝框
//****************************************************************************//Copyright(C)2004-2005Macromedia,Inc.AllRightsReserved.//ThefollowingisSampleCodeandissubjecttoallrestrictionson//suchcodeascontainedintheEndUserLicenseAgreementaccompanying//thisproduct.//****************************************************************************importmx.video.*;/***<p>Creates<code>NetConnection</code>for<code>VideoPlayer</code>,a*helperclassforthatuserfacingclass.</p>**<p>NCManagersupportsasubsetofSMILtohandlemultiplestreams*formultiplebandwidths.NCManagerassumesanyURLthatdoesnot*beingwith"rtmp://"anddoesnotendwith".flv"isaSMILurl.*SeeSMILParserformoreonSMILsupport.</p>**@seeSMILParser*/classHttpConnectionManagerimplementsINCManager{//myVideoPlayerprivatevar_owner:VideoPlayer;//serverconnectioninfoprivatevar_contentPath:String;privatevar_protocol:String;privatevar_serverName:String;privatevar_portNumber:String;privatevar_wrappedURL:String;privatevar_appName:String;privatevar_streamName:String;privatevar_streamLength:Number;privatevar_streamWidth:Number;privatevar_streamHeight:Number;privatevar_streams:Array;privatevar_isRTMP:Boolean;privatevar_smilMgr:SMILManager;privatevar_bitrate:Number;/***<p>fallbackServerNameisexposedintwoways:</p>**<p>Usercansupplysecond<metabase>insmilandthatbase*attrwillbetakenasthefallbackServerName(notethatonly*theservernamewillbetakenfromthisandnottheapplication*nameoranythingelse).</p>**<p>Thesecondwayistheusercandirectlysetthisby*accessingthencMgrpropertyinFLVPlaybackorVideoPlayerand*setfallbackServerNamepropertydirectly.</p>*/publicvarfallbackServerName:String;//intervalforxntimeoutprivatevar_timeoutIntervalId:Number;privatevar_timeout:Number;/***Defaultconnectiontimeoutinmilliseconds.**@see#getTimeout()*@see#setTimeout()*/publicvarDEFAULT_TIMEOUT:Number=60000;//bandwidthdetectionstuffpublicvar_payload:Number;privatevar_autoSenseBW:Boolean;//infoonsuccessfulxnprivatevar_nc:NetConnection;privatevar_ncUri:String;//infoonmultxnswetrypublicvar_tryNC:Array;privatevar_tryNCIntervalId:Number;//ListofconnectionstriedbyconnectRTMP,inordertriedprivatestaticvarRTMP_CONN:Array=[{protocol:"rtmp:/",port:"1935"},{protocol:"rtmp:/",port:"443"},{protocol:"rtmpt:/",port:"80"},{protocol:"rtmps:/",port:"443"}];//CounterthattracksthenexttypetotryinRTMP_CONN.privatevar_connTypeCounter:Number;publicfunctionNCManager()        {initNCInfo();initOtherInfo();//intervals_timeoutIntervalId=0;_tryNCIntervalId=0;//actuallycallssetter_timeout=DEFAULT_TIMEOUT;}privatefunctioninitNCInfo():Void{_isRTMP=undefined;_serverName=undefined;_wrappedURL=undefined;_portNumber=undefined;_appName=undefined;}privatefunctioninitOtherInfo():Void{_contentPath=undefined;_streamName=undefined;_streamLength=undefined;_streamWidth=undefined;_streamHeight=undefined;_streams=undefined;_autoSenseBW=false;_payload=0;_connTypeCounter=0;cleanConns();}/**@seeINCManager#getTimeout()*/publicfunctiongetTimeout():Number{return_timeout;}/**@seeINCManager#setTimeout()*/publicfunctionsetTimeout(t:Number):Void{_timeout=t;if(_timeoutIntervalId!=0){clearInterval(_timeoutIntervalId);_timeoutIntervalId=setInterval(this,"_onFCSConnectTimeOut",_timeout);}}/***ForRTMPstreams,returnsvaluecalculatedfromautodetection,*notvaluesetviasetBitrate().**@seeINCManager#getBitrate()*/publicfunctiongetBitrate():Number{return_bitrate;}/***Thisvalueisonlyusedwithprogressivedownload(HTTP),with*RTMPstreamingusesautodetection.**@seeINCManager#getBitrate()*/publicfunctionsetBitrate(b:Number):Void{if(_isRTMP==undefined||!_isRTMP){_bitrate=b;}}/***@seeINCManager#getVideoPlayer()*/publicfunctiongetVideoPlayer():VideoPlayer{return_owner;}/***@seeINCManager#setVideoPlayer()*/publicfunctionsetVideoPlayer(v:VideoPlayer):Void{_owner=v;}/***@seeINCManager#getNetConnection()*/publicfunctiongetNetConnection():NetConnection{return_nc;}/***@seeINCManager#getStreamName()*/publicfunctiongetStreamName():String{return_streamName;}/***@seeINCManager#isRTMP()*/publicfunctionisRTMP():Boolean{return_isRTMP;}/***@seeINCManager#getStreamLength()*/publicfunctiongetStreamLength():Number{return_streamLength;}/***@seeINCManager#getStreamWidth()*/publicfunctiongetStreamWidth():Number{return_streamWidth;}/***@seeINCManager#getStreamHeight()*/publicfunctiongetStreamHeight():Number{return_streamHeight;}/***@seeINCManager#connectToURL()*/publicfunctionconnectToURL(url:String):Boolean{//ifdefDEBUG//debugTrace("connectToURL("+url+")");//endif//initinitOtherInfo();_contentPath=url;if(_contentPath==null||_contentPath==undefined||_contentPath==""){thrownewVideoError(VideoError.INVALID_CONTENT_PATH);}//parseURLtodeterminewhattodowithitvarparseResults:Object=parseURL(_contentPath);if(parseResults.streamName==undefined||parseResults.streamName==""){thrownewVideoError(VideoError.INVALID_CONTENT_PATH,url);}//connecttoeitherrtmporhttpordownloadandparsesmilif(parseResults.isRTMP){varcanReuse:Boolean=canReuseOldConnection(parseResults);_isRTMP=true;_protocol=parseResults.protocol;_streamName=parseResults.streamName;_serverName=parseResults.serverName;_wrappedURL=parseResults.wrappedURL;_portNumber=parseResults.portNumber;_appName=parseResults.appName;if(_appName==undefined||_appName==""||_streamName==undefined||_streamName==""){thrownewVideoError(VideoError.INVALID_CONTENT_PATH,url);}_autoSenseBW=(_streamName.indexOf(",")!=-1);return(canReuse||connectRTMP());}else{varcanReuse:Boolean=canReuseOldConnection(parseResults);_isRTMP=false;_streamName=parseResults.streamName;return(canReuse||connectHTTP());}}/***@seeINCManager#connectAgain()*/publicfunctionconnectAgain():Boolean{//ifdefDEBUG//debugTrace("connectAgain()");//endifvarslashIndex:Number=_appName.indexOf("/");if(slashIndex<0){//returntheappNameandstreamNamebacktooriginalform//sowecanstartthisprocessalloveragainwiththe//fallbackserverifnecessaryslashIndex=_streamName.indexOf("/");if(slashIndex>=0){_appName+="/";_appName+=_streamName.slice(0,slashIndex);_streamName=_streamName.slice(slashIndex+1);}returnfalse;}varnewStreamName=_appName.slice(slashIndex+1);newStreamName+="/";newStreamName+=_streamName;_streamName=newStreamName;_appName=_appName.slice(0,slashIndex);close();_payload=0;_connTypeCounter=0;cleanConns();connectRTMP();returntrue;}/***@seeINCManager#reconnect()*/publicfunctionreconnect():Void{//ifdefDEBUG//debugTrace("reconnect()");//endifif(!_isRTMP){thrownewError("Cannotcallreconnectonanhttpconnection");}_nc.onStatus=function(info:Object):Void{this.mc.reconnectOnStatus(this,info);};_nc.onBWDone=function():Void{this.mc.onReconnected();};//ifdefDEBUG//debugTrace("_ncUri="+_ncUri);//endif_nc.connect(_ncUri,false);}/***dispatchesreconnectevent,calledby*<code>NetConnection.onBWDone</code>**@private*/publicfunctiononReconnected():Void{delete_nc.onStatus;delete_nc.onBWDone;_owner.ncReconnected();}/***@seeINCManager#close*/publicfunctionclose():Void{if(_nc){_nc.close();}}/***Calledby<code>SMILManager</code>whendone.**@seeINCManager#helperDone()*/publicfunctionhelperDone(helper:Object,success:Boolean){if(helper!=_smilMgr)return;if(!success){_nc=undefined;_owner.ncConnected();delete_smilMgr;return;}//success!//grabwidthandheight_streamWidth=_smilMgr.width;_streamHeight=_smilMgr.height;//getcorrectstreamnamevarparseResults:Object;varurl:String=_smilMgr.baseURLAttr;if(url!=undefined&&url!=""){parseResults=parseURL(url);_isRTMP=parseResults.isRTMP;_streamName=parseResults.streamName;if(_isRTMP){_protocol=parseResults.protocol;_serverName=parseResults.serverName;_portNumber=parseResults.portNumber;_wrappedURL=parseResults.wrappedURL;_appName=parseResults.appName;if(_appName==undefined||_appName==""){thrownewVideoError(VideoError.INVALID_XML,"BaseRTMPURLmustincludeapplicationname:"+url);}if(_smilMgr.baseURLAttr.length>1){varparseResults:Object=parseURL(_smilMgr.baseURLAttr);if(parseResults.serverName!=undefined){fallbackServerName=parseResults.serverName;}}}}_streams=_smilMgr.videoTags;for(vari:Number=0;i<_streams.length;i++){url=_streams.src;parseResults=parseURL(url);if(_isRTMP==undefined){_isRTMP=parseResults.isRTMP;if(_isRTMP){_protocol=parseResults.protocol;if(_streams.length>1){thrownewVideoError(VideoError.INVALID_XML,"CannotswitchbetweenmultipleabsoluteRTMPURLs,mustusemetatagbaseattribute.");}_serverName=parseResults.serverName;_portNumber=parseResults.portNumber;_wrappedURL=parseResults.wrappedURL;_appName=parseResults.appName;if(_appName==undefined||_appName==""){thrownewVideoError(VideoError.INVALID_XML,"BaseRTMPURLmustincludeapplicationname:"+url);}}}elseif(_streamName!=undefined&&_streamName!=""&&!parseResults.isRelative&&_streams.length>1){thrownewVideoError(VideoError.INVALID_XML,"Whenusingmetatagbaseattribute,cannotuseabsoluteURLsforvideoorreftagsrcattributes.");}_streams.parseResults=parseResults;}_autoSenseBW=_streams.length>1;if(!_autoSenseBW){if(_streamName!=undefined){_streamName+=_streams.parseResults.streamName;}else{_streamName=_streams.parseResults.streamName;}_streamLength=_streams.dur;}if(_isRTMP){connectRTMP();}else{if(_autoSenseBW)bitrateMatch();connectHTTP();_owner.ncConnected();}}/***matchesbitratewithstream**@private*/privatefunctionbitrateMatch():Void{varwhichStream:Number;if(isNaN(_bitrate)){whichStream=0;}else{for(varj:Number=0;j<_streams.length;j++){if(isNaN(_streams.bitrate)||_bitrate<=_streams.bitrate){whichStream=j;break;}}}if(isNaN(whichStream)){thrownewVideoError(VideoError.NO_BITRATE_MATCH);}if(_streamName!=undefined){_streamName+=_streams.src;}else{_streamName=_streams.src;}_streamLength=_streams.dur;}/***<p>ParsesURLtodetermineifitishttporrtmp.Ifitisrtmp,*breaksitintopiecestoextractserverURLandport,application*nameandstreamname.If.flvisattheendofanrtmpURL,it*willbestrippedoff.</p>**@private*/privatefunctionparseURL(url:String):Object{//ifdefDEBUG//debugTrace("parseURL()");//endifvarparseResults=newObject();//getprotocolvarstartIndex:Number=0;varendIndex:Number=url.indexOf(":/",startIndex);if(endIndex>=0){endIndex+=2;parseResults.protocol=url.slice(startIndex,endIndex);parseResults.isRelative=false;}else{parseResults.isRelative=true;}if(parseResults.protocol!=undefined&&(parseResults.protocol=="rtmp:/"||parseResults.protocol=="rtmpt:/"||parseResults.protocol=="rtmps:/")){parseResults.isRTMP=true;startIndex=endIndex;if(url.charAt(startIndex)==/){startIndex++;//getserver(andmaybeport)varcolonIndex:Number=url.indexOf(":",startIndex);varslashIndex:Number=url.indexOf("/",startIndex);if(slashIndex<0){if(colonIndex<0){parseResults.serverName=url.slice(startIndex);}else{endIndex=colonIndex;parseResults.portNumber=url.slice(startIndex,endIndex);startIndex=endIndex+1;parseResults.serverName=url.slice(startIndex);}returnparseResults;}if(colonIndex>=0&&colonIndex<slashIndex){endIndex=colonIndex;parseResults.serverName=url.slice(startIndex,endIndex);startIndex=endIndex+1;endIndex=slashIndex;parseResults.portNumber=url.slice(startIndex,endIndex);}else{endIndex=slashIndex;parseResults.serverName=url.slice(startIndex,endIndex);}startIndex=endIndex+1;}//handlewrappedRTMPserversbitrecursively,ifitisthereif(url.charAt(startIndex)==?){varsubURL=url.slice(startIndex+1);varsubParseResults=parseURL(subURL);if(subParseResults.protocol==undefined||!subParseResults.isRTMP){thrownewVideoError(VideoError.INVALID_CONTENT_PATH,url);}parseResults.wrappedURL="?";parseResults.wrappedURL+=subParseResults.protocol;if(subParseResults.server!=undefined){parseResults.wrappedURL+="/";parseResults.wrappedURL+=subParseResults.server;}if(subParseResults.wrappedURL!=undefined){parseResults.wrappedURL+="/?";parseResults.wrappedURL+=subParseResults.wrappedURL;}parseResults.appName=subParseResults.appName;parseResults.streamName=subParseResults.streamName;returnparseResults;}//getapplicationnameendIndex=url.indexOf("/",startIndex);if(endIndex<0){parseResults.appName=url.slice(startIndex);returnparseResults;}parseResults.appName=url.slice(startIndex,endIndex);startIndex=endIndex+1;//checkforinstancenametobeaddedtoapplicationnameendIndex=url.indexOf("/",startIndex);if(endIndex<0){parseResults.streamName=url.slice(startIndex);returnparseResults;}parseResults.appName+="/";parseResults.appName+=url.slice(startIndex,endIndex);startIndex=endIndex+1;//getflvnameparseResults.streamName=url.slice(startIndex);}else{//ishttp,justreturnthefullurlreceivedasstreamNameparseResults.isRTMP=false;parseResults.streamName=url;}returnparseResults;}/***<p>ComparesconnectioninfowithpreviousNetConnection,*willreuseexistingconnectionifpossible.*/privatefunctioncanReuseOldConnection(parseResults:Object):Boolean{//noreuseifnopriorconnectionif(_nc==undefined||_nc==null)returnfalse;//httpconnectionif(!parseResults.isRTMP){//canreuseifprevconnectionwashttpif(!_isRTMP)returntrue;//cannotreuseifwasrtmp--close_owner.close();_nc=null;initNCInfo();returnfalse;}//rtmpconnectionif(_isRTMP){if(parseResults.serverName==_serverName&&parseResults.appName==_appName&&parseResults.protocol==_protocol&&parseResults.portNumber==_portNumber&&parseResults.wrappedURL==_wrappedURL){returntrue;}//cannotreusethisrtmp--close_owner.close();_nc=null;}initNCInfo();returnfalse;}/***<p>Handlescreating<code>NetConnection</code>instancefor*progressivedownloadofFLVviahttp.</p>**@private*/privatefunctionconnectHTTP():Boolean{//ifdefDEBUG//debugTrace("connectHTTP()");//endif_nc=newNetConnection();_nc.connect(null);returntrue;}/***<p>Toplevelfunctionforcreating<code>NetConnection</code>*instanceforprogressivedownloadofFLVviartmp.Actually*triestocreateseveraldifferentconnectionsusingdifferent*protocolsandportsinapipeline,somultipleconnection*attemptsmaybeoccurringsimultaneously,andwillusethe*firstonethatconnectssuccessfully.</p>**@private*/privatefunctionconnectRTMP():Boolean{//ifdefDEBUG//debugTrace("connectRTMP()");//endif//setuptimeoutclearInterval(_timeoutIntervalId);_timeoutIntervalId=setInterval(this,"_onFCSConnectTimeOut",_timeout);_tryNC=newArray();for(vari:Number=0;i<RTMP_CONN.length;i++){//ifdefDEBUG//debugTrace("Creatingconnection"+i);//endif_tryNC=newNetConnection();_tryNC.mc=this;_tryNC.pending=false;_tryNC.connIndex=i;_tryNC.onBWDone=function(p_bw:Number):Void{this.mc.onConnected(this,p_bw);}_tryNC.onBWCheck=function():Number{return++this.mc._payload;}_tryNC.onStatus=function(info:Object):Void{this.mc.connectOnStatus(this,info);};}nextConnect();returnfalse;}/***<p>Doesworkoftryingtoopenrtmpconnections.Calledeither*by<code>connectRTMP</code>oronanintervalsetupin*thatmethod.</p>**<p>Forcreatingrtmpconnections.</p>**@see#connectRTMP()*@private*/privatefunctionnextConnect():Void{//ifdefDEBUG//debugTrace("nextConnect()");//endifclearInterval(_tryNCIntervalId);_tryNCIntervalId=0;varprotocol:String;varport:String;if(_connTypeCounter==0){protocol=_protocol;if(_portNumber!=undefined){port=_portNumber;}else{for(vari:Number=0;i<RTMP_CONN.length;i++){if(protocol==RTMP_CONN.protocol){port=RTMP_CONN.port;break;}}}}else{protocol=RTMP_CONN.protocol;port=RTMP_CONN.port;}varxnURL:String=protocol+((_serverName==undefined)?"":"/"+_serverName+":"+port+"/")+((_wrappedURL==undefined)?"":_wrappedURL+"/")+_appName;//ifdefDEBUG//debugTrace("_tryNC["+_connTypeCounter+"]connectingtoroom:"+xnURL);//endif_tryNC.pending=true;_tryNC.connect(xnURL,_autoSenseBW);if(_connTypeCounter<(RTMP_CONN.length-1)){_connTypeCounter++;_tryNCIntervalId=setInterval(this,"nextConnect",1500);}}/***<p>Stopsallintervals,closesallunneededconnections,andother*cleanuprelatedtothe<code>connectRTMP</code>strategyof*pipeliningconnectionattemptstodifferentprotocolsand*ports.</p>**<p>Forcreatingrtmpconnections.</p>**@see#connectRTMP()*@private*/publicfunctioncleanConns(){//ifdefDEBUG//debugTrace("cleanConns()");//endifclearInterval(_tryNCIntervalId);_tryNCIntervalId=0;if(_tryNC!=undefined){for(vari:Number=0;i<_tryNC.length;i++){if(_tryNC!=undefined){//ifdefDEBUG//debugTrace("_tryNC["+i+"]="+_tryNC);//endifdelete_tryNC.onStatus;if(_tryNC.pending){_tryNC.onStatus=function(info:Object):Void{this.mc.disconnectOnStatus(this,info);};}else{delete_tryNC.onStatus;_tryNC.close();}}delete_tryNC;}delete_tryNC;}}/***<p>Startsanotherpipelinedconnectionattemptwith*<code>connectRTMP</code>withthefallbackserver.</p>**<p>Forcreatingrtmpconnections.</p>**@see#connectRTMP()*@private*/privatefunctiontryFallBack():Void{//ifdefDEBUG//debugTrace("tryFallBack()");//endifif(_serverName==fallbackServerName||fallbackServerName==undefined||fallbackServerName==null){//ifdefDEBUG//debugTrace("Alreadytriedtofallback!");//endif//itsnotconnecteddelete_nc;_nc=undefined;_owner.ncConnected();}else{_connTypeCounter=0;cleanConns();_serverName=fallbackServerName;//ifdefDEBUG//debugTrace("connect:"+_serverName);//endifconnectRTMP();}}/***<p>Startsanotherpipelinedconnectionattemptwith*<code>connectRTMP</code>withthefallbackserver.</p>**<p>Forcreatingrtmpconnections.</p>**@see#connectRTMP()*@private*/publicfunctiononConnected(p_nc:NetConnection,p_bw:Number):Void{//ifdefDEBUG//debugTrace("onConnected()");//endif//avoidtimeoutclearInterval(_timeoutIntervalId);_timeoutIntervalId=0;//ditchthesenowunneededfunctionsandlistenersdeletep_nc.onBWDone;deletep_nc.onBWCheck;deletep_nc.onStatus;//storepointerstothesuccessfulxnanduri_nc=p_nc;_ncUri=_nc.uri;if(_autoSenseBW){_bitrate=p_bw*1024;if(_streams!=undefined){bitrateMatch();}elseif(_streamName.indexOf(",")!=-1){varsSplit:Array=_streamName.split(",");//removeleadingandtrailingwhitespacefromstringfor(vari:Number=0;i<sSplit.length;i+=2){varsName=stripFrontAndBackWhiteSpace(sSplit);if(i+1<sSplit.length){//Ifwehavelessbwthanthenextthresholdorif//thereisntanotherthreshold(laststring)if(p_bw<=Number(sSplit)){_streamName=sName;break;}}else{_streamName=sName;break;}}//for}}//stripoff.flvifincludedif(_streamName.slice(-4).toLowerCase()==".flv"){_streamName=_streamName.slice(0,-4);}//ifweneedtogetthestreamlengthfromtheserver,doithereif(!_owner.isLive&&_streamLength==undefined){varres:Object=newObject();res.mc=this;res.onResult=function(length:Number){this.mc.getStreamLengthResult(length);};_nc.call("getStreamLength",res,_streamName);}else{_owner.ncConnected();}}/***netStatuseventlistenerwhenconnecting**@private*/publicfunctionconnectOnStatus(target:NetConnection,info:Object):Void{//ifdefDEBUG//debugTrace("_tryNC["+target.connIndex+"].onStatus:"+info.code);//varstuff;//for(stuffininfo){//        debugTrace("info["+stuff+"]="+info);//}//endiftarget.pending=false;if(info.code=="NetConnection.Connect.Success"){//ifdefDEBUG//debugTrace("Connection"+RTMP_CONN.protocol+//":"+RTMP_CONN.port+"succeeded!");//endif_nc=_tryNC;_tryNC=undefined;cleanConns();}elseif(((info.code=="NetConnection.Connect.Failed")||(info.code=="NetConnection.Connect.Rejected"))&&(target.connIndex==(RTMP_CONN.length-1))){//TryrearrangingtheappURL,thenthefallbackServerif(!connectAgain()){tryFallBack();}}else{//ifdefDEBUG//debugTrace(RTMP_CONN.protocol+":"+//RTMP_CONN.port+//"onStatus:"+info.code);//endif}}/***netStatuseventlistenerwhenreconnecting**@private*/publicfunctionreconnectOnStatus(target:NetConnection,info:Object):Void{//ifdefDEBUG//debugTrace("reconnectOnStatus:"+info.code);//endifif((info.code=="NetConnection.Connect.Failed")||(info.code=="NetConnection.Connect.Rejected")){//TrythefallbackServerdelete_nc;_nc=undefined;_owner.ncReconnected();}}/***netStatuseventlistenerfordisconnectingextra*NetConnectionsthatwereopenedinparallel**@private*/publicfunctiondisconnectOnStatus(target:NetConnection,info:Object):Void{//ifdefDEBUG//debugTrace("disconnectOnStatus:"+info.code);//endifif(info.code=="NetConnection.Connect.Success"){deletetarget.onStatus;//ifdefDEBUG//debugTrace("Closingmyself");//endiftarget.close();}}/***ResponderfunctiontoreceivestreamLengthresultfrom*serveraftermakingrpc**@private*/publicfunctiongetStreamLengthResult(length:Number):Void{//ifdefDEBUG//debugTrace("getStreamLengthResult("+length+")");//endif_streamLength=length;_owner.ncConnected();}/***<p>Calledonintervaltotimeoutallconnectionattempts.</p>**<p>Forcreatingrtmpconnections.</p>**@see#connectRTMP()*@private*/publicfunction_onFCSConnectTimeOut():Void{//ifdefDEBUG//debugTrace("_onFCSConnectTimeOut()");//endifcleanConns();_nc=undefined;if(!connectAgain()){_owner.ncConnected();}}privatestaticfunctionstripFrontAndBackWhiteSpace(p_str:String):String{vari:Number;varl:Number=p_str.length;varstartIndex:Number=0varendIndex:Number=l;for(i=0;i<l;i++){switch(p_str.charCodeAt(i)){case9://tabcase10://newlinecase13://carriagereturncase32://spacecontinue;}startIndex=i;break;}for(i=l;i>=0;i--){switch(p_str.charCodeAt(i)){case9://tabcase10://newlinecase13://carriagereturncase32://spacecontinue;}endIndex=i+1;break;}if(endIndex<=startIndex){return"";}returnp_str.slice(startIndex,endIndex);}//ifdefDEBUG//publicfunctiondebugTrace(s:String):Void//{//        if(_owner!=undefined){//_owner.debugTrace("#NCManager#"+s);//        }//}//endif}//classmx.video.NCManager

如许场景中一切的FLVPlayer都利用HttpConnectionManager作为NCManager了.不外等等,如许做是不敷的,由于我们的HttpConnectionManager还没有被编译进SWF中,只需复杂的加一句HttpConnectionManager就能够了。
完全的代码:
importmx.video.FLVPlayback;
importmx.video.VideoPlayer;
HttpConnectionManager;//为了让类可以被编译进swf
VideoPlayer.prototype.ncMgrClassName="HttpConnectionManager";
varplayer:FLVPlayback;
player["_vp"]._video.smoothing=true;//让视频可以光滑播放的小hack
player.contentPath="water.swf";//water.flv后缀名改成了swf
到这里,我们的播放器就完成了。
教程及源码下载:Player.zip

可以为受众提供跨计算机、智能手机、平板电脑和电视平台的令人痴迷的一致性体验。

蒙在股里 发表于 2015-1-17 15:21:54

用户在观看广告的时候,无法通过正常点击鼠标来查看广告的尺寸、字节数、所链接的URL广告本身信息。

仓酷云 发表于 2015-1-31 19:44:10

作为奖赏,你可以使用关键祯动画支持和tweening- 两个最主要的节省时间的方式。本质上,关键祯是动画中显著事件发生的位置。

透明 发表于 2015-2-7 01:29:24

在计算机出现之前,动画制作者必需手工绘制即使差别很小的不同祯的图像。当然,非自动的,一祯祯的动画在很多情况下仍然很有用,Flash也允许这样做。

小妖女 发表于 2015-2-19 16:23:44

只要用心 只要努力 在加上你无限的创意和想象。FLASH无敌了

只想知道 发表于 2015-3-6 15:39:51

时间期限本身就是一个优点,因为它可以让你确定一个祯率。电视每秒刷新屏幕30次,电影每秒刷新屏幕24次。Flash的祯率是可变的。

再见西城 发表于 2015-3-13 04:20:39

各种性能才能运用的得心应手,制作出优秀的动画。

不帅 发表于 2015-3-20 12:57:12

Flash也可以合成简单的JavaScript函数。如果你学过某种脚本语言如JavaScript或者Macromedia的Director Lingo,你会知道这有点令人畏缩。
页: [1]
查看完整版本: 来一发FLVPlayer组件辨认非flv后缀视频-Flash动画基本