ckplayer.js 204 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764
  1. /*
  2. 软件名称:ckplayer
  3. 软件版本:X
  4. 软件作者:http://www.ckplayer.com
  5. ---------------------------------------------------------------------------------------------
  6. 开发说明:
  7. 使用的主要程序语言:javascript(js)及actionscript3.0(as3.0)(as3.0主要用于flashplayer部分的开发,不在该页面呈现)
  8. 功能:播放视频
  9. 特点:兼容HTML5-VIDEO(优先)以及FlashPlayer
  10. =====================================================================================================================
  11. */
  12. function ckplayerConfig() {
  13. return {
  14. flashvars: {}, //用来补充flashvars里的对象
  15. languagePath: '', //语言包文件地址
  16. stylePath: '', //风格包文件地址
  17. config: {
  18. fullInteractive: true, //是否开启交互功能
  19. delay: 30, //延迟加载视频,单位:毫秒
  20. timeFrequency: 100, //计算当前播放时间和加载量的时间频率,单位:毫秒
  21. autoLoad: true, //视频是否自动加载
  22. loadNext: 0, //多段视频预加载的段数,设置成0则全部加载
  23. definition: true, //是否使用清晰度组件
  24. smartRemove: true, //是否使用智能清理,使用该功能则在多段时当前播放段之前的段都会被清除出内存,减少对内存的使用
  25. bufferTime: 200, //缓存区的长度,单位:毫秒,不要小于10
  26. click: true, //是否支持屏幕单击暂停
  27. doubleClick: true, //是否支持屏幕双击全屏
  28. doubleClickInterval: 200, //判断双击的标准,即二次单击间隔的时间差之内判断为是双击,单位:毫秒
  29. keyDown: {
  30. space: true, //是否启用空格键切换播放/暂停
  31. left: true, //是否启用左方向键快退
  32. right: true, //是否启用右方向键快进
  33. up: true, //是否支持上方向键增加音量
  34. down: true //是否支持下方向键减少音量
  35. },
  36. timeJump: 10, //快进快退时的秒数
  37. volumeJump: 0.1, //音量调整的数量,大于0小于1的小数
  38. timeScheduleAdjust: 1, //是否可调节调节栏,0不启用,1是启用,2是只能前进(向右拖动),3是只能后退,4是只能前进但能回到第一次拖动时的位置,5是看过的地方可以随意拖动
  39. previewDefaultLoad: true, //预览图片是否默认加载,优点是鼠标第一次经过进度条即可显示预览图片
  40. promptSpotTime: false, //提示点文字是否在前面加上对应时间
  41. buttonMode: {
  42. player: false, //鼠标在播放器上是否显示可点击形态
  43. controlBar: false, //鼠标在控制栏上是否显示可点击形态
  44. timeSchedule: true, //鼠标在时间进度条上是否显示可点击形态
  45. volumeSchedule: true //鼠标在音量调节栏上是否显示可点击形态
  46. },
  47. liveAndVod: { //直播+点播=回播功能
  48. open: false, //是否开启,开启该功能需要设置flashvars里live=true
  49. vodTime: 2, //可以回看的整点数
  50. start: 'start' //回看请求参数
  51. },
  52. errorNum: 3, //错误重连次数
  53. playCorrect: false, //是否需要错误修正,这是针对rtmp的
  54. timeCorrect: true, //http视频播放时间错误纠正,有些因为视频格式的问题导致视频没有实际播放结束视频文件就返回了stop命令
  55. m3u8Definition: { //m3u8自动清晰度时按关键字来进行判断
  56. //tags:['200k','110k','400k','600k','1000k']
  57. },
  58. m3u8MaxBufferLength: 30, //m3u8每次缓冲时间,单位:秒数
  59. split: ',', //当视频地址采用字符形式并且需要使用逗号或其它符号来切割数组里定义
  60. timeStamp: '', //一个地址,用来请求当前时间戳,用于播放器内部时间效准
  61. addCallback: 'adPlay,adPause,playOrPause,videoPlay,videoPause,videoMute,videoEscMute,videoClear,changeVolume,fastBack,fastNext,videoSeek,newVideo,getMetaDate,videoRotation,videoBrightness,videoContrast,videoSaturation,videoHue,videoZoom,videoProportion,videoError,addListener,removeListener,addElement,getElement,deleteElement,animate,animateResume,animatePause,deleteAnimate,changeConfig,getConfig,openUrl,fullScreen,quitFullScreen,switchFull,screenshot,custom,changeControlBarShow,getCurrentSrc'
  62. //需要支持的事件
  63. },
  64. menu: { //版权名称支持
  65. ckkey: '',
  66. name: '',
  67. link: '',
  68. version: '',
  69. domain: '',
  70. more: []
  71. },
  72. style: { //风格部分内容配置,这里主要配置loading和logo以及广告的部分内容
  73. loading: {
  74. file: 'data:image/swf;base64,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',
  75. align: 'center',
  76. vAlign: 'middle',
  77. offsetX: -100,
  78. offsetY: -40
  79. },
  80. logo: {
  81. file: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFcAAAAUCAYAAAD4BKGuAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAVTSURBVHja1Fl/aJVVGP4cw/mH5tUWi3I53cA0WbeIzMgaq6lQoVawm0S6glHhIKM/TELICotqCxMSGWQRdFfRLEhc9mMxqA0rbdS2wsV0GkZXuaKUWlHvgeeNh7f3u1du3Ft74eGcnXu+c873vD/Pt0nZbDZyZL2gWZAQTBH8IjggeEjgPZASPIB+g/P7EsGT6J/BfHfjHFIv2Jpjj/+dlDskvCm42Jk7X3C7YJOgw/z2oOBGwdEYRW0RVAjOCZ4ugNggqwU3CTLRBJFyQ+xuwVRY14igB78tE9QKpgmeEHwkGKRnq9AeMesHRWwEsYGUxwSdBZ51ecweE4Lct0DsOVjaZvptA8jfC4JfghWpXIJ2jMY+EDShf1pwh6DvX5x1GtpDE43cNFlfhyFWpQ9xd5FgFo3fRi++C+2nCBNBRgU3O6RsEyyEQv4QLMb4CcE9RlFBLqS1WZ6BZ83A35ofVhuvfE5QJrjWebdgCJOx51qM1QgewbMzsO57MDQrB9DeC8ObHd5Xyb2eiNiQQxmtgkZBr+OuZwV7BIcF1RgbF1wTE2MbEccX48VY9sMzBilhTke/m+b1Q9lefpgruI7OsYhIGzPJuAnn3+6EM7vu1YKl5vkrYRSfCGZivCxoMklk7M5j6eFlXyRNRSAvAoFf0Fo/CC7LkbwuQjsZsf0qwbuI9wlYgIqGl6NEzDYibJ/gbmAfxpKoMDRcaSK8xZzjZbK+NMhSYoNSngV5e+ksKXp+JdqZwDDmdpSbsqa9gNAyi5JalSGv3iQ+dtNK9HvI+sNBh2AhvNYVaH+msRtAdsa4ehoKCuQsoP2PY8+kCSkJ5IRWjD2FZ4/BOFSWYv9KhI40eUKQ31CqdnLM1c1OOnHufKSS+iEZvgHNhji8g1yT5VZKdCnHO+ajvrYK/I7GkuSWjwvq8Mzl5M79NF89aCHaBNXmWv0sQVUUZEDwsDnbr2i9s31lKyGuFs7kITEBC+snJaToRYIFrRN0CeYgoSUxJ23WUm85eB41b4IUuIvGtyIMVMY8lzHGMoYworF7J/onKYk10/wVQL6zXYr+Zq9aOEhuXZPDel8Q3If+HMzTeHPKlForEK+mws3SMfH2UMxNLIJbasKsoIQZwVLbKFkN4T1C3HxUMM+EkCAfgjwNV40Y304KriOP+jIHqa+jvYsqnH/kqzKaGCFZxWnoTqooxky8+dHUsOGwr6Jfi9jmlVVTHGLnot9L3qGWqCToWYYRF5fDa96mtb93yI2g8B0IWxlTHWmi/hOG00D4mEJfJ5WhQX7ySCsDUaNkJeud6+sgXCgs3OLEG2/xdZSh10JBeiB1zQU0HuQdSib60rOdm9kFToIL8hmFiRHzm1YM0ylet5k579OFpcUk4I0oD0/QuJ7tcBy5ERY6ixdrh5uNwN3bUV7pd4E+J958HmPxbRRydqK/in6vxj5aH9din/udEPKtuU1GqBL24xJwBInQWiHLcbQVKBXTzkVpHP0tWHsIpZUqPeWcrScXuX2ImRkqlufBhdQl15ig3WLKH0/SeAmtD+uprBqGx1ThhlWN5LKG4lcNKbDblFDjVDU0wWK7yLLqnPNk6cKzKsfXt1GQmQQXSuwymhd3tr9lkvPJMUV152kc2PsmUEMxtzdPRk2SNX2DQ3Vhr02Is18LXjHVAz/bG0NEK8johus3UBiwyfkYlDkQUyLaWrwZBrbHMaB8Z3PJLaYk8IIVKKPSJdxbv3ecynNzLNr33GKLV1YVW4IyfycXfq0UxP4X5HJdXCqX4Wv0AKqYkkipw4LG6WxMNi+GhAtH+M/K8wVe7wuWvwQYAFT+UsGCXmX3AAAAAElFTkSuQmCC',
  82. align: 'right',
  83. vAlign: 'top',
  84. offsetX: -100,
  85. offsetY: 10
  86. },
  87. advertisement: { //广告相关的配置
  88. time: 5, //广告默认播放时长以及多个广告时每个广告默认播放时间,单位:秒
  89. method: 'get', //广告监测地址默认请求方式,get/post
  90. videoForce: false, //频广告是否强制播放结束
  91. videoVolume: 0.8, //视频音量
  92. skipButtonShow: true, //是否显示跳过广告按钮
  93. linkButtonShow: true, //是否显示广告链接按钮,如果选择显示,只有在提供了广告链接地址时才会显示
  94. muteButtonShow: true, //是否显示跳过广告按钮
  95. closeButtonShow: true, //暂停时是否显示关闭广告按钮
  96. closeOtherButtonShow: true, //其它广告是否需要关闭广告按钮
  97. frontSkipButtonDelay: 0, //前置广告跳过广告按钮延时显示的时间,单位:秒
  98. insertSkipButtonDelay: 0, //插入广告跳过广告按钮延时显示的时间,单位:秒
  99. endSkipButtonDelay: 0, //后置广告跳过广告按钮延时显示的时间,单位:秒
  100. frontStretched: 2, //前置广告拉伸方式,0=原始大小,1=自动缩放,2=只有当广告的宽或高大于播放器宽高时才进行缩放,3=参考播放器宽高,4=宽度参考播放器宽、高度自动,5=高度参考播放器高、宽度自动
  101. insertStretched: 2, //插入广告拉伸方式,0=原始大小,1=自动缩放,2=只有当广告的宽或高大于播放器宽高时才进行缩放,3=参考播放器宽高,4=宽度参考播放器宽、高度自动,5=高度参考播放器高、宽度自动
  102. pauseStretched: 2, //暂停广告拉伸方式,0=原始大小,1=自动缩放,2=只有当广告的宽或高大于播放器宽高时才进行缩放,3=参考播放器宽高,4=宽度参考播放器宽、高度自动,5=高度参考播放器高、宽度自动
  103. endStretched: 2 //结束广告拉伸方式,0=原始大小,1=自动缩放,2=只有当广告的宽或高大于播放器宽高时才进行缩放,3=参考播放器宽高,4=宽度参考播放器宽、高度自动,5=高度参考播放器高、宽度自动
  104. },
  105. video: { //视频的默认比例
  106. defaultWidth: 4, //宽度
  107. defaultHeight: 3 //高度
  108. }
  109. }
  110. };
  111. }
  112. !(function() {
  113. var javascriptPath = '';
  114. ! function() {
  115. var scriptList = document.scripts,
  116. thisPath = scriptList[scriptList.length - 1].src;
  117. javascriptPath = thisPath.substring(0, thisPath.lastIndexOf('/') + 1);
  118. }();
  119. var ckplayer = function(obj) {
  120. /*
  121. javascript部分开发所用的注释说明:
  122. 1:初始化-程序调用时即运行的代码部分
  123. 2:定义样式-定义容器(div,p,canvas等)的样式表,即css
  124. 3:监听动作-监听元素节点(单击-click,鼠标进入-mouseover,鼠标离开-mouseout,鼠标移动-mousemove等)事件
  125. 4:监听事件-监听视频的状态(播放,暂停,全屏,音量调节等)事件
  126. 5:共用函数-这类函数在外部也可以使用
  127. 6:全局变量-定义成全局使用的变量
  128. 7:其它相关注释
  129. 全局变量说明:
  130. 在本软件中所使用到的全局变量(变量(类型)包括Boolean,String,Int,Object(包含元素对象和变量对象),Array,Function等)
  131. 下面列出重要的全局变量:
  132. V:Object:视频对象
  133. VA:Array:视频列表(包括视频地址,类型,清晰度说明)
  134. ID:String:视频ID
  135. CB:Object:控制栏各元素的集合对象
  136. PD:Object:内部视频容器对象
  137. ---------------------------------------------------------------------------------------------
  138. 程序开始
  139. 下面为需要初始化配置的全局变量
  140. 初始化配置
  141. config:全局变量/变量类型:Object/功能:定义一些基本配置
  142. */
  143. this.config = {
  144. videoClick: true, //是否支持单击播放/暂停动作
  145. videoDbClick: true, //是否支持双击全屏/退出全屏动作
  146. errorTime: 100, //延迟判断失败的时间,单位:毫秒
  147. videoDrawImage: false //是否使用视频drawImage功能,注意,该功能在移动端表现不了
  148. };
  149. //全局变量/变量类型:Object/功能:播放器默认配置,在外部传递过来相应配置后,则进行相关替换
  150. this.varsConfig = {
  151. playerID: '', //播放器ID
  152. container: '', //视频容器的ID
  153. variable: 'ckplayer', //播放函数(变量)名称
  154. volume: 0.8, //默认音量,范围0-1
  155. poster: '', //封面图片地址
  156. autoplay: false, //是否自动播放
  157. loop: false, //是否需要循环播放
  158. live: false, //是否是直播
  159. duration: 0, //指定总时间
  160. seek: 0, //默认需要跳转的秒数
  161. drag: '', //拖动时支持的前置参数
  162. front: '', //前一集按钮动作
  163. next: '', //下一集按钮动作
  164. loaded: '', //加载播放器后调用的函数
  165. flashplayer: false, //设置成true则强制使用flashplayer
  166. html5m3u8: false, //PC平台上是否使用h5播放器播放m3u8
  167. track: null, //字幕轨道
  168. cktrack: null, //ck字幕
  169. preview: null, //预览图片对象
  170. prompt: null, //提示点功能
  171. video: null, //视频地址
  172. config: '', //调用配置函数名称
  173. type: '', //视频格式
  174. crossorigin: '', //设置html5视频的crossOrigin属性
  175. crossdomain: '', //安全策略文件地址
  176. unescape: false, //默认flashplayer里需要解码
  177. mobileCkControls: false, //移动端h5显示控制栏
  178. playbackrate: 1, //默认倍速
  179. debug: false //是否开启调试模式
  180. };
  181. this.vars = {};
  182. //全局变量/变量类型:Object/功能:语言配置
  183. this.language = {
  184. volume: '音量:',
  185. play: '点击播放',
  186. pause: '点击暂停',
  187. full: '点击全屏',
  188. escFull: '退出全屏',
  189. mute: '点击静音',
  190. escMute: '取消静音',
  191. front: '上一集',
  192. next: '下一集',
  193. definition: '点击选择清晰度',
  194. playbackRate: '点击选择速度',
  195. error: '加载出错'
  196. };
  197. //全局变量/变量类型:Array/功能:右键菜单:[菜单标题,类型(link:链接,default:灰色,function:调用函数,javascript:调用js函数),执行内容(包含链接地址,函数名称),[line(间隔线)]]
  198. this.contextMenu = [
  199. ['ckplayer', 'link', 'http://www.ckplayer.com'],
  200. ['version:X', 'default', 'line']
  201. ];
  202. //全局变量/变量类型:Array/功能:错误列表
  203. this.errorList = [
  204. ['000', 'Object does not exist'],
  205. ['001', 'Variables type is not a object'],
  206. ['002', 'Video object does not exist'],
  207. ['003', 'Video object format error'],
  208. ['004', 'Video object format error'],
  209. ['005', 'Video object format error'],
  210. ['006', '[error] does not exist '],
  211. ['007', 'Ajax error'],
  212. ['008', 'Ajax error'],
  213. ['009', 'Ajax object format error'],
  214. ['010', 'Ajax.status:[error]']
  215. ];
  216. //全局变量/变量类型:Array/功能:HTML5变速播放的值数组/如果不需要可以设置成null
  217. this.playbackRateArr = [
  218. [0.5, '0.5倍'],
  219. [1, '正常'],
  220. [1.25, '1.25倍'],
  221. [1.5, '1.5倍'],
  222. [2, '2倍速'],
  223. [4, '4倍速']
  224. ];
  225. //全局变量/变量类型:Array/功能:HTML5默认变速播放的值
  226. this.playbackRateDefault = 1;
  227. //全局变量/变量类型:String/功能:定义logo
  228. this.logo = '';
  229. //全局变量/变量类型:Boolean/功能:是否加载了播放器
  230. this.loaded = false;
  231. //全局变量/变量类型:计时器/功能:监听视频加载出错的状态
  232. this.timerError = null;
  233. //全局变量/变量类型:Boolean/功能:是否出错
  234. this.error = false;
  235. //全局变量/变量类型:Array/功能:出错地址的数组
  236. this.errorUrl = [];
  237. //全局变量/变量类型:计时器/功能:监听全屏与非全屏状态
  238. this.timerFull = null;
  239. //全局变量/变量类型:Boolean/功能:是否全屏状态
  240. this.full = false;
  241. //全局变量/变量类型:计时器/功能:监听当前的月/日 时=分=秒
  242. this.timerTime = null;
  243. //全局变量/变量类型:计时器/功能:监听视频加载
  244. this.timerBuffer = null;
  245. //全局变量/变量类型:Boolean/功能:设置进度按钮及进度条是否跟着时间变化,该属性主要用来在按下进度按钮时暂停进度按钮移动和进度条的长度变化
  246. this.isTimeButtonMove = true;
  247. //全局变量/变量类型:Boolean/功能:进度栏是否有效,如果是直播,则不需要监听时间让进度按钮和进度条变化
  248. this.isTimeButtonDown = false;
  249. //全局变量/变量类型:Boolean/功能:用来模拟双击功能的判断
  250. this.isClick = false;
  251. //全局变量/变量类型:计时器/功能:用来模拟双击功能的计时器
  252. this.timerClick = null;
  253. //全局变量/变量类型:计时器/功能:旋转loading
  254. this.timerLoading = null;
  255. //全局变量/变量类型:计时器/功能:监听鼠标在视频上移动显示控制栏
  256. this.timerCBar = null;
  257. //全局变量/变量类型:Int/功能:播放视频时如果该变量的值大于0,则进行跳转后设置该值为0
  258. this.needSeek = 0;
  259. //全局变量/变量类型:Int/功能:当前音量
  260. this.volume = 0;
  261. //全局变量/变量类型:Int/功能:静音时保存临时音量
  262. this.volumeTemp = 0;
  263. //全局变量/变量类型:Number/功能:当前播放时间
  264. this.time = 0;
  265. //全局变量/变量类型:Boolean/功能:定义首次调用
  266. this.isFirst = true;
  267. //全局变量/变量类型:Boolean/功能:是否使用HTML5-VIDEO播放
  268. this.html5Video = true;
  269. //全局变量/变量类型:Object/功能:记录视频容器节点的x;y
  270. this.pdCoor = {
  271. x: 0,
  272. y: 0
  273. };
  274. //全局变量/变量类型:String/功能:判断当前使用的播放器类型,html5video或flashplayer
  275. this.playerType = '';
  276. //全局变量/变量类型:Int/功能:加载进度条的长度
  277. this.loadTime = 0;
  278. //全局变量/body对象
  279. this.body = document.body || document.documentElement;
  280. //全局变量/V/播放器
  281. this.V = null;
  282. //全局变量/保存外部js监听事件数组
  283. this.listenerJsArr = [];
  284. //全局变量/保存控制栏显示元素的总宽度
  285. this.buttonLen = 0;
  286. //全局变量/保存控制栏显示元素的数组
  287. this.buttonArr = [];
  288. //全局变量/保存按钮元素的宽
  289. this.buttonWidth = {};
  290. //全局变量/保存播放器上新增元件的数组
  291. this.elementArr = [];
  292. //全局变量/字幕内容
  293. this.track = [];
  294. //全局变量/字幕索引
  295. this.trackIndex = 0;
  296. //全局变量/当前显示的字幕内容
  297. this.nowTrackShow = {
  298. sn: ''
  299. };
  300. //全局变量/保存字幕元件数组
  301. this.trackElement = [];
  302. //全局变量/将视频转换为图片
  303. this.timerVCanvas = null;
  304. //全局变量/animate
  305. this.animateArray = [];
  306. //全局变量/保存animate的元件
  307. this.animateElementArray = [];
  308. //全局变量/保存需要在暂停时停止缓动的数组
  309. this.animatePauseArray = [];
  310. //全局变量/预览图片加载状态/0=没有加载,1=正在加载,2=加载完成
  311. this.previewStart = 0;
  312. //全局变量/预览图片容器
  313. this.previewDiv = null;
  314. //全局变量/预览框
  315. this.previewTop = null;
  316. //全局变量/预览框的宽
  317. this.previewWidth = 120;
  318. //全局变量/预览图片容器缓动函数
  319. this.previewTween = null;
  320. //全局变量/是否是m3u8格式,是的话则可以加载hls.js
  321. this.isM3u8 = false;
  322. //全局变量/保存提示点数组
  323. this.promptArr = [];
  324. //全局变量/显示提示点文件的容器
  325. this.promptElement = null;
  326. //配置文件函数
  327. this.ckplayerConfig = {};
  328. //控制栏是否显示
  329. this.showFace = true;
  330. //是否监听过h5的错误
  331. this.errorAdd = false;
  332. //是否发送了错误
  333. this.errorSend = false;
  334. //控制栏是否隐藏
  335. this.controlBarIsShow = true;
  336. //字体
  337. this.fontFamily = '"Microsoft YaHei"; YaHei; "\5FAE\8F6F\96C5\9ED1"; SimHei; "\9ED1\4F53";Arial';
  338. //记录第一次拖动进度按钮时的位置
  339. this.timeSliderLeftTemp = 0;
  340. if(obj) {
  341. this.embed(obj);
  342. }
  343. };
  344. ckplayer.prototype = {
  345. /*
  346. 主要函数部分开始
  347. 主接口函数:
  348. 调用播放器需初始化该函数
  349. */
  350. embed: function(c) {
  351. //c:Object:是调用接口传递的属性对象
  352. if(window.location.href.substr(0, 7) == 'file://') {
  353. alert('Please use the HTTP protocol to open the page');
  354. return;
  355. }
  356. if(c == undefined || !c) {
  357. this.eject(this.errorList[0]);
  358. return;
  359. }
  360. if(typeof(c) != 'object') {
  361. this.eject(this.errorList[1]);
  362. }
  363. this.vars = this.standardization(this.varsConfig, c);
  364. if(!this.vars['mobileCkControls'] && this.isMobile()) {
  365. this.vars['flashplayer'] = false;
  366. this.showFace = false;
  367. }
  368. var videoString = this.vars['video'];
  369. if(!videoString) {
  370. this.eject(this.errorList[2]);
  371. return;
  372. }
  373. if(typeof(videoString) == 'string') {
  374. if(videoString.substr(0, 3) == 'CK:' || videoString.substr(0, 3) == 'CE:' || videoString.substr(8, 3) == 'CK:' || videoString.substr(8, 3) == 'CE:') {
  375. this.vars['flashplayer'] = true;
  376. }
  377. }
  378. if(this.vars['config']) {
  379. this.ckplayerConfig = eval(this.vars['config'] + '()');
  380. } else {
  381. this.ckplayerConfig = ckplayerConfig();
  382. }
  383. if((!this.supportVideo() && this.vars['flashplayer'] != '') || (this.vars['flashplayer'] && this.uploadFlash()) || !this.isMsie()) {
  384. this.html5Video = false;
  385. this.getVideo();
  386. } else if(videoString) {
  387. //判断视频数据类型
  388. this.analysedVideoUrl(videoString);
  389. return this;
  390. } else {
  391. this.eject(this.errorList[2]);
  392. }
  393. },
  394. /*
  395. 内部函数
  396. 根据外部传递过来的video开始分析视频地址
  397. */
  398. analysedVideoUrl: function(video) {
  399. var i = 0,
  400. y = 0;
  401. var thisTemp = this;
  402. //定义全局变量VA:Array:视频列表(包括视频地址,类型,清晰度说明)
  403. this.VA = [];
  404. if(typeof(video) == 'string') { //如果是字符形式的则判断后缀进行填充
  405. if(video.substr(0, 8) != 'website:') {
  406. this.VA = [
  407. [video, '', '', 0]
  408. ];
  409. var fileExt = this.getFileExt(video);
  410. switch(fileExt) {
  411. case '.mp4':
  412. this.VA[0][1] = 'video/mp4';
  413. break;
  414. case '.ogg':
  415. this.VA[0][1] = 'video/ogg';
  416. break;
  417. case '.webm':
  418. this.VA[0][1] = 'video/webm';
  419. break;
  420. default:
  421. break;
  422. }
  423. this.getVideo();
  424. } else {
  425. if(this.html5Video) {
  426. var ajaxObj = {
  427. url: video.substr(8),
  428. success: function(data) {
  429. if(data) {
  430. thisTemp.analysedUrl(data);
  431. } else {
  432. thisTemp.eject(thisTemp.errorList[5]);
  433. this.VA = video;
  434. thisTemp.getVideo();
  435. }
  436. }
  437. };
  438. this.ajax(ajaxObj);
  439. } else {
  440. this.VA = video;
  441. this.getVideo();
  442. }
  443. }
  444. } else if(typeof(video) == 'object') { //对象或数组
  445. if(!this.isUndefined(typeof(video.length))) { //说明是数组
  446. if(!this.isUndefined(typeof(video[0].length))) { //说明是数组形式的数组
  447. this.VA = video;
  448. }
  449. this.getVideo();
  450. } else {
  451. /*
  452. 如果video格式是对象形式,则分二种
  453. 如果video对象里包含type,则直接播放
  454. */
  455. if(!this.isUndefined(video['type'])) {
  456. this.VA.push([video['file'], video['type'], '', 0]);
  457. this.getVideo();
  458. } else {
  459. this.eject(this.errorList[5]);
  460. }
  461. }
  462. } else {
  463. this.eject(this.errorList[4]);
  464. }
  465. },
  466. /*
  467. 对请求到的视频地址进行重新分析
  468. */
  469. analysedUrl: function(data) {
  470. this.vars = this.standardization(this.vars, data);
  471. if(!this.isUndefined(data['video'])) {
  472. this.vars['video'] = data['video'];
  473. }
  474. this.analysedVideoUrl(this.vars['video']);
  475. },
  476. /*
  477. 内部函数
  478. 检查浏览器支持的视频格式,如果是则将支持的视频格式重新分组给播放列表
  479. */
  480. getHtml5Video: function() {
  481. var va = this.VA;
  482. var nva = [];
  483. var mobile = false;
  484. var video = document.createElement('video');
  485. var codecs = function(type) {
  486. var cod = '';
  487. switch(type) {
  488. case 'video/mp4':
  489. cod = 'avc1.4D401E, mp4a.40.2';
  490. break;
  491. case 'video/ogg':
  492. cod = 'theora, vorbis';
  493. break;
  494. case 'video/webm':
  495. cod = 'vp8.0, vorbis';
  496. break;
  497. default:
  498. break;
  499. }
  500. return cod;
  501. };
  502. var supportType = function(vidType, codType) {
  503. if(!video.canPlayType) {
  504. this.html5Video = false;
  505. return;
  506. }
  507. var isSupp = video.canPlayType(vidType + ';codecs="' + codType + '"');
  508. if(isSupp == '') {
  509. return false
  510. }
  511. return true;
  512. };
  513. if(this.vars['flashplayer'] || !this.isMsie()) {
  514. this.html5Video = false;
  515. return;
  516. }
  517. if(this.isMobile()) {
  518. mobile = true;
  519. }
  520. for(var i = 0; i < va.length; i++) {
  521. var v = va[i];
  522. if(v) {
  523. if(v[1] != '' && !mobile && supportType(v[1], codecs(v[1])) && v[0].substr(0, 4) != 'rtmp') {
  524. nva.push(v);
  525. }
  526. if((this.getFileExt(v[0]) == '.m3u8' || this.vars['type']=='video/m3u8' || this.vars['type']=='m3u8' || v[1]=='video/m3u8' || v[1]=='m3u8') && this.vars['html5m3u8']) {
  527. this.isM3u8 = true;
  528. nva.push(v);
  529. }
  530. }
  531. }
  532. if(nva.length > 0) {
  533. this.VA = nva;
  534. } else {
  535. if(!mobile) {
  536. this.html5Video = false;
  537. }
  538. }
  539. },
  540. /*
  541. 内部函数
  542. 根据视频地址开始构建播放器
  543. */
  544. getVideo: function() {
  545. //如果存在字幕则加载
  546. if(this.V) { //如果播放器已存在,则认为是从newVideo函数发送过来的请求
  547. this.changeVideo();
  548. return;
  549. }
  550. if(this.vars['cktrack']) {
  551. this.loadTrack();
  552. }
  553. if(this.supportVideo() && !this.vars['flashplayer']) {
  554. this.getHtml5Video(); //判断浏览器支持的视频格式
  555. }
  556. var thisTemp = this;
  557. var v = this.vars;
  558. var src = '',
  559. source = '',
  560. poster = '',
  561. loop = '',
  562. autoplay = '',
  563. track = '';
  564. var video = v['video'];
  565. var i = 0;
  566. this.CD = this.getByElement(v['container']);
  567. volume = v['volume'];
  568. if(!this.CD) {
  569. this.eject(this.errorList[6], v['container']);
  570. return false;
  571. }
  572. //开始构建播放容器
  573. var playerID = 'ckplayer' + this.randomString();
  574. var playerDiv = document.createElement('div');
  575. playerDiv.className = playerID;
  576. this.V = undefined;
  577. this.CD.innerHTML = '';
  578. this.CD.appendChild(playerDiv);
  579. this.PD = this.getByElement(playerID); //PD:定义播放器容器对象全局变量
  580. this.css(this.CD, {
  581. backgroundColor: '#000000',
  582. overflow: 'hidden',
  583. position: 'relative'
  584. });
  585. this.css(this.PD, {
  586. backgroundColor: '#000000',
  587. width: '100%',
  588. height: '100%',
  589. fontFamily: this.fontFamily
  590. });
  591. if(this.html5Video) { //如果支持HTML5-VIDEO则默认使用HTML5-VIDEO播放器
  592. //禁止播放器容器上鼠标选择文本
  593. this.PD.onselectstart = this.PD.ondrag = function() {
  594. return false;
  595. };
  596. //播放容器构建完成并且设置好样式
  597. //构建播放器
  598. if(this.VA.length == 1) {
  599. src = ' src="' + decodeURIComponent(this.VA[0][0]) + '"';
  600. } else {
  601. var videoArr = this.VA.slice(0);
  602. videoArr = this.arrSort(videoArr);
  603. for(i = 0; i < videoArr.length; i++) {
  604. var type = '';
  605. var va = videoArr[i];
  606. if(va[1]) {
  607. type = ' type="' + va[1] + '"';
  608. if(type == ' type="video/m3u8"' || type == ' type="m3u8"') {
  609. type = '';
  610. }
  611. }
  612. source += '<source src="' + decodeURIComponent(va[0]) + '"' + type + '>';
  613. }
  614. }
  615. //分析视频地址结束
  616. if(v['autoplay']) {
  617. autoplay = ' autoplay="autoplay"';
  618. }
  619. if(v['poster']) {
  620. poster = ' poster="' + v['poster'] + '"';
  621. }
  622. if(v['loop']) {
  623. loop = ' loop="loop"';
  624. }
  625. if(v['seek'] > 0) {
  626. this.needSeek = v['seek'];
  627. }
  628. if(v['track'] != null && v['cktrack'] == null) {
  629. var trackArr = v['track'];
  630. var trackDefault = '';
  631. var defaultHave = false;
  632. for(i = 0; i < trackArr.length; i++) {
  633. var trackObj = trackArr[i];
  634. if(trackObj['default'] && !defaultHave) {
  635. trackDefault = ' default';
  636. defaultHave = true;
  637. } else {
  638. trackDefault = '';
  639. }
  640. track += '<track kind="' + trackObj['kind'] + '" src="' + trackObj['src'] + '" srclang="' + trackObj['srclang'] + '" label="' + trackObj['label'] + '"' + trackDefault + '>';
  641. }
  642. }
  643. var autoLoad = this.ckplayerConfig['config']['autoLoad'];
  644. var preload = '';
  645. if(!autoLoad) {
  646. preload = ' preload="meta"';
  647. }
  648. var vid = this.randomString();
  649. var controls = '';
  650. if(!this.showFace) {
  651. controls = ' controls="controls"';
  652. }
  653. var html = '';
  654. if(!this.isM3u8) {
  655. html = '<video id="' + vid + '"' + src + ' width="100%" height="100%"' + autoplay + poster + loop + preload + controls + ' x5-playsinline="" playsinline="" webkit-playsinline="true">' + source + track + '</video>';
  656. } else {
  657. html = '<video id="' + vid + '" width="100%" height="100%"' + poster + loop + preload + controls + ' x5-playsinline="" playsinline="" webkit-playsinline="true">' + track + '</video>';
  658. }
  659. this.PD.innerHTML = html;
  660. this.V = this.getByElement('#' + vid); //V:定义播放器对象全局变量
  661. if(this.vars['crossorigin']) {
  662. this.V.crossOrigin = this.vars['crossorigin'];
  663. }
  664. try {
  665. this.V.volume = volume; //定义音量
  666. if(this.playbackRateArr && this.vars['playbackrate'] > -1) {
  667. if(this.vars['playbackrate'] < this.playbackRateArr.length) {
  668. this.playbackRateDefault = this.vars['playbackrate'];
  669. }
  670. this.V.playbackRate = this.playbackRateArr[this.playbackRateDefault][0]; //定义倍速
  671. }
  672. } catch(error) {}
  673. this.css(this.V, {
  674. width: '100%',
  675. height: '100%'
  676. });
  677. if(this.isM3u8) {
  678. var loadJsHandler = function() {
  679. thisTemp.embedHls(thisTemp.VA[0][0], v['autoplay']);
  680. };
  681. this.loadJs(javascriptPath + 'hls/hls.min.js', loadJsHandler);
  682. }
  683. this.css(this.V, 'backgroundColor', '#000000');
  684. //创建一个画布容器
  685. if(this.config['videoDrawImage']) {
  686. var canvasID = 'vcanvas' + this.randomString();
  687. var canvasDiv = document.createElement('div');
  688. canvasDiv.className = canvasID;
  689. this.PD.appendChild(canvasDiv);
  690. this.MD = this.getByElement(canvasID); //定义画布存储容器
  691. this.css(this.MD, {
  692. backgroundColor: '#000000',
  693. width: '100%',
  694. height: '100%',
  695. position: 'absolute',
  696. display: 'none',
  697. cursor: 'pointer',
  698. left: '0px',
  699. top: '0px',
  700. zIndex: '10'
  701. });
  702. var cvid = 'ccanvas' + this.randomString();
  703. this.MD.innerHTML = this.newCanvas(cvid, this.PD.offsetWidth, this.PD.offsetHeight);
  704. this.MDC = this.getByElement(cvid + '-canvas');
  705. this.MDCX = this.MDC.getContext('2d');
  706. }
  707. this.playerType = 'html5video';
  708. //播放器构建完成并且设置好样式
  709. //建立播放器的监听函数,包含操作监听及事件监听
  710. this.addVEvent();
  711. //根据清晰度的值构建清晰度切换按钮
  712. if(this.showFace) {
  713. this.definition();
  714. if(!this.vars['live'] && this.playbackRateArr && this.vars['playbackrate'] > -1) {
  715. this.playbackRate();
  716. }
  717. if(v['autoplay']) {
  718. this.loadingStart(true);
  719. }
  720. }
  721. this.playerLoad();
  722. } else { //如果不支持HTML5-VIDEO则调用flashplayer
  723. this.embedSWF();
  724. }
  725. },
  726. /*
  727. 内部函数
  728. 发送播放器加载成功的消息
  729. */
  730. playerLoad: function() {
  731. var thisTemp = this;
  732. if(this.isFirst) {
  733. this.isFirst = false;
  734. window.setTimeout(function() {
  735. thisTemp.loadedHandler();
  736. }, 1);
  737. }
  738. },
  739. /*
  740. 内部函数
  741. 建立播放器的监听函数,包含操作监听及事件监听
  742. */
  743. addVEvent: function() {
  744. var thisTemp = this;
  745. //监听视频单击事件
  746. var eventVideoClick = function(event) {
  747. thisTemp.videoClick();
  748. };
  749. this.addListenerInside('click', eventVideoClick);
  750. this.addListenerInside('click', eventVideoClick, this.MDC);
  751. //延迟计算加载失败事件
  752. this.timerErrorFun();
  753. //监听视频加载到元数据事件
  754. var eventJudgeIsLive = function(event) {
  755. thisTemp.sendJS('loadedmetadata');
  756. thisTemp.sendJS('duration', thisTemp.V.duration);
  757. thisTemp.judgeIsLive();
  758. };
  759. this.addListenerInside('loadedmetadata', eventJudgeIsLive);
  760. //监听视频播放事件
  761. var eventPlaying = function(event) {
  762. thisTemp.playingHandler();
  763. thisTemp.sendJS('play');
  764. thisTemp.sendJS('paused', false);
  765. };
  766. this.addListenerInside('playing', eventPlaying);
  767. //监听视频暂停事件
  768. var eventPause = function(event) {
  769. thisTemp.pauseHandler();
  770. thisTemp.sendJS('pause');
  771. thisTemp.sendJS('paused', true);
  772. };
  773. this.addListenerInside('pause', eventPause);
  774. //监听视频播放时间事件
  775. var eventTimeupdate = function(event) {
  776. if(thisTemp.timerLoading != null) {
  777. thisTemp.loadingStart(false);
  778. }
  779. if(thisTemp.time) {
  780. thisTemp.sendJS('time', thisTemp.time);
  781. }
  782. };
  783. this.addListenerInside('timeupdate', eventTimeupdate);
  784. //监听视频缓冲事件
  785. var eventWaiting = function(event) {
  786. thisTemp.loadingStart(true);
  787. };
  788. this.addListenerInside('waiting', eventWaiting);
  789. //监听视频seek开始事件
  790. var eventSeeking = function(event) {
  791. thisTemp.sendJS('seek', 'start');
  792. };
  793. this.addListenerInside('seeking', eventSeeking);
  794. //监听视频seek结束事件
  795. var eventSeeked = function(event) {
  796. thisTemp.seekedHandler();
  797. thisTemp.sendJS('seek', 'ended');
  798. };
  799. this.addListenerInside('seeked', eventSeeked);
  800. //监听视频播放结束事件
  801. var eventEnded = function(event) {
  802. thisTemp.endedHandler();
  803. thisTemp.sendJS('ended');
  804. };
  805. this.addListenerInside('ended', eventEnded);
  806. //监听视频音量
  807. var eventVolumeChange = function(event) {
  808. try {
  809. thisTemp.volumechangeHandler();
  810. thisTemp.sendJS('volume', thisTemp.volume || thisTemp.V.volume);
  811. } catch(event) {}
  812. };
  813. this.addListenerInside('volumechange', eventVolumeChange);
  814. //监听全屏事件
  815. var eventFullChange = function(event) {
  816. var fullState = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
  817. thisTemp.sendJS('full', fullState);
  818. };
  819. this.addListenerInside('fullscreenchange', eventFullChange);
  820. this.addListenerInside('webkitfullscreenchange', eventFullChange);
  821. this.addListenerInside('mozfullscreenchange', eventFullChange);
  822. //建立界面
  823. if(this.showFace) {
  824. this.interFace();
  825. }
  826. },
  827. /*
  828. 内部函数
  829. 重置界面元素
  830. */
  831. resetPlayer: function() {
  832. this.timeTextHandler();
  833. if(this.showFace) {
  834. this.timeProgress(0, 1); //改变时间进度条宽
  835. this.changeLoad(0);
  836. this.initPlayPause(); //判断显示播放或暂停按钮
  837. this.definition(); //构建清晰度按钮
  838. this.showFrontNext(); //构建上一集下一集按钮
  839. this.deletePrompt(); //删除提示点
  840. this.deletePreview(); //删除预览图
  841. this.trackHide(); //重置字幕
  842. this.resetTrack();
  843. this.trackElement = [];
  844. this.track = [];
  845. }
  846. },
  847. /*
  848. 内部函数
  849. 构建界面元素
  850. */
  851. interFace: function() {
  852. this.showFace = true;
  853. var thisTemp = this;
  854. var html = ''; //控制栏内容
  855. var i = 0;
  856. var bWidth = 38, //按钮的宽
  857. bHeight = 38; //按钮的高
  858. var bBgColor = '#FFFFFF', //按钮元素默认颜色
  859. bOverColor = '#0782F5'; //按钮元素鼠标经过时的颜色
  860. var timeInto = this.formatTime(0) + ' / ' + this.formatTime(this.vars['duration']); //时间显示框默认显示内容
  861. var randomS = this.randomString(10); //获取一个随机字符串
  862. /*
  863. 以下定义界面各元素的ID,统一以ID结束
  864. */
  865. var controlBarBgID = 'controlbgbar' + randomS, //控制栏背景
  866. controlBarID = 'controlbar' + randomS, //控制栏容器
  867. timeProgressBgID = 'timeprogressbg' + randomS, //播放进度条背景
  868. loadProgressID = 'loadprogress' + randomS, //加载进度条
  869. timeProgressID = 'timeprogress' + randomS, //播放进度条
  870. timeBOBGID = 'timebobg' + randomS, //播放进度按钮容器,该元素为一个透明覆盖在播放进度条上
  871. timeBOID = 'timebo' + randomS, //播放进度可拖动按钮外框
  872. timeBWID = 'timebw' + randomS, //播放进度可拖动按钮内框
  873. timeTextID = 'timetext' + randomS, //时间文本框
  874. playID = 'play' + randomS, //播放按钮
  875. pauseID = 'pause' + randomS, //暂停按钮
  876. frontID = 'front' + randomS, //前一集按钮
  877. nextID = 'next' + randomS, //下一集按钮
  878. fullID = 'full' + randomS, //全屏按钮
  879. escFullID = 'escfull' + randomS, //退出全屏按钮
  880. muteID = 'mute' + randomS, //静音按钮
  881. escMuteID = 'escmute' + randomS, //取消静音按钮
  882. volumeID = 'volume' + randomS, //音量调节框容器
  883. volumeDbgID = 'volumedbg' + randomS, //音量调节框容器背景
  884. volumeBgID = 'volumebg' + randomS, //音量调节框背景层
  885. volumeUpID = 'volumeup' + randomS, //音量调节框可变宽度层
  886. volumeBOID = 'volumebo' + randomS, //音量调节按钮外框
  887. volumeBWID = 'volumebw' + randomS, //音量调节按钮内框
  888. definitionID = 'definition' + randomS, //清晰度容器
  889. definitionPID = 'definitionp' + randomS, //清晰度列表容器
  890. playbackRateID = 'playbackrate' + randomS, //清晰度容器
  891. playbackRatePID = 'playbackratep' + randomS, //清晰度列表容器
  892. promptBgID = 'promptbg' + randomS, //提示框背景
  893. promptID = 'prompt' + randomS, //提示框
  894. dlineID = 'dline' + randomS, //分隔线共用前缀
  895. menuID = 'menu' + randomS, //右键容器
  896. pauseCenterID = 'pausecenter' + randomS, //中间暂停按钮
  897. loadingID = 'loading' + randomS, //缓冲
  898. errorTextID = 'errortext' + randomS, //错误文本框
  899. logoID = 'logo' + randomS; //logo
  900. //构建一些PD(播放器容器)里使用的元素
  901. var controlBarBg = document.createElement('div'),
  902. controlBar = document.createElement('div'),
  903. timeProgressBg = document.createElement('div'),
  904. timeBoBg = document.createElement('div'),
  905. pauseCenter = document.createElement('div'),
  906. errorText = document.createElement('div'),
  907. promptBg = document.createElement('div'),
  908. prompt = document.createElement('div'),
  909. menuDiv = document.createElement('div'),
  910. definitionP = document.createElement('div'),
  911. playbackrateP = document.createElement('div'),
  912. loading = document.createElement('div'),
  913. logo = document.createElement('div');
  914. controlBarBg.className = controlBarBgID;
  915. controlBar.className = controlBarID;
  916. timeProgressBg.className = timeProgressBgID;
  917. timeBoBg.className = timeBOBGID;
  918. promptBg.className = promptBgID;
  919. prompt.className = promptID;
  920. menuDiv.className = menuID;
  921. definitionP.className = definitionPID;
  922. playbackrateP.className = playbackRatePID;
  923. pauseCenter.className = pauseCenterID;
  924. loading.className = loadingID;
  925. logo.className = logoID;
  926. errorText.className = errorTextID;
  927. this.PD.appendChild(controlBarBg);
  928. this.PD.appendChild(controlBar);
  929. this.PD.appendChild(timeProgressBg);
  930. this.PD.appendChild(timeBoBg);
  931. this.PD.appendChild(promptBg);
  932. this.PD.appendChild(prompt);
  933. this.PD.appendChild(definitionP);
  934. this.PD.appendChild(playbackrateP);
  935. this.PD.appendChild(pauseCenter);
  936. this.PD.appendChild(loading);
  937. this.PD.appendChild(errorText);
  938. this.PD.appendChild(logo);
  939. this.body.appendChild(menuDiv);
  940. //构建一些PD(播放器容器)里使用的元素结束
  941. if(this.vars['live']) { //如果是直播,时间显示文本框里显示当前系统时间
  942. timeInto = this.getNowDate();
  943. }
  944. //构建控制栏的内容
  945. html += '<div class="' + playID + '" data-title="' + thisTemp.language['play'] + '">' + this.newCanvas(playID, bWidth, bHeight) + '</div>'; //播放按钮
  946. html += '<div class="' + pauseID + '" data-title="' + thisTemp.language['pause'] + '">' + this.newCanvas(pauseID, bWidth, bHeight) + '</div>'; //暂停按钮
  947. html += '<div class="' + dlineID + '-la"></div>'; //分隔线
  948. html += '<div class="' + frontID + '" data-title="' + thisTemp.language['front'] + '">' + this.newCanvas(frontID, bWidth, bHeight) + '</div>'; //前一集按钮
  949. html += '<div class="' + dlineID + '-lb"></div>'; //分隔线
  950. html += '<div class="' + nextID + '" data-title="' + thisTemp.language['next'] + '">' + this.newCanvas(nextID, bWidth, bHeight) + '</div>'; //下一集按钮
  951. html += '<div class="' + dlineID + '-lc"></div>'; //分隔线
  952. html += '<div class="' + timeTextID + '">' + timeInto + '</div>'; //时间文本
  953. html += '<div class="' + fullID + '" data-title="' + thisTemp.language['full'] + '">' + this.newCanvas(fullID, bWidth, bHeight) + '</div>'; //全屏按钮
  954. html += '<div class="' + escFullID + '" data-title="' + thisTemp.language['escFull'] + '">' + this.newCanvas(escFullID, bWidth, bHeight) + '</div>'; //退出全屏按钮
  955. html += '<div class="' + dlineID + '-ra"></div>'; //分隔线
  956. html += '<div class="' + definitionID + '" data-title="' + thisTemp.language['definition'] + '"></div>'; //清晰度容器
  957. html += '<div class="' + dlineID + '-rb"></div>'; //分隔线
  958. html += '<div class="' + playbackRateID + '" data-title="' + thisTemp.language['playbackRate'] + '"></div>'; //倍速
  959. html += '<div class="' + dlineID + '-rc"></div>'; //分隔线
  960. html += '<div class="' + volumeID + '"><div class="' + volumeDbgID + '"><div class="' + volumeBgID + '"><div class="' + volumeUpID + '"></div></div><div class="' + volumeBOID + '"><div class="' + volumeBWID + '"></div></div></div></div>'; //音量调节框,音量调节按钮
  961. html += '<div class="' + muteID + '" data-title="' + thisTemp.language['mute'] + '">' + this.newCanvas(muteID, bWidth, bHeight) + '</div>'; //静音按钮
  962. html += '<div class="' + escMuteID + '" data-title="' + thisTemp.language['escMute'] + '">' + this.newCanvas(escMuteID, bWidth, bHeight) + '</div>'; //退出静音按钮
  963. html += '<div class="' + dlineID + '-rd"></div>'; //分隔线
  964. this.getByElement(controlBarID).innerHTML = html;
  965. //构建控制栏内容结束
  966. //构建进度条内容
  967. this.getByElement(timeProgressBgID).innerHTML = '<div class="' + loadProgressID + '"></div><div class="' + timeProgressID + '"></div>';
  968. this.getByElement(timeBOBGID).innerHTML = '<div class="' + timeBOID + '"><div class="' + timeBWID + '"></div></div>';
  969. //构建进度条内容结束
  970. this.getByElement(pauseCenterID).innerHTML = this.newCanvas(pauseCenterID, 80, 80); //构建中间暂停按钮
  971. this.getByElement(loadingID).innerHTML = this.newCanvas(loadingID, 60, 60); //构建中间缓冲时显示的图标
  972. this.getByElement(errorTextID).innerHTML = this.language['error']; //构建错误时显示的文本框
  973. if(this.ckplayerConfig['style']['logo']) {
  974. if(this.ckplayerConfig['style']['logo']['file']) {
  975. var logoFile = this.ckplayerConfig['style']['logo']['file'];
  976. if(logoFile.substr(0, 15) == 'data:image/png;' || logoFile.substr(0, 15) == 'data:image/jpg;' || logoFile.substr(0, 15) == 'data:image/jpeg;') {
  977. this.getByElement(logoID).innerHTML = '<img src="' + logoFile + '" border="0">'; //构建logo
  978. }
  979. }
  980. } else {
  981. this.getByElement(logoID).innerHTML = this.vars['logo'] || this.logo || ''; //构建logo
  982. }
  983. //CB:Object:全局变量,将一些全局需要用到的元素统一放在CB对象里
  984. var pd = this.PD;
  985. this.CB = {
  986. controlBarBg: this.getByElement(controlBarBgID, pd),
  987. controlBar: this.getByElement(controlBarID, pd),
  988. promptBg: this.getByElement(promptBgID, pd),
  989. prompt: this.getByElement(promptID, pd),
  990. timeProgressBg: this.getByElement(timeProgressBgID, pd),
  991. loadProgress: this.getByElement(loadProgressID, pd),
  992. timeProgress: this.getByElement(timeProgressID, pd),
  993. timeBoBg: this.getByElement(timeBOBGID, pd),
  994. timeButton: this.getByElement(timeBOID, pd),
  995. timeText: this.getByElement(timeTextID, pd),
  996. play: this.getByElement(playID, pd),
  997. front: this.getByElement(frontID, pd),
  998. next: this.getByElement(nextID, pd),
  999. pause: this.getByElement(pauseID, pd),
  1000. definition: this.getByElement(definitionID, pd),
  1001. definitionP: this.getByElement(definitionPID, pd),
  1002. definitionLine: this.getByElement(dlineID + '-rb', pd),
  1003. playbackrate: this.getByElement(playbackRateID, pd),
  1004. playbackrateP: this.getByElement(playbackRatePID, pd),
  1005. playbackrateLine: this.getByElement(dlineID + '-rc', pd),
  1006. full: this.getByElement(fullID, pd),
  1007. escFull: this.getByElement(escFullID, pd),
  1008. mute: this.getByElement(muteID, pd),
  1009. escMute: this.getByElement(escMuteID, pd),
  1010. volume: this.getByElement(volumeID, pd),
  1011. volumeBg: this.getByElement(volumeBgID, pd),
  1012. volumeUp: this.getByElement(volumeUpID, pd),
  1013. volumeBO: this.getByElement(volumeBOID, pd),
  1014. pauseCenter: this.getByElement(pauseCenterID, pd),
  1015. menu: this.getByElement(menuID),
  1016. loading: this.getByElement(loadingID, pd),
  1017. loadingCanvas: this.getByElement(loadingID + '-canvas', pd),
  1018. errorText: this.getByElement(errorTextID, pd),
  1019. logo: this.getByElement(logoID, pd),
  1020. playLine: this.getByElement(dlineID + '-la', pd),
  1021. frontLine: this.getByElement(dlineID + '-lb', pd),
  1022. nextLine: this.getByElement(dlineID + '-lc', pd),
  1023. fullLine: this.getByElement(dlineID + '-ra'),
  1024. definitionLine: this.getByElement(dlineID + '-rb', pd),
  1025. muteLine: this.getByElement(dlineID + '-rd', pd)
  1026. };
  1027. this.buttonWidth = {
  1028. play: bWidth,
  1029. full: bWidth,
  1030. front: bWidth,
  1031. next: bWidth,
  1032. mute: bWidth
  1033. };
  1034. //定义界面元素的样式
  1035. //控制栏背景
  1036. this.css(controlBarBgID, {
  1037. width: '100%',
  1038. height: bHeight + 'px',
  1039. backgroundColor: '#000000',
  1040. position: 'absolute',
  1041. bottom: '0px',
  1042. filter: 'alpha(opacity:0.8)',
  1043. opacity: '0.8',
  1044. zIndex: '90'
  1045. });
  1046. //控制栏容器
  1047. this.css(controlBarID, {
  1048. width: '100%',
  1049. height: bHeight + 'px',
  1050. position: 'absolute',
  1051. bottom: '0px',
  1052. zIndex: '90'
  1053. });
  1054. //中间暂停按钮
  1055. this.css(pauseCenterID, {
  1056. width: '80px',
  1057. height: '80px',
  1058. borderRadius: '50%',
  1059. position: 'absolute',
  1060. display: 'none',
  1061. cursor: 'pointer',
  1062. zIndex: '100'
  1063. });
  1064. //loading
  1065. this.css(loadingID, {
  1066. width: '60px',
  1067. height: '60px',
  1068. position: 'absolute',
  1069. display: 'none',
  1070. zIndex: '100'
  1071. });
  1072. //出错文本框
  1073. this.css(errorTextID, {
  1074. width: '120px',
  1075. height: '30px',
  1076. lineHeight: '30px',
  1077. color: '#FFFFFF',
  1078. fontSize: '14px',
  1079. textAlign: 'center',
  1080. position: 'absolute',
  1081. display: 'none',
  1082. zIndex: '101',
  1083. cursor: 'default',
  1084. zIndex: '100'
  1085. });
  1086. //定义logo文字的样式
  1087. this.css(logoID, {
  1088. height: '30px',
  1089. lineHeight: '30px',
  1090. color: '#FFFFFF',
  1091. fontFamily: 'Arial',
  1092. fontSize: '28px',
  1093. textAlign: 'center',
  1094. position: 'absolute',
  1095. float: 'left',
  1096. left: '-1000px',
  1097. top: '20px',
  1098. zIndex: '100',
  1099. filter: 'alpha(opacity:0.8)',
  1100. opacity: '0.8',
  1101. cursor: 'default'
  1102. });
  1103. this.css(this.CB['loadingCanvas'], {
  1104. transform: 'rotate(0deg)',
  1105. msTransform: 'rotate(0deg)',
  1106. mozTransform: 'rotate(0deg)',
  1107. webkitTransform: 'rotate(0deg)',
  1108. oTransform: 'rotate(0deg)'
  1109. });
  1110. //定义提示语的样式
  1111. this.css([promptBgID, promptID], {
  1112. height: '30px',
  1113. lineHeight: '30px',
  1114. color: '#FFFFFF',
  1115. fontSize: '14px',
  1116. textAlign: 'center',
  1117. position: 'absolute',
  1118. borderRadius: '5px',
  1119. paddingLeft: '5px',
  1120. paddingRight: '5px',
  1121. bottom: '0px',
  1122. display: 'none',
  1123. zIndex: '95'
  1124. });
  1125. this.css(promptBgID, {
  1126. backgroundColor: '#000000',
  1127. filter: 'alpha(opacity:0.5)',
  1128. opacity: '0.5'
  1129. });
  1130. //时间进度条背景容器
  1131. this.css(timeProgressBgID, {
  1132. width: '100%',
  1133. height: '6px',
  1134. backgroundColor: '#3F3F3F',
  1135. overflow: 'hidden',
  1136. position: 'absolute',
  1137. bottom: '38px',
  1138. zIndex: '88'
  1139. });
  1140. //加载进度和时间进度
  1141. this.css([loadProgressID, timeProgressID], {
  1142. width: '1px',
  1143. height: '6px',
  1144. position: 'absolute',
  1145. bottom: '38px',
  1146. top: '0px',
  1147. zIndex: '91'
  1148. });
  1149. this.css(loadProgressID, 'backgroundColor', '#6F6F6F');
  1150. this.css(timeProgressID, 'backgroundColor', bOverColor);
  1151. //时间进度按钮
  1152. this.css(timeBOBGID, {
  1153. width: '100%',
  1154. height: '14px',
  1155. overflow: 'hidden',
  1156. position: 'absolute',
  1157. bottom: '34px',
  1158. cursor: 'pointer',
  1159. zIndex: '92'
  1160. });
  1161. this.css(timeBOID, {
  1162. width: '14px',
  1163. height: '14px',
  1164. overflow: 'hidden',
  1165. borderRadius: '50%',
  1166. backgroundColor: bBgColor,
  1167. cursor: 'pointer',
  1168. position: 'absolute',
  1169. top: '0px',
  1170. zIndex: '20'
  1171. });
  1172. this.css(timeBWID, {
  1173. width: '8px',
  1174. height: '8px',
  1175. overflow: 'hidden',
  1176. borderRadius: '50%',
  1177. position: 'absolute',
  1178. backgroundColor: bOverColor,
  1179. left: '3px',
  1180. top: '3px'
  1181. });
  1182. this.css(timeTextID, {
  1183. lineHeight: bHeight + 'px',
  1184. color: '#FFFFFF',
  1185. fontFamily: 'arial',
  1186. fontSize: '16px',
  1187. paddingLeft: '10px',
  1188. float: 'left',
  1189. overflow: 'hidden',
  1190. cursor: 'default'
  1191. });
  1192. //分隔线
  1193. this.css([dlineID + '-la', dlineID + '-lb', dlineID + '-lc', dlineID + '-ra', dlineID + '-rb', dlineID + '-rc', dlineID + '-rd'], {
  1194. width: '0px',
  1195. height: bHeight + 'px',
  1196. overflow: 'hidden',
  1197. borderLeft: '1px solid #303030',
  1198. borderRight: '1px solid #151515',
  1199. filter: 'alpha(opacity:0.9)',
  1200. opacity: '0.9'
  1201. });
  1202. this.css([dlineID + '-la', dlineID + '-lb', dlineID + '-lc'], 'float', 'left');
  1203. this.css([dlineID + '-ra', dlineID + '-rb', dlineID + '-rc', dlineID + '-rd'], 'float', 'right');
  1204. this.css([dlineID + '-lb', dlineID + '-lc', dlineID + '-rb', dlineID + '-rc'], 'display', 'none');
  1205. //播放/暂停/上一集/下一集按钮
  1206. this.css([playID, pauseID, frontID, nextID], {
  1207. width: bWidth + 'px',
  1208. height: bHeight + 'px',
  1209. float: 'left',
  1210. overflow: 'hidden',
  1211. cursor: 'pointer'
  1212. });
  1213. this.css([frontID, nextID], 'display', 'none');
  1214. //初始化判断播放/暂停按钮隐藏项
  1215. this.initPlayPause();
  1216. //设置静音/取消静音的按钮样式
  1217. this.css([muteID, escMuteID], {
  1218. width: bWidth + 'px',
  1219. height: bHeight + 'px',
  1220. float: 'right',
  1221. overflow: 'hidden',
  1222. cursor: 'pointer'
  1223. });
  1224. if(this.vars['volume'] > 0) {
  1225. this.css(escMuteID, 'display', 'none');
  1226. } else {
  1227. this.css(muteID, 'display', 'none');
  1228. }
  1229. //音量调节框
  1230. this.css([volumeID, volumeDbgID], {
  1231. width: '110px',
  1232. height: bHeight + 'px',
  1233. overflow: 'hidden',
  1234. float: 'right'
  1235. });
  1236. this.css(volumeDbgID, {
  1237. position: 'absolute'
  1238. });
  1239. this.css([volumeBgID, volumeUpID], {
  1240. width: '100px',
  1241. height: '6px',
  1242. overflow: 'hidden',
  1243. borderRadius: '5px',
  1244. cursor: 'pointer'
  1245. });
  1246. this.css(volumeBgID, {
  1247. position: 'absolute',
  1248. top: '16px'
  1249. });
  1250. this.css(volumeBgID, 'backgroundColor', '#666666');
  1251. this.css(volumeUpID, 'backgroundColor', bOverColor);
  1252. this.buttonWidth['volume'] = 100;
  1253. //音量调节按钮
  1254. this.css(volumeBOID, {
  1255. width: '12px',
  1256. height: '12px',
  1257. overflow: 'hidden',
  1258. borderRadius: '50%',
  1259. position: 'absolute',
  1260. backgroundColor: bBgColor,
  1261. top: '13px',
  1262. left: '0px',
  1263. cursor: 'pointer'
  1264. });
  1265. this.css(volumeBWID, {
  1266. width: '6px',
  1267. height: '6px',
  1268. overflow: 'hidden',
  1269. borderRadius: '50%',
  1270. position: 'absolute',
  1271. backgroundColor: bOverColor,
  1272. left: '3px',
  1273. top: '3px'
  1274. });
  1275. //清晰度容器
  1276. this.css(definitionID, {
  1277. lineHeight: bHeight + 'px',
  1278. color: '#FFFFFF',
  1279. float: 'right',
  1280. fontSize: '14px',
  1281. textAlign: 'center',
  1282. overflow: 'hidden',
  1283. display: 'none',
  1284. cursor: 'pointer'
  1285. });
  1286. this.css(definitionPID, {
  1287. lineHeight: (bHeight - 8) + 'px',
  1288. color: '#FFFFFF',
  1289. overflow: 'hidden',
  1290. position: 'absolute',
  1291. bottom: '4px',
  1292. backgroundColor: '#000000',
  1293. textAlign: 'center',
  1294. zIndex: '95',
  1295. cursor: 'pointer',
  1296. display: 'none'
  1297. });
  1298. //倍速容器
  1299. this.css(playbackRateID, {
  1300. lineHeight: bHeight + 'px',
  1301. color: '#FFFFFF',
  1302. float: 'right',
  1303. fontSize: '14px',
  1304. textAlign: 'center',
  1305. overflow: 'hidden',
  1306. display: 'none',
  1307. cursor: 'pointer'
  1308. });
  1309. this.css(playbackRatePID, {
  1310. lineHeight: (bHeight - 8) + 'px',
  1311. color: '#FFFFFF',
  1312. overflow: 'hidden',
  1313. position: 'absolute',
  1314. bottom: '4px',
  1315. backgroundColor: '#000000',
  1316. textAlign: 'center',
  1317. zIndex: '95',
  1318. cursor: 'pointer',
  1319. display: 'none'
  1320. });
  1321. //设置全屏/退出全屏按钮样式
  1322. this.css([fullID, escFullID], {
  1323. width: bWidth + 'px',
  1324. height: bHeight + 'px',
  1325. float: 'right',
  1326. overflow: 'hidden',
  1327. cursor: 'pointer'
  1328. });
  1329. this.css(escFullID, 'display', 'none');
  1330. //构建各按钮的形状
  1331. //播放按钮
  1332. var cPlay = this.getByElement(playID + '-canvas').getContext('2d');
  1333. var cPlayFillRect = function() {
  1334. thisTemp.canvasFill(cPlay, [
  1335. [12, 10],
  1336. [29, 19],
  1337. [12, 28]
  1338. ]);
  1339. };
  1340. cPlay.fillStyle = bBgColor;
  1341. cPlayFillRect();
  1342. var cPlayOver = function(event) {
  1343. cPlay.clearRect(0, 0, bWidth, bHeight);
  1344. cPlay.fillStyle = bOverColor;
  1345. cPlayFillRect();
  1346. };
  1347. var cPlayOut = function(event) {
  1348. cPlay.clearRect(0, 0, bWidth, bHeight);
  1349. cPlay.fillStyle = bBgColor;
  1350. cPlayFillRect();
  1351. };
  1352. this.addListenerInside('mouseover', cPlayOver, this.getByElement(playID + '-canvas'));
  1353. this.addListenerInside('mouseout', cPlayOut, this.getByElement(playID + '-canvas'));
  1354. //暂停按钮
  1355. var cPause = this.getByElement(pauseID + '-canvas').getContext('2d');
  1356. var cPauseFillRect = function() {
  1357. thisTemp.canvasFillRect(cPause, [
  1358. [10, 10, 5, 18],
  1359. [22, 10, 5, 18]
  1360. ]);
  1361. };
  1362. cPause.fillStyle = bBgColor;
  1363. cPauseFillRect();
  1364. var cPauseOver = function(event) {
  1365. cPause.clearRect(0, 0, bWidth, bHeight);
  1366. cPause.fillStyle = bOverColor;
  1367. cPauseFillRect();
  1368. };
  1369. var cPauseOut = function(event) {
  1370. cPause.clearRect(0, 0, bWidth, bHeight);
  1371. cPause.fillStyle = bBgColor;
  1372. cPauseFillRect();
  1373. };
  1374. this.addListenerInside('mouseover', cPauseOver, this.getByElement(pauseID + '-canvas'));
  1375. this.addListenerInside('mouseout', cPauseOut, this.getByElement(pauseID + '-canvas'));
  1376. //前一集按钮
  1377. var cFront = this.getByElement(frontID + '-canvas').getContext('2d');
  1378. var cFrontFillRect = function() {
  1379. thisTemp.canvasFill(cFront, [
  1380. [16, 19],
  1381. [30, 10],
  1382. [30, 28]
  1383. ]);
  1384. thisTemp.canvasFillRect(cFront, [
  1385. [8, 10, 5, 18]
  1386. ]);
  1387. };
  1388. cFront.fillStyle = bBgColor;
  1389. cFrontFillRect();
  1390. var cFrontOver = function(event) {
  1391. cFront.clearRect(0, 0, bWidth, bHeight);
  1392. cFront.fillStyle = bOverColor;
  1393. cFrontFillRect();
  1394. };
  1395. var cFrontOut = function(event) {
  1396. cFront.clearRect(0, 0, bWidth, bHeight);
  1397. cFront.fillStyle = bBgColor;
  1398. cFrontFillRect();
  1399. };
  1400. this.addListenerInside('mouseover', cFrontOver, this.getByElement(frontID + '-canvas'));
  1401. this.addListenerInside('mouseout', cFrontOut, this.getByElement(frontID + '-canvas'));
  1402. //下一集按钮
  1403. var cNext = this.getByElement(nextID + '-canvas').getContext('2d');
  1404. var cNextFillRect = function() {
  1405. thisTemp.canvasFill(cNext, [
  1406. [8, 10],
  1407. [22, 19],
  1408. [8, 28]
  1409. ]);
  1410. thisTemp.canvasFillRect(cNext, [
  1411. [25, 10, 5, 18]
  1412. ]);
  1413. };
  1414. cNext.fillStyle = bBgColor;
  1415. cNextFillRect();
  1416. var cNextOver = function(event) {
  1417. cNext.clearRect(0, 0, bWidth, bHeight);
  1418. cNext.fillStyle = bOverColor;
  1419. cNextFillRect();
  1420. };
  1421. var cNextOut = function(event) {
  1422. cNext.clearRect(0, 0, bWidth, bHeight);
  1423. cNext.fillStyle = bBgColor;
  1424. cNextFillRect();
  1425. };
  1426. this.addListenerInside('mouseover', cNextOver, this.getByElement(nextID + '-canvas'));
  1427. this.addListenerInside('mouseout', cNextOut, this.getByElement(nextID + '-canvas'));
  1428. //全屏按钮
  1429. var cFull = this.getByElement(fullID + '-canvas').getContext('2d');
  1430. var cFullFillRect = function() {
  1431. thisTemp.canvasFillRect(cFull, [
  1432. [19, 10, 9, 3],
  1433. [25, 13, 3, 6],
  1434. [10, 19, 3, 9],
  1435. [13, 25, 6, 3]
  1436. ]);
  1437. };
  1438. cFull.fillStyle = bBgColor;
  1439. cFullFillRect();
  1440. var cFullOver = function() {
  1441. cFull.clearRect(0, 0, bWidth, bHeight);
  1442. cFull.fillStyle = bOverColor;
  1443. cFullFillRect();
  1444. };
  1445. var cFullOut = function() {
  1446. cFull.clearRect(0, 0, bWidth, bHeight);
  1447. cFull.fillStyle = bBgColor;
  1448. cFullFillRect();
  1449. };
  1450. this.addListenerInside('mouseover', cFullOver, this.getByElement(fullID + '-canvas'));
  1451. this.addListenerInside('mouseout', cFullOut, this.getByElement(fullID + '-canvas'));
  1452. //定义退出全屏按钮样式
  1453. var cEscFull = this.getByElement(escFullID + '-canvas').getContext('2d');
  1454. var cEscFullFillRect = function() {
  1455. thisTemp.canvasFillRect(cEscFull, [
  1456. [20, 9, 3, 9],
  1457. [23, 15, 6, 3],
  1458. [9, 20, 9, 3],
  1459. [15, 23, 3, 6]
  1460. ]);
  1461. };
  1462. cEscFull.fillStyle = bBgColor;
  1463. cEscFullFillRect();
  1464. var cEscFullOver = function() {
  1465. cEscFull.clearRect(0, 0, bWidth, bHeight);
  1466. cEscFull.fillStyle = bOverColor;
  1467. cEscFullFillRect();
  1468. };
  1469. var cEscFullOut = function() {
  1470. cEscFull.clearRect(0, 0, bWidth, bHeight);
  1471. cEscFull.fillStyle = bBgColor;
  1472. cEscFullFillRect();
  1473. };
  1474. this.addListenerInside('mouseover', cEscFullOver, this.getByElement(escFullID + '-canvas'));
  1475. this.addListenerInside('mouseout', cEscFullOut, this.getByElement(escFullID + '-canvas'));
  1476. //定义全屏按钮的样式
  1477. var cMute = this.getByElement(muteID + '-canvas').getContext('2d');
  1478. var cMuteFillRect = function() {
  1479. thisTemp.canvasFill(cMute, [
  1480. [10, 15],
  1481. [15, 15],
  1482. [21, 10],
  1483. [21, 28],
  1484. [15, 23],
  1485. [10, 23]
  1486. ]);
  1487. thisTemp.canvasFillRect(cMute, [
  1488. [23, 15, 2, 8],
  1489. [27, 10, 2, 18]
  1490. ]);
  1491. };
  1492. cMute.fillStyle = bBgColor;
  1493. cMuteFillRect();
  1494. var cMuteOver = function() {
  1495. cMute.clearRect(0, 0, bWidth, bHeight);
  1496. cMute.fillStyle = bOverColor;
  1497. cMuteFillRect();
  1498. };
  1499. var cMuteOut = function() {
  1500. cMute.clearRect(0, 0, bWidth, bHeight);
  1501. cMute.fillStyle = bBgColor;
  1502. cMuteFillRect();
  1503. };
  1504. this.addListenerInside('mouseover', cMuteOver, this.getByElement(muteID + '-canvas'));
  1505. this.addListenerInside('mouseout', cMuteOut, this.getByElement(muteID + '-canvas'));
  1506. //定义退出全屏按钮样式
  1507. var cEscMute = this.getByElement(escMuteID + '-canvas').getContext('2d');
  1508. var cEscMuteFillRect = function() {
  1509. thisTemp.canvasFill(cEscMute, [
  1510. [10, 15],
  1511. [15, 15],
  1512. [21, 10],
  1513. [21, 28],
  1514. [15, 23],
  1515. [10, 23]
  1516. ]);
  1517. thisTemp.canvasFill(cEscMute, [
  1518. [23, 13],
  1519. [24, 13],
  1520. [33, 25],
  1521. [32, 25]
  1522. ]);
  1523. thisTemp.canvasFill(cEscMute, [
  1524. [32, 13],
  1525. [33, 13],
  1526. [24, 25],
  1527. [23, 25]
  1528. ]);
  1529. };
  1530. cEscMute.fillStyle = bBgColor;
  1531. cEscMuteFillRect();
  1532. var cEscMuteOver = function() {
  1533. cEscMute.clearRect(0, 0, bWidth, bHeight);
  1534. cEscMute.fillStyle = bOverColor;
  1535. cEscMuteFillRect();
  1536. };
  1537. var cEscMuteOut = function() {
  1538. cEscMute.clearRect(0, 0, bWidth, bHeight);
  1539. cEscMute.fillStyle = bBgColor;
  1540. cEscMuteFillRect();
  1541. };
  1542. this.addListenerInside('mouseover', cEscMuteOver, this.getByElement(escMuteID + '-canvas'));
  1543. this.addListenerInside('mouseout', cEscMuteOut, this.getByElement(escMuteID + '-canvas'));
  1544. //定义loading样式
  1545. var cLoading = this.getByElement(loadingID + '-canvas').getContext('2d');
  1546. var cLoadingFillRect = function() {
  1547. cLoading.save();
  1548. var grad = cLoading.createLinearGradient(0, 0, 60, 60);
  1549. grad.addColorStop(0, bBgColor);
  1550. var grad2 = cLoading.createLinearGradient(0, 0, 80, 60);
  1551. grad2.addColorStop(1, bOverColor);
  1552. var grad3 = cLoading.createLinearGradient(0, 0, 80, 60);
  1553. grad3.addColorStop(1, '#FF9900');
  1554. var grad4 = cLoading.createLinearGradient(0, 0, 80, 60);
  1555. grad4.addColorStop(1, '#CC3300');
  1556. cLoading.strokeStyle = grad; //设置描边样式
  1557. cLoading.lineWidth = 8; //设置线宽
  1558. cLoading.beginPath(); //路径开始
  1559. cLoading.arc(30, 30, 25, 0, 0.4 * Math.PI, false); //用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
  1560. cLoading.stroke(); //绘制
  1561. cLoading.closePath(); //路径结束
  1562. cLoading.beginPath(); //路径开始
  1563. cLoading.strokeStyle = grad2; //设置描边样式
  1564. cLoading.arc(30, 30, 25, 0.5 * Math.PI, 0.9 * Math.PI, false); //用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
  1565. cLoading.stroke(); //绘制
  1566. cLoading.beginPath(); //路径开始
  1567. cLoading.strokeStyle = grad3; //设置描边样式
  1568. cLoading.arc(30, 30, 25, Math.PI, 1.4 * Math.PI, false); //用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
  1569. cLoading.stroke(); //绘制
  1570. cLoading.beginPath(); //路径开始
  1571. cLoading.strokeStyle = grad4; //设置描边样式
  1572. cLoading.arc(30, 30, 25, 1.5 * Math.PI, 1.9 * Math.PI, false); //用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
  1573. cLoading.stroke(); //绘制
  1574. cLoading.closePath(); //路径结束
  1575. cLoading.restore();
  1576. };
  1577. cLoading.fillStyle = bBgColor;
  1578. cLoadingFillRect();
  1579. //定义中间暂停按钮的样式
  1580. var cPauseCenter = this.getByElement(pauseCenterID + '-canvas').getContext('2d');
  1581. var cPauseCenterFillRect = function() {
  1582. thisTemp.canvasFill(cPauseCenter, [
  1583. [28, 22],
  1584. [59, 38],
  1585. [28, 58]
  1586. ]);
  1587. /* 指定几个颜色 */
  1588. cPauseCenter.save();
  1589. cPauseCenter.lineWidth = 5; //设置线宽
  1590. cPauseCenter.beginPath(); //路径开始
  1591. cPauseCenter.arc(40, 40, 35, 0, 2 * Math.PI, false); //用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
  1592. cPauseCenter.stroke(); //绘制
  1593. cPauseCenter.closePath(); //路径结束
  1594. cPauseCenter.restore();
  1595. };
  1596. cPauseCenter.fillStyle = bBgColor;
  1597. cPauseCenter.strokeStyle = bBgColor;
  1598. cPauseCenterFillRect();
  1599. var cPauseCenterOver = function() {
  1600. cPauseCenter.clearRect(0, 0, 80, 80);
  1601. cPauseCenter.fillStyle = bOverColor;
  1602. cPauseCenter.strokeStyle = bOverColor;
  1603. cPauseCenterFillRect();
  1604. };
  1605. var cPauseCenterOut = function() {
  1606. cPauseCenter.clearRect(0, 0, 80, 80);
  1607. cPauseCenter.fillStyle = bBgColor;
  1608. cPauseCenter.strokeStyle = bBgColor;
  1609. cPauseCenterFillRect();
  1610. };
  1611. this.addListenerInside('mouseover', cPauseCenterOver, this.getByElement(pauseCenterID + '-canvas'));
  1612. this.addListenerInside('mouseout', cPauseCenterOut, this.getByElement(pauseCenterID + '-canvas'));
  1613. //鼠标经过/离开音量调节按钮
  1614. var volumeBOOver = function() {
  1615. thisTemp.css(volumeBOID, 'backgroundColor', bOverColor);
  1616. thisTemp.css(volumeBWID, 'backgroundColor', bBgColor);
  1617. };
  1618. var volumeBOOut = function() {
  1619. thisTemp.css(volumeBOID, 'backgroundColor', bBgColor);
  1620. thisTemp.css(volumeBWID, 'backgroundColor', bOverColor);
  1621. };
  1622. this.addListenerInside('mouseover', volumeBOOver, this.getByElement(volumeBOID));
  1623. this.addListenerInside('mouseout', volumeBOOut, this.getByElement(volumeBOID));
  1624. //鼠标经过/离开进度按钮
  1625. var timeBOOver = function() {
  1626. thisTemp.css(timeBOID, 'backgroundColor', bOverColor);
  1627. thisTemp.css(timeBWID, 'backgroundColor', bBgColor);
  1628. };
  1629. var timeBOOut = function() {
  1630. thisTemp.css(timeBOID, 'backgroundColor', bBgColor);
  1631. thisTemp.css(timeBWID, 'backgroundColor', bOverColor);
  1632. };
  1633. this.addListenerInside('mouseover', timeBOOver, this.getByElement(timeBOID));
  1634. this.addListenerInside('mouseout', timeBOOut, this.getByElement(timeBOID));
  1635. this.addButtonEvent(); //注册按钮及音量调节,进度操作事件
  1636. this.newMenu(); //单独设置右键的样式和事件
  1637. this.controlBarHide(); //单独注册控制栏隐藏事件
  1638. this.keypress(); //单独注册键盘事件
  1639. //初始化音量调节框
  1640. this.changeVolume(this.vars['volume']);
  1641. //初始化判断是否需要显示上一集和下一集按钮
  1642. this.showFrontNext();
  1643. window.setTimeout(function() {
  1644. thisTemp.elementCoordinate(); //调整中间暂停按钮/loading的位置/error的位置
  1645. }, 100);
  1646. this.checkBarWidth();
  1647. var resize = function() {
  1648. thisTemp.elementCoordinate();
  1649. thisTemp.timeUpdateHandler();
  1650. thisTemp.changeLoad();
  1651. thisTemp.checkBarWidth();
  1652. thisTemp.changeElementCoor(); //修改新加元件的坐标
  1653. thisTemp.changePrompt();
  1654. };
  1655. this.addListenerInside('resize', resize, window);
  1656. },
  1657. /*
  1658. 内部函数
  1659. 创建按钮,使用canvas画布
  1660. */
  1661. newCanvas: function(id, width, height) {
  1662. return '<canvas class="' + id + '-canvas" width="' + width + '" height="' + height + '"></canvas>';
  1663. },
  1664. /*
  1665. 内部函数
  1666. 注册按钮,音量调节框,进度操作框事件
  1667. */
  1668. addButtonEvent: function() {
  1669. var thisTemp = this;
  1670. //定义按钮的单击事件
  1671. var playClick = function(event) {
  1672. thisTemp.videoPlay();
  1673. thisTemp.sendJS('clickEvent', 'actionScript->videoPlay');
  1674. };
  1675. this.addListenerInside('click', playClick, this.CB['play']);
  1676. this.addListenerInside('click', playClick, this.CB['pauseCenter']);
  1677. var pauseClick = function(event) {
  1678. thisTemp.videoPause();
  1679. thisTemp.sendJS('clickEvent', 'actionScript->videoPause');
  1680. };
  1681. this.addListenerInside('click', pauseClick, this.CB['pause']);
  1682. var frontClick = function(event) {
  1683. if(thisTemp.vars['front']) {
  1684. eval(thisTemp.vars['front'] + '()');
  1685. thisTemp.sendJS('clickEvent', 'actionScript->' + thisTemp.vars['front']);
  1686. }
  1687. };
  1688. this.addListenerInside('click', frontClick, this.CB['front']);
  1689. var nextClick = function(event) {
  1690. if(thisTemp.vars['next']) {
  1691. eval(thisTemp.vars['next'] + '()');
  1692. thisTemp.sendJS('clickEvent', 'actionScript->' + thisTemp.vars['next']);
  1693. }
  1694. };
  1695. this.addListenerInside('click', nextClick, this.CB['next']);
  1696. var muteClick = function(event) {
  1697. thisTemp.videoMute();
  1698. thisTemp.sendJS('clickEvent', 'actionScript->videoMute');
  1699. };
  1700. this.addListenerInside('click', muteClick, this.CB['mute']);
  1701. var escMuteClick = function(event) {
  1702. thisTemp.videoEscMute();
  1703. thisTemp.sendJS('clickEvent', 'actionScript->videoEscMute');
  1704. };
  1705. this.addListenerInside('click', escMuteClick, this.CB['escMute']);
  1706. var fullClick = function(event) {
  1707. thisTemp.fullScreen();
  1708. thisTemp.sendJS('clickEvent', 'actionScript->fullScreen');
  1709. };
  1710. this.addListenerInside('click', fullClick, this.CB['full']);
  1711. var escFullClick = function(event) {
  1712. thisTemp.quitFullScreen();
  1713. thisTemp.sendJS('clickEvent', 'actionScript->quitFullScreen');
  1714. };
  1715. this.addListenerInside('click', escFullClick, this.CB['escFull']);
  1716. //定义各个按钮的鼠标经过/离开事件
  1717. var promptHide = function(event) {
  1718. thisTemp.promptShow(false);
  1719. };
  1720. var playOver = function(event) {
  1721. thisTemp.promptShow(thisTemp.CB['play']);
  1722. };
  1723. this.addListenerInside('mouseover', playOver, this.CB['play']);
  1724. this.addListenerInside('mouseout', promptHide, this.CB['play']);
  1725. var pauseOver = function(event) {
  1726. thisTemp.promptShow(thisTemp.CB['pause']);
  1727. };
  1728. this.addListenerInside('mouseover', pauseOver, this.CB['pause']);
  1729. this.addListenerInside('mouseout', promptHide, this.CB['pause']);
  1730. var frontOver = function(event) {
  1731. thisTemp.promptShow(thisTemp.CB['front']);
  1732. };
  1733. this.addListenerInside('mouseover', frontOver, this.CB['front']);
  1734. this.addListenerInside('mouseout', promptHide, this.CB['front']);
  1735. var nextOver = function(event) {
  1736. thisTemp.promptShow(thisTemp.CB['next']);
  1737. };
  1738. this.addListenerInside('mouseover', nextOver, this.CB['next']);
  1739. this.addListenerInside('mouseout', promptHide, this.CB['next']);
  1740. var muteOver = function(event) {
  1741. thisTemp.promptShow(thisTemp.CB['mute']);
  1742. };
  1743. this.addListenerInside('mouseover', muteOver, this.CB['mute']);
  1744. this.addListenerInside('mouseout', promptHide, this.CB['mute']);
  1745. var escMuteOver = function(event) {
  1746. thisTemp.promptShow(thisTemp.CB['escMute']);
  1747. };
  1748. this.addListenerInside('mouseover', escMuteOver, this.CB['escMute']);
  1749. this.addListenerInside('mouseout', promptHide, this.CB['escMute']);
  1750. var fullOver = function(event) {
  1751. thisTemp.promptShow(thisTemp.CB['full']);
  1752. };
  1753. this.addListenerInside('mouseover', fullOver, this.CB['full']);
  1754. this.addListenerInside('mouseout', promptHide, this.CB['full']);
  1755. var escFullOver = function(event) {
  1756. thisTemp.promptShow(thisTemp.CB['escFull']);
  1757. };
  1758. this.addListenerInside('mouseover', escFullOver, this.CB['escFull']);
  1759. this.addListenerInside('mouseout', promptHide, this.CB['escFull']);
  1760. var definitionOver = function(event) {
  1761. thisTemp.promptShow(thisTemp.CB['definition']);
  1762. };
  1763. this.addListenerInside('mouseover', definitionOver, this.CB['definition']);
  1764. this.addListenerInside('mouseout', promptHide, this.CB['definition']);
  1765. var playbackrateOver = function(event) {
  1766. thisTemp.promptShow(thisTemp.CB['playbackrate']);
  1767. };
  1768. this.addListenerInside('mouseover', playbackrateOver, this.CB['playbackrate']);
  1769. this.addListenerInside('mouseout', promptHide, this.CB['playbackrate']);
  1770. //定义音量和进度按钮的滑块事件
  1771. var volumePrompt = function(vol) {
  1772. var volumeBOXY = thisTemp.getCoor(thisTemp.CB['volumeBO']);
  1773. var promptObj = {
  1774. title: thisTemp.language['volume'] + vol + '%',
  1775. x: volumeBOXY['x'] + thisTemp.CB['volumeBO'].offsetWidth * 0.5,
  1776. y: volumeBOXY['y']
  1777. };
  1778. thisTemp.promptShow(false, promptObj);
  1779. };
  1780. var volumeObj = {
  1781. slider: this.CB['volumeBO'],
  1782. follow: this.CB['volumeUp'],
  1783. refer: this.CB['volumeBg'],
  1784. grossValue: 'volume',
  1785. pd: true,
  1786. startFun: function(vol) {},
  1787. monitorFun: function(vol) {
  1788. thisTemp.changeVolume(vol * 0.01, false, false);
  1789. volumePrompt(vol);
  1790. },
  1791. endFun: function(vol) {},
  1792. overFun: function(vol) {
  1793. volumePrompt(vol);
  1794. }
  1795. };
  1796. this.slider(volumeObj);
  1797. var volumeClickObj = {
  1798. refer: this.CB['volumeBg'],
  1799. grossValue: 'volume',
  1800. fun: function(vol) {
  1801. thisTemp.changeVolume(vol * 0.01, true, true);
  1802. }
  1803. };
  1804. this.progressClick(volumeClickObj);
  1805. this.timeButtonMouseDown(); //用单击的函数来判断是否需要建立控制栏监听
  1806. //鼠标经过/离开音量调节框时的
  1807. var volumeBgMove = function(event) {
  1808. var volumeBgXY = thisTemp.getCoor(thisTemp.CB['volumeBg']);
  1809. var eventX = thisTemp.client(event)['x'];
  1810. var eventVolume = parseInt((eventX - volumeBgXY['x']) * 100 / thisTemp.CB['volumeBg'].offsetWidth);
  1811. var buttonPromptObj = {
  1812. title: thisTemp.language['volume'] + eventVolume + '%',
  1813. x: eventX,
  1814. y: volumeBgXY['y']
  1815. };
  1816. thisTemp.promptShow(false, buttonPromptObj);
  1817. };
  1818. this.addListenerInside('mousemove', volumeBgMove, this.CB['volumeBg']);
  1819. this.addListenerInside('mouseout', promptHide, this.CB['volumeBg']);
  1820. this.addListenerInside('mouseout', promptHide, this.CB['volumeBO']);
  1821. //注册清晰度相关事件
  1822. this.addDefListener();
  1823. //注册倍速相关事件
  1824. this.addPlaybackrate();
  1825. },
  1826. /*
  1827. 内部函数
  1828. 注册单击视频动作
  1829. */
  1830. videoClick: function() {
  1831. var thisTemp = this;
  1832. var clearTimerClick = function() {
  1833. if(thisTemp.timerClick != null) {
  1834. if(thisTemp.timerClick.runing) {
  1835. thisTemp.timerClick.stop();
  1836. }
  1837. thisTemp.timerClick = null;
  1838. }
  1839. };
  1840. var timerClickFun = function() {
  1841. clearTimerClick();
  1842. thisTemp.isClick = false;
  1843. thisTemp.playOrPause();
  1844. };
  1845. clearTimerClick();
  1846. if(this.isClick) {
  1847. this.isClick = false;
  1848. if(thisTemp.config['videoDbClick']) {
  1849. if(!this.full) {
  1850. thisTemp.fullScreen();
  1851. } else {
  1852. thisTemp.quitFullScreen();
  1853. }
  1854. }
  1855. } else {
  1856. this.isClick = true;
  1857. this.timerClick = new this.timer(300, timerClickFun, 1)
  1858. //this.timerClick.start();
  1859. }
  1860. },
  1861. /*
  1862. 内部函数
  1863. 注册鼠标经过进度滑块的事件
  1864. */
  1865. timeButtonMouseDown: function() {
  1866. var thisTemp = this;
  1867. var timePrompt = function(time) {
  1868. if(isNaN(time)) {
  1869. time = 0;
  1870. }
  1871. var timeButtonXY = thisTemp.getCoor(thisTemp.CB['timeButton']);
  1872. var promptObj = {
  1873. title: thisTemp.formatTime(time),
  1874. x: timeButtonXY['x'] - thisTemp.pdCoor['x'] + thisTemp.CB['timeButton'].offsetWidth * 0.5,
  1875. y: timeButtonXY['y'] - thisTemp.pdCoor['y']
  1876. };
  1877. thisTemp.promptShow(false, promptObj);
  1878. };
  1879. var timeObj = {
  1880. slider: this.CB['timeButton'],
  1881. follow: this.CB['timeProgress'],
  1882. refer: this.CB['timeBoBg'],
  1883. grossValue: 'time',
  1884. pd: false,
  1885. startFun: function(time) {
  1886. thisTemp.isTimeButtonMove = false;
  1887. },
  1888. monitorFun: function(time) {},
  1889. endFun: function(time) {
  1890. if(thisTemp.V) {
  1891. if(thisTemp.V.duration > 0) {
  1892. thisTemp.needSeek = 0;
  1893. thisTemp.videoSeek(parseInt(time));
  1894. }
  1895. }
  1896. },
  1897. overFun: function(time) {
  1898. timePrompt(time);
  1899. }
  1900. };
  1901. var timeClickObj = {
  1902. refer: this.CB['timeBoBg'],
  1903. grossValue: 'time',
  1904. fun: function(time) {
  1905. if(thisTemp.V) {
  1906. if(thisTemp.V.duration > 0) {
  1907. thisTemp.needSeek = 0;
  1908. thisTemp.videoSeek(parseInt(time));
  1909. }
  1910. }
  1911. }
  1912. };
  1913. var timeBoBgmousemove = function(event) {
  1914. var timeBoBgXY = thisTemp.getCoor(thisTemp.CB['timeBoBg']);
  1915. var eventX = thisTemp.client(event)['x'];
  1916. var eventTime = parseInt((eventX - timeBoBgXY['x']) * thisTemp.V.duration / thisTemp.CB['timeBoBg'].offsetWidth);
  1917. var buttonPromptObj = {
  1918. title: thisTemp.formatTime(eventTime),
  1919. x: eventX,
  1920. y: timeBoBgXY['y']
  1921. };
  1922. thisTemp.promptShow(false, buttonPromptObj);
  1923. var def = false;
  1924. if(!thisTemp.isUndefined(thisTemp.CB['definitionP'])) {
  1925. if(thisTemp.css(thisTemp.CB['definitionP'], 'display') != 'block') {
  1926. def = true;
  1927. }
  1928. }
  1929. if(thisTemp.vars['preview'] != null && def) {
  1930. buttonPromptObj['time'] = eventTime;
  1931. thisTemp.preview(buttonPromptObj);
  1932. }
  1933. };
  1934. var promptHide = function(event) {
  1935. thisTemp.promptShow(false);
  1936. if(thisTemp.previewDiv != null) {
  1937. thisTemp.css([thisTemp.previewDiv, thisTemp.previewTop], 'display', 'none');
  1938. }
  1939. };
  1940. if(!this.vars['live']) { //如果不是直播
  1941. this.isTimeButtonDown = true;
  1942. this.addListenerInside('mousemove', timeBoBgmousemove, this.CB['timeBoBg']);
  1943. this.addListenerInside('mouseout', promptHide, this.CB['timeBoBg']);
  1944. } else {
  1945. this.isTimeButtonDown = false;
  1946. timeObj['removeListenerInside'] = true;
  1947. timeClickObj['removeListenerInside'] = true;
  1948. }
  1949. this.slider(timeObj);
  1950. this.progressClick(timeClickObj);
  1951. },
  1952. /*
  1953. 内部函数
  1954. 注册调节框上单击事件,包含音量调节框和播放时度调节框
  1955. */
  1956. progressClick: function(obj) {
  1957. /*
  1958. refer:参考对象
  1959. fun:返回函数
  1960. refer:参考元素,即背景
  1961. grossValue:调用的参考值类型
  1962. pd:
  1963. */
  1964. //建立参考元素的mouseClick事件,用来做为鼠标在其上按下时触发的状态
  1965. var thisTemp = this;
  1966. var referMouseClick = function(event) {
  1967. var referX = thisTemp.client(event)['x'] - thisTemp.getCoor(obj['refer'])['x'];
  1968. var rWidth = obj['refer'].offsetWidth;
  1969. var grossValue = 0;
  1970. if(obj['grossValue'] == 'volume') {
  1971. grossValue = 100;
  1972. } else {
  1973. if(thisTemp.V) {
  1974. grossValue = thisTemp.V.duration;
  1975. }
  1976. }
  1977. var nowZ = parseInt(referX * grossValue / rWidth);
  1978. if(obj['fun']) {
  1979. if(obj['grossValue'] === 'time') {
  1980. var sliderXY = thisTemp.getCoor(thisTemp.CB['timeButton']);
  1981. sliderLeft = sliderXY['x'];
  1982. if(!thisTemp.checkSlideLeft(referX, sliderLeft, rWidth)) {
  1983. return;
  1984. }
  1985. var bimeButtonWB = thisTemp.CB['timeButton'].offsetWidth * 0.5;
  1986. thisTemp.css(thisTemp.CB['timeButton'], 'left', (referX - bimeButtonWB) + 'px');
  1987. thisTemp.css(thisTemp.CB['timeProgress'], 'width', (referX) + 'px');
  1988. }
  1989. obj['fun'](nowZ);
  1990. }
  1991. };
  1992. if(this.isUndefined(obj['removeListenerInside'])) {
  1993. this.addListenerInside('click', referMouseClick, obj['refer']);
  1994. } else {
  1995. this.removeListenerInside('click', referMouseClick, obj['refer']);
  1996. }
  1997. },
  1998. /*
  1999. 内部函数
  2000. 共用的注册滑块事件
  2001. */
  2002. slider: function(obj) {
  2003. /*
  2004. obj={
  2005. slider:滑块元素
  2006. follow:跟随滑块的元素
  2007. refer:参考元素,即背景
  2008. grossValue:调用的参考值类型
  2009. startFun:开始调用的元素
  2010. monitorFun:监听函数
  2011. endFun:结束调用的函数
  2012. overFun:鼠标放上去后调用的函数
  2013. pd:是否需要修正
  2014. }
  2015. */
  2016. var thisTemp = this;
  2017. var clientX = 0,
  2018. criterionWidth = 0,
  2019. sliderLeft = 0,
  2020. referLeft = 0;
  2021. var value = 0;
  2022. var calculation = function() { //根据滑块的left计算百分比
  2023. var sLeft = parseInt(thisTemp.css(obj['slider'], 'left'));
  2024. var rWidth = obj['refer'].offsetWidth - obj['slider'].offsetWidth;
  2025. var grossValue = 0;
  2026. if(thisTemp.isUndefined(sLeft) || isNaN(sLeft)) {
  2027. sLeft = 0;
  2028. }
  2029. if(obj['grossValue'] == 'volume') {
  2030. grossValue = 100;
  2031. } else {
  2032. if(thisTemp.V) {
  2033. grossValue = thisTemp.V.duration;
  2034. }
  2035. }
  2036. return parseInt(sLeft * grossValue / rWidth);
  2037. };
  2038. var mDown = function(event) {
  2039. thisTemp.addListenerInside('mousemove', mMove, document);
  2040. thisTemp.addListenerInside('mouseup', mUp, document);
  2041. var referXY = thisTemp.getCoor(obj['refer']);
  2042. var sliderXY = thisTemp.getCoor(obj['slider']);
  2043. clientX = thisTemp.client(event)['x'];
  2044. referLeft = referXY['x'];
  2045. sliderLeft = sliderXY['x'];
  2046. criterionWidth = clientX - sliderLeft;
  2047. if(obj['startFun']) {
  2048. obj['startFun'](calculation());
  2049. }
  2050. };
  2051. var mMove = function(event) {
  2052. clientX = thisTemp.client(event)['x'];
  2053. var newX = clientX - criterionWidth - referLeft;
  2054. if(newX < 0) {
  2055. newX = 0;
  2056. }
  2057. if(newX > obj['refer'].offsetWidth - obj['slider'].offsetWidth) {
  2058. newX = obj['refer'].offsetWidth - obj['slider'].offsetWidth;
  2059. }
  2060. if(obj['slider'] === thisTemp.CB['timeButton']) {
  2061. if(!thisTemp.checkSlideLeft(newX, sliderLeft, obj['refer'].offsetWidth)) {
  2062. return;
  2063. }
  2064. }
  2065. thisTemp.css(obj['slider'], 'left', newX + 'px');
  2066. thisTemp.css(obj['follow'], 'width', (newX + obj['slider'].offsetWidth * 0.5) + 'px');
  2067. var nowZ = calculation();
  2068. if(obj['monitorFun']) {
  2069. obj['monitorFun'](nowZ);
  2070. }
  2071. };
  2072. var mUp = function(event) {
  2073. thisTemp.removeListenerInside('mousemove', mMove, document);
  2074. thisTemp.removeListenerInside('mouseup', mUp, document);
  2075. if(obj['endFun']) {
  2076. obj['endFun'](calculation());
  2077. }
  2078. };
  2079. var mOver = function(event) {
  2080. if(obj['overFun']) {
  2081. obj['overFun'](calculation());
  2082. }
  2083. };
  2084. if(this.isUndefined(obj['removeListenerInside'])) {
  2085. this.addListenerInside('mousedown', mDown, obj['slider']);
  2086. this.addListenerInside('mouseover', mOver, obj['slider']);
  2087. } else {
  2088. this.removeListenerInside('mousedown', mDown, obj['slider']);
  2089. this.removeListenerInside('mouseover', mOver, obj['slider']);
  2090. }
  2091. },
  2092. /*
  2093. 内部函数
  2094. 判断是否可以拖动进度按钮或点击进度栏
  2095. */
  2096. checkSlideLeft: function(newX, sliderLeft, refer) {
  2097. var timeSA = this.ckplayerConfig['config']['timeScheduleAdjust'];
  2098. switch(timeSA) {
  2099. case 0:
  2100. return false;
  2101. break;
  2102. case 2:
  2103. if(newX < sliderLeft) {
  2104. return false;
  2105. }
  2106. break;
  2107. case 3:
  2108. if(newX > sliderLeft) {
  2109. return false;
  2110. }
  2111. break;
  2112. case 4:
  2113. if(!this.timeSliderLeftTemp) {
  2114. this.timeSliderLeftTemp = sliderLeft / refer;
  2115. }
  2116. if(newX < this.timeSliderLeftTemp * refer) {
  2117. return false;
  2118. }
  2119. break;
  2120. case 5:
  2121. if(!this.timeSliderLeftTemp) {
  2122. this.timeSliderLeftTemp = sliderLeft / refer;
  2123. } else {
  2124. var timeSliderMax = sliderLeft / refer;
  2125. if(timeSliderMax > this.timeSliderLeftTemp) {
  2126. this.timeSliderLeftTemp = timeSliderMax;
  2127. }
  2128. }
  2129. if(newX > this.timeSliderLeftTemp * refer) {
  2130. return false;
  2131. }
  2132. break;
  2133. default:
  2134. return true;
  2135. break;
  2136. }
  2137. return true;
  2138. },
  2139. /*
  2140. 内部函数
  2141. 显示loading
  2142. */
  2143. loadingStart: function(rot) {
  2144. var thisTemp = this;
  2145. if(this.isUndefined(rot)) {
  2146. rot = true;
  2147. }
  2148. if(this.showFace) {
  2149. this.css(thisTemp.CB['loading'], 'display', 'none');
  2150. }
  2151. if(this.timerLoading != null) {
  2152. if(this.timerLoading.runing) {
  2153. this.timerLoading.stop();
  2154. }
  2155. this.timerLoading = null;
  2156. }
  2157. var buffer = 0;
  2158. var loadingFun = function() {
  2159. var nowRotate = '0';
  2160. try {
  2161. nowRotate = thisTemp.css(thisTemp.CB['loadingCanvas'], 'transform') || thisTemp.css(thisTemp.CB['loadingCanvas'], '-ms-transform') || thisTemp.css(thisTemp.CB['loadingCanvas'], '-moz-transform') || thisTemp.css(thisTemp.CB['loadingCanvas'], '-webkit-transform') || thisTemp.css(thisTemp.CB['loadingCanvas'], '-o-transform') || '0';
  2162. } catch(event) {}
  2163. nowRotate = parseInt(nowRotate.replace('rotate(', '').replace('deg);', ''));
  2164. nowRotate += 4;
  2165. if(nowRotate > 360) {
  2166. nowRotate = 0;
  2167. }
  2168. if(thisTemp.showFace) {
  2169. thisTemp.css(thisTemp.CB['loadingCanvas'], {
  2170. transform: 'rotate(' + nowRotate + 'deg)',
  2171. msTransform: 'rotate(' + nowRotate + 'deg)',
  2172. mozTransform: 'rotate(' + nowRotate + 'deg)',
  2173. webkitTransform: 'rotate(' + nowRotate + 'deg)',
  2174. oTransform: 'rotate(' + nowRotate + 'deg)'
  2175. });
  2176. }
  2177. buffer++;
  2178. if(buffer >= 99) {
  2179. buffer = 99;
  2180. }
  2181. thisTemp.sendJS('buffer', buffer);
  2182. };
  2183. if(rot) {
  2184. this.timerLoading = new this.timer(10, loadingFun);
  2185. //this.timerLoading.start();
  2186. if(this.showFace) {
  2187. this.css(thisTemp.CB['loading'], 'display', 'block');
  2188. }
  2189. } else {
  2190. thisTemp.sendJS('buffer', 100);
  2191. }
  2192. },
  2193. /*
  2194. 内部函数
  2195. 判断是否需要显示上一集和下一集
  2196. */
  2197. showFrontNext: function() {
  2198. if(!this.showFace) {
  2199. return;
  2200. }
  2201. if(this.vars['front']) {
  2202. this.css([this.CB['front'], this.CB['frontLine']], 'display', 'block');
  2203. } else {
  2204. this.css([this.CB['front'], this.CB['frontLine']], 'display', 'none');
  2205. }
  2206. if(this.vars['next']) {
  2207. this.css([this.CB['next'], this.CB['nextLine']], 'display', 'block');
  2208. } else {
  2209. this.css([this.CB['next'], this.CB['nextLine']], 'display', 'none');
  2210. }
  2211. },
  2212. /*
  2213. 内部函数
  2214. 显示提示语
  2215. */
  2216. promptShow: function(ele, data) {
  2217. if(!this.showFace) {
  2218. return;
  2219. }
  2220. var obj = {};
  2221. if(ele || data) {
  2222. if(!this.isUndefined(data)) {
  2223. obj = data;
  2224. } else {
  2225. var offsetCoor = this.getCoor(ele);
  2226. obj = {
  2227. title: this.getDataset(ele, 'title'),
  2228. x: offsetCoor['x'] + ele.offsetWidth * 0.5,
  2229. y: offsetCoor['y']
  2230. };
  2231. }
  2232. this.CB['prompt'].innerHTML = obj['title'];
  2233. this.css(this.CB['prompt'], 'display', 'block');
  2234. var promoptWidth = this.getStringLen(obj['title']) * 10;
  2235. this.css(this.CB['promptBg'], 'width', promoptWidth + 'px');
  2236. this.css(this.CB['prompt'], 'width', promoptWidth + 'px');
  2237. promoptWidth += 10;
  2238. var x = obj['x'] - (promoptWidth * 0.5);
  2239. var y = this.PD.offsetHeight - obj['y'] + 8;
  2240. if(x < 0) {
  2241. x = 0;
  2242. }
  2243. if(x > this.PD.offsetWidth - promoptWidth) {
  2244. x = this.PD.offsetWidth - promoptWidth;
  2245. }
  2246. this.css([this.CB['promptBg'], this.CB['prompt']], {
  2247. display: 'block',
  2248. left: x + 'px',
  2249. bottom: y + 'px'
  2250. });
  2251. } else {
  2252. this.css([this.CB['promptBg'], this.CB['prompt']], {
  2253. display: 'none'
  2254. });
  2255. }
  2256. },
  2257. /*
  2258. 内部函数
  2259. 监听错误
  2260. */
  2261. timerErrorFun: function() {
  2262. var thisTemp = this;
  2263. this.errorSend = false;
  2264. var clearIntervalError = function(event) {
  2265. if(thisTemp.timerError != null) {
  2266. if(thisTemp.timerError.runing) {
  2267. thisTemp.timerError.stop();
  2268. }
  2269. thisTemp.timerError = null;
  2270. }
  2271. };
  2272. var errorFun = function(event) {
  2273. clearIntervalError();
  2274. thisTemp.error = true;
  2275. //提取错误播放地址
  2276. thisTemp.errorUrl = thisTemp.getVideoUrl();
  2277. //提取错误播放地址结束
  2278. if(!thisTemp.errorSend) {
  2279. thisTemp.errorSend = true;
  2280. thisTemp.sendJS('error');
  2281. }
  2282. if(thisTemp.showFace) {
  2283. thisTemp.css(thisTemp.CB['errorText'], 'display', 'block');
  2284. thisTemp.css(thisTemp.CB['pauseCenter'], 'display', 'none');
  2285. thisTemp.css(thisTemp.CB['loading'], 'display', 'none');
  2286. }
  2287. thisTemp.V.removeAttribute('poster');
  2288. thisTemp.resetPlayer();
  2289. };
  2290. var errorListenerFun = function(event) {
  2291. window.setTimeout(function() {
  2292. if(isNaN(thisTemp.V.duration)) {
  2293. errorFun(event);
  2294. }
  2295. }, 500);
  2296. };
  2297. if(!this.errorAdd) {
  2298. this.errorAdd = true;
  2299. this.addListenerInside('error', errorListenerFun, this.V);
  2300. }
  2301. clearIntervalError();
  2302. var timerErrorFun = function() {
  2303. if(thisTemp.V && parseInt(thisTemp.V.networkState) == 3) {
  2304. errorFun();
  2305. }
  2306. };
  2307. this.timerError = new this.timer(this.config['errorTime'], timerErrorFun);
  2308. //this.timerError.start();
  2309. },
  2310. /*
  2311. 内部函数
  2312. 构建判断全屏还是非全屏的判断
  2313. */
  2314. judgeFullScreen: function() {
  2315. var thisTemp = this;
  2316. if(this.timerFull != null) {
  2317. if(this.timerFull.runing) {
  2318. this.timerFull.stop();
  2319. }
  2320. this.timerFull = null;
  2321. }
  2322. var fullFun = function() {
  2323. thisTemp.isFullScreen();
  2324. };
  2325. this.timerFull = new this.timer(20, fullFun);
  2326. },
  2327. /*
  2328. 内部函数
  2329. 判断是否是全屏
  2330. */
  2331. isFullScreen: function() {
  2332. if(!this.showFace) {
  2333. return;
  2334. }
  2335. var fullState = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement;
  2336. if(fullState && !this.full) {
  2337. this.full = true;
  2338. this.sendJS('full', true);
  2339. this.elementCoordinate();
  2340. this.css(this.CB['full'], 'display', 'none');
  2341. this.css(this.CB['escFull'], 'display', 'block');
  2342. if(this.vars['live'] == 0) {
  2343. this.timeUpdateHandler();
  2344. }
  2345. this.PD.appendChild(this.CB['menu']);
  2346. }
  2347. if(!fullState && this.full) {
  2348. this.full = false;
  2349. this.sendJS('full', false);
  2350. this.elementCoordinate();
  2351. this.css(this.CB['full'], 'display', 'block');
  2352. this.css(this.CB['escFull'], 'display', 'none');
  2353. if(this.timerFull != null) {
  2354. if(this.timerFull.runing) {
  2355. this.timerFull.stop();
  2356. }
  2357. this.timerFull = null;
  2358. }
  2359. if(this.vars['live'] == 0) {
  2360. this.timeUpdateHandler();
  2361. }
  2362. this.body.appendChild(this.CB['menu']);
  2363. }
  2364. },
  2365. /*
  2366. 内部函数
  2367. 构建右键内容及注册相关动作事件
  2368. */
  2369. newMenu: function() {
  2370. var thisTemp = this;
  2371. var i = 0;
  2372. this.css(this.CB['menu'], {
  2373. backgroundColor: '#FFFFFF',
  2374. padding: '5px',
  2375. position: 'absolute',
  2376. left: '10px',
  2377. top: '20px',
  2378. display: 'none',
  2379. zIndex: '999',
  2380. color: '#A1A9BE',
  2381. boxShadow: '2px 2px 3px #AAAAAA'
  2382. });
  2383. var mArr = this.contextMenu;
  2384. var cMenu = this.ckplayerConfig['menu'];
  2385. if(cMenu['name']) {
  2386. if(cMenu['link']) {
  2387. mArr[0] = [cMenu['name'], 'link', cMenu['link']];
  2388. } else {
  2389. mArr[0] = [cMenu['name'], 'default'];
  2390. }
  2391. }
  2392. if(cMenu['version']) {
  2393. mArr[1] = [cMenu['version'], 'default', 'line'];
  2394. }
  2395. if(cMenu['more']) {
  2396. if(typeof(cMenu['more']) == 'object') {
  2397. if(cMenu['more'].length > 0) {
  2398. var moreArr = cMenu['more'];
  2399. for(i = 0; i < moreArr.length; i++) {
  2400. var mTemp = moreArr[i];
  2401. var arrTemp = [];
  2402. if(mTemp['name']) {
  2403. arrTemp.push(mTemp['name']);
  2404. }
  2405. if(mTemp['clickEvent'] && mTemp['clickEvent'] != 'none') {
  2406. var eveObj = this.clickEvent(mTemp['clickEvent']);
  2407. arrTemp.push(eveObj['type']);
  2408. if(eveObj['fun']) {
  2409. arrTemp.push(eveObj['fun']);
  2410. }
  2411. if(eveObj['link']) {
  2412. arrTemp.push(eveObj['link']);
  2413. }
  2414. if(eveObj['target']) {
  2415. arrTemp.push(' target="' + eveObj['target'] + '"');
  2416. }
  2417. }
  2418. if(mTemp['separatorBefore']) {
  2419. arrTemp.push('line');
  2420. }
  2421. mArr.push(arrTemp);
  2422. }
  2423. }
  2424. }
  2425. }
  2426. var html = '';
  2427. for(i = 0; i < mArr.length; i++) {
  2428. var me = mArr[i];
  2429. switch(me[1]) {
  2430. case 'default':
  2431. html += '<p>' + me[0] + '</p>';
  2432. break;
  2433. case 'link':
  2434. html += '<p><a href="' + me[2] + '"' + me[3] + '>' + me[0] + '</a></p>';
  2435. break;
  2436. case 'javaScript':
  2437. html += '<p><a href="javascript:' + me[2] + '">' + me[0] + '</a></p>';
  2438. break;
  2439. case 'actionScript':
  2440. html += '<p><a href="javascript:' + this.vars['variable'] + me[2].replace('thisTemp', '') + '">' + me[0] + '</a></p>';
  2441. break;
  2442. default:
  2443. break;
  2444. }
  2445. }
  2446. this.CB['menu'].innerHTML = html;
  2447. var pArr = this.CB['menu'].childNodes;
  2448. for(i = 0; i < pArr.length; i++) {
  2449. this.css(pArr[i], {
  2450. height: '30px',
  2451. lineHeight: '30px',
  2452. margin: '0px',
  2453. fontFamily: this.fontFamily,
  2454. fontSize: '12px',
  2455. paddingLeft: '10px',
  2456. paddingRight: '30px'
  2457. });
  2458. if(mArr[i][mArr[i].length - 1] == 'line') {
  2459. this.css(pArr[i], 'borderBottom', '1px solid #e9e9e9');
  2460. }
  2461. var aArr = pArr[i].childNodes;
  2462. for(var n = 0; n < aArr.length; n++) {
  2463. if(aArr[n].localName == 'a') {
  2464. this.css(aArr[n], {
  2465. color: '#000000',
  2466. textDecoration: 'none'
  2467. });
  2468. }
  2469. }
  2470. }
  2471. this.PD.oncontextmenu = function(event) {
  2472. var eve = event || window.event;
  2473. var client = thisTemp.client(event);
  2474. if(eve.button == 2) {
  2475. eve.returnvalue = false;
  2476. var x = client['x'] + thisTemp.pdCoor['x'] - 2;
  2477. var y = client['y'] + thisTemp.pdCoor['y'] - 2;
  2478. thisTemp.css(thisTemp.CB['menu'], {
  2479. display: 'block',
  2480. left: x + 'px',
  2481. top: y + 'px'
  2482. });
  2483. return false;
  2484. }
  2485. return true;
  2486. };
  2487. var setTimeOutPClose = function() {
  2488. if(setTimeOutP) {
  2489. window.clearTimeout(setTimeOutP);
  2490. setTimeOutP = null;
  2491. }
  2492. };
  2493. var setTimeOutP = null;
  2494. var mouseOut = function(event) {
  2495. setTimeOutPClose();
  2496. setTimeOutP = window.setTimeout(function(event) {
  2497. thisTemp.css(thisTemp.CB['menu'], 'display', 'none');
  2498. }, 500);
  2499. };
  2500. this.addListenerInside('mouseout', mouseOut, thisTemp.CB['menu']);
  2501. var mouseOver = function(event) {
  2502. setTimeOutPClose();
  2503. };
  2504. this.addListenerInside('mouseover', mouseOver, thisTemp.CB['menu']);
  2505. },
  2506. /*
  2507. 内部函数
  2508. 构建控制栏隐藏事件
  2509. */
  2510. controlBarHide: function(hide) {
  2511. var thisTemp = this;
  2512. var client = {
  2513. x: 0,
  2514. y: 0
  2515. },
  2516. oldClient = {
  2517. x: 0,
  2518. y: 0
  2519. };
  2520. var cShow = true,
  2521. force = false;
  2522. var oldCoor = [0, 0];
  2523. var controlBarShow = function(show) {
  2524. if(show && !cShow && thisTemp.controlBarIsShow) {
  2525. cShow = true;
  2526. thisTemp.sendJS('controlBar', true);
  2527. thisTemp.css(thisTemp.CB['controlBarBg'], 'display', 'block');
  2528. thisTemp.css(thisTemp.CB['controlBar'], 'display', 'block');
  2529. thisTemp.css(thisTemp.CB['timeProgressBg'], 'display', 'block');
  2530. thisTemp.css(thisTemp.CB['timeBoBg'], 'display', 'block');
  2531. thisTemp.changeVolume(thisTemp.volume);
  2532. thisTemp.changeLoad();
  2533. if(!thisTemp.timerBuffer) {
  2534. thisTemp.bufferEdHandler();
  2535. }
  2536. } else {
  2537. if(cShow) {
  2538. cShow = false;
  2539. var paused = thisTemp.getMetaDate()['paused'];
  2540. if(force) {
  2541. paused = false;
  2542. }
  2543. if(!paused) {
  2544. thisTemp.sendJS('controlBar', false);
  2545. thisTemp.css(thisTemp.CB['controlBarBg'], 'display', 'none');
  2546. thisTemp.css(thisTemp.CB['controlBar'], 'display', 'none');
  2547. thisTemp.css(thisTemp.CB['timeProgressBg'], 'display', 'none');
  2548. thisTemp.css(thisTemp.CB['timeBoBg'], 'display', 'none');
  2549. thisTemp.promptShow(false);
  2550. }
  2551. }
  2552. }
  2553. };
  2554. var cbarFun = function(event) {
  2555. if(client['x'] == oldClient['x'] && client['y'] == oldClient['y']) {
  2556. var cdH = parseInt(thisTemp.CD.offsetHeight);
  2557. if((client['y'] < cdH - 50 || client['y'] > cdH - 2) && cShow) {
  2558. controlBarShow(false);
  2559. }
  2560. } else {
  2561. if(!cShow) {
  2562. controlBarShow(true);
  2563. }
  2564. }
  2565. oldClient = {
  2566. x: client['x'],
  2567. y: client['y']
  2568. }
  2569. };
  2570. this.timerCBar = new this.timer(2000, cbarFun);
  2571. var cdMove = function(event) {
  2572. var getClient = thisTemp.client(event);
  2573. client['x'] = getClient['x'];
  2574. client['y'] = getClient['y'];
  2575. if(!cShow) {
  2576. controlBarShow(true);
  2577. }
  2578. };
  2579. this.addListenerInside('mousemove', cdMove, thisTemp.CD);
  2580. this.addListenerInside('ended', cdMove);
  2581. this.addListenerInside('resize', cdMove, window);
  2582. if(hide === true) {
  2583. cShow = true;
  2584. force = true;
  2585. controlBarShow(false);
  2586. }
  2587. if(hide === false) {
  2588. cShow = false;
  2589. force = true;
  2590. controlBarShow(true);
  2591. }
  2592. },
  2593. /*
  2594. 内部函数
  2595. 注册键盘按键事件
  2596. */
  2597. keypress: function() {
  2598. var thisTemp = this;
  2599. var keyDown = function(eve) {
  2600. var keycode = eve.keyCode || eve.which;
  2601. switch(keycode) {
  2602. case 32:
  2603. thisTemp.playOrPause();
  2604. break;
  2605. case 37:
  2606. thisTemp.fastBack();
  2607. break;
  2608. case 39:
  2609. thisTemp.fastNext();
  2610. break;
  2611. case 38:
  2612. now = thisTemp.volume + thisTemp.ckplayerConfig['config']['volumeJump'];
  2613. thisTemp.changeVolume(now > 1 ? 1 : now);
  2614. break;
  2615. case 40:
  2616. now = thisTemp.volume - thisTemp.ckplayerConfig['config']['volumeJump'];
  2617. thisTemp.changeVolume(now < 0 ? 0 : now);
  2618. break;
  2619. default:
  2620. break;
  2621. }
  2622. };
  2623. this.addListenerInside('keydown', keyDown, window || document);
  2624. },
  2625. /*
  2626. 内部函数
  2627. 注册倍速相关
  2628. */
  2629. playbackRate: function() {
  2630. if(!this.showFace) {
  2631. return;
  2632. }
  2633. var thisTemp = this;
  2634. var vArr = this.playbackRateArr;
  2635. var html = '';
  2636. var nowD = ''; //当前的清晰度
  2637. var i = 0;
  2638. if(!nowD) {
  2639. nowD = vArr[this.playbackRateDefault][1];
  2640. }
  2641. if(vArr.length > 1) {
  2642. var zlen = 0;
  2643. for(i = 0; i < vArr.length; i++) {
  2644. html = '<p>' + vArr[i][1] + '</p>' + html;
  2645. var dlen = this.getStringLen(vArr[i][1]);
  2646. if(dlen > zlen) {
  2647. zlen = dlen;
  2648. }
  2649. }
  2650. if(html) {
  2651. html += '<p>' + nowD + '</p>';
  2652. }
  2653. this.CB['playbackrate'].innerHTML = nowD;
  2654. this.CB['playbackrateP'].innerHTML = html;
  2655. this.css([this.CB['playbackrate'], this.CB['playbackrateLine']], 'display', 'block');
  2656. var pArr = this.CB['playbackrateP'].childNodes;
  2657. for(var i = 0; i < pArr.length; i++) {
  2658. var fontColor = '#FFFFFF';
  2659. if(pArr[i].innerHTML == nowD) {
  2660. fontColor = '#0782F5';
  2661. }
  2662. this.css(pArr[i], {
  2663. color: fontColor,
  2664. margin: '0px',
  2665. padding: '0px',
  2666. fontSize: '14px'
  2667. });
  2668. if(i < pArr.length - 1) {
  2669. this.css(pArr[i], 'borderBottom', '1px solid #282828')
  2670. }
  2671. var defClick = function(event) {
  2672. if(nowD != this.innerHTML) {
  2673. thisTemp.css(thisTemp.CB['playbackrateP'], 'display', 'none');
  2674. thisTemp.newPlaybackrate(this.innerHTML);
  2675. thisTemp.sendJS('clickEvent', 'actionScript->newPlaybackrate');
  2676. }
  2677. };
  2678. this.addListenerInside('click', defClick, pArr[i]);
  2679. }
  2680. var pW = (zlen * 10) + 20;
  2681. this.css(this.CB['playbackrateP'], {
  2682. width: pW + 'px'
  2683. });
  2684. this.css(this.CB['playbackrate'], {
  2685. width: pW + 'px'
  2686. });
  2687. this.buttonWidth['playbackrate'] = this.CB['playbackrate'].offsetWidth;
  2688. } else {
  2689. this.CB['playbackrate'].innerHTML = '';
  2690. this.CB['playbackrateP'].innerHTML = '';
  2691. this.css([this.CB['playbackrate'], this.CB['playbackrateLine']], 'display', 'none');
  2692. }
  2693. },
  2694. /*
  2695. 内部函数
  2696. 注册切换倍速播放相关事件
  2697. */
  2698. addPlaybackrate: function() {
  2699. var thisTemp = this;
  2700. var setTimeOutP = null;
  2701. var defClick = function(event) {
  2702. thisTemp.css(thisTemp.CB['playbackrateP'], {
  2703. left: thisTemp.getCoor(thisTemp.CB['playbackrate'])['x'] + 'px',
  2704. display: 'block'
  2705. });
  2706. };
  2707. this.addListenerInside('click', defClick, this.CB['playbackrate']);
  2708. var defMouseOut = function(event) {
  2709. if(setTimeOutP) {
  2710. window.clearTimeout(setTimeOutP);
  2711. setTimeOutP = null;
  2712. }
  2713. setTimeOutP = window.setTimeout(function(event) {
  2714. thisTemp.css(thisTemp.CB['playbackrateP'], 'display', 'none');
  2715. }, 500);
  2716. };
  2717. this.addListenerInside('mouseout', defMouseOut, thisTemp.CB['playbackrateP']);
  2718. var defMouseOver = function(event) {
  2719. if(setTimeOutP) {
  2720. window.clearTimeout(setTimeOutP);
  2721. setTimeOutP = null;
  2722. }
  2723. };
  2724. this.addListenerInside('mouseover', defMouseOver, thisTemp.CB['playbackrateP']);
  2725. },
  2726. /*
  2727. 内部函数
  2728. 切换倍速后发生的动作
  2729. */
  2730. newPlaybackrate: function(title) {
  2731. var vArr = this.playbackRateArr;
  2732. var nVArr = [];
  2733. var i = 0;
  2734. for(i = 0; i < vArr.length; i++) {
  2735. var v = vArr[i];
  2736. if(v[1] == title) {
  2737. this.playbackRateDefault = i;
  2738. this.V.playbackRate = v[0];
  2739. if(this.showFace) {
  2740. this.CB['playbackrate'].innerHTML = v[1];
  2741. this.playbackRate();
  2742. }
  2743. this.sendJS('playbackRate', v);
  2744. }
  2745. }
  2746. },
  2747. /*
  2748. 内部函数
  2749. 构建清晰度按钮及切换事件(Click事件)
  2750. */
  2751. definition: function() {
  2752. if(!this.showFace) {
  2753. return;
  2754. }
  2755. var thisTemp = this;
  2756. var vArr = this.VA;
  2757. var dArr = [];
  2758. var html = '';
  2759. var nowD = ''; //当前的清晰度
  2760. var i = 0;
  2761. for(i = 0; i < vArr.length; i++) {
  2762. var d = vArr[i][2];
  2763. if(dArr.indexOf(d) == -1) {
  2764. dArr.push(d);
  2765. }
  2766. if(this.V) {
  2767. if(vArr[i][0] == this.V.currentSrc) {
  2768. nowD = d;
  2769. }
  2770. }
  2771. }
  2772. if(!nowD) {
  2773. nowD = dArr[0];
  2774. }
  2775. if(dArr.length > 1) {
  2776. var zlen = 0;
  2777. for(i = dArr.length - 1; i > -1; i--) {
  2778. html = '<p>' + dArr[i] + '</p>' + html;
  2779. var dlen = this.getStringLen(dArr[i]);
  2780. if(dlen > zlen) {
  2781. zlen = dlen;
  2782. }
  2783. }
  2784. if(html) {
  2785. html += '<p>' + nowD + '</p>';
  2786. }
  2787. this.CB['definition'].innerHTML = nowD;
  2788. this.CB['definitionP'].innerHTML = html;
  2789. this.css([this.CB['definition'], this.CB['definitionLine']], 'display', 'block');
  2790. var pArr = this.CB['definitionP'].childNodes;
  2791. for(var i = 0; i < pArr.length; i++) {
  2792. var fontColor = '#FFFFFF';
  2793. if(pArr[i].innerHTML == nowD) {
  2794. fontColor = '#0782F5';
  2795. }
  2796. this.css(pArr[i], {
  2797. color: fontColor,
  2798. margin: '0px',
  2799. padding: '0px',
  2800. fontSize: '14px'
  2801. });
  2802. if(i < pArr.length - 1) {
  2803. this.css(pArr[i], 'borderBottom', '1px solid #282828')
  2804. }
  2805. var defClick = function() {
  2806. if(nowD != this.innerHTML) {
  2807. thisTemp.css(thisTemp.CB['definitionP'], 'display', 'none');
  2808. thisTemp.newDefinition(this.innerHTML);
  2809. }
  2810. };
  2811. this.addListenerInside('click', defClick, pArr[i]);
  2812. }
  2813. var pW = (zlen * 10) + 20;
  2814. this.css(this.CB['definitionP'], {
  2815. width: pW + 'px'
  2816. });
  2817. this.css(this.CB['definition'], {
  2818. width: pW + 'px'
  2819. });
  2820. this.buttonWidth['definition'] = this.CB['definition'].offsetWidth;
  2821. } else {
  2822. this.CB['definition'].innerHTML = '';
  2823. this.CB['definitionP'].innerHTML = '';
  2824. this.css([this.CB['definition'], this.CB['definitionLine']], 'display', 'none');
  2825. }
  2826. },
  2827. /*
  2828. 内部函数
  2829. 注册清晰度相关事件
  2830. */
  2831. addDefListener: function() {
  2832. var thisTemp = this;
  2833. var setTimeOutP = null;
  2834. var defClick = function(event) {
  2835. thisTemp.css(thisTemp.CB['definitionP'], {
  2836. left: thisTemp.getCoor(thisTemp.CB['definition'])['x'] + 'px',
  2837. display: 'block'
  2838. });
  2839. };
  2840. this.addListenerInside('click', defClick, this.CB['definition']);
  2841. var defMouseOut = function(event) {
  2842. if(setTimeOutP) {
  2843. window.clearTimeout(setTimeOutP);
  2844. setTimeOutP = null;
  2845. }
  2846. setTimeOutP = window.setTimeout(function(event) {
  2847. thisTemp.css(thisTemp.CB['definitionP'], 'display', 'none');
  2848. }, 500);
  2849. };
  2850. this.addListenerInside('mouseout', defMouseOut, thisTemp.CB['definitionP']);
  2851. var defMouseOver = function(event) {
  2852. if(setTimeOutP) {
  2853. window.clearTimeout(setTimeOutP);
  2854. setTimeOutP = null;
  2855. }
  2856. };
  2857. this.addListenerInside('mouseover', defMouseOver, thisTemp.CB['definitionP']);
  2858. },
  2859. /*
  2860. 内部函数
  2861. 切换清晰度后发生的动作
  2862. */
  2863. newDefinition: function(title) {
  2864. var vArr = this.VA;
  2865. var nVArr = [];
  2866. var i = 0;
  2867. for(i = 0; i < vArr.length; i++) {
  2868. var v = vArr[i];
  2869. if(v[2] == title) {
  2870. nVArr.push(v);
  2871. this.sendJS('definitionChange', i + '');
  2872. }
  2873. }
  2874. if(nVArr.length < 1) {
  2875. return;
  2876. }
  2877. if(this.V != null && this.needSeek == 0) {
  2878. this.needSeek = this.V.currentTime;
  2879. }
  2880. if(this.getFileExt(nVArr[0][0]) != '.m3u8') {
  2881. this.isM3u8 = false;
  2882. }
  2883. if(!this.isM3u8) {
  2884. if(nVArr.length == 1) {
  2885. this.V.innerHTML = '';
  2886. this.V.src = nVArr[0][0];
  2887. } else {
  2888. var source = '';
  2889. nVArr = this.arrSort(nVArr);
  2890. for(i = 0; i < nVArr.length; i++) {
  2891. var type = '';
  2892. var va = nVArr[i];
  2893. if(va[1]) {
  2894. type = ' type="' + va[1] + '"';
  2895. }
  2896. source += '<source src="' + va[0] + '"' + type + '>';
  2897. }
  2898. this.V.removeAttribute('src');
  2899. this.V.innerHTML = source;
  2900. }
  2901. } else {
  2902. this.embedHls(vArr[0][0], this.vars['autoplay']);
  2903. }
  2904. this.V.autoplay = 'autoplay';
  2905. this.V.load();
  2906. this.timerErrorFun();
  2907. },
  2908. /*
  2909. 内置函数
  2910. 播放hls
  2911. */
  2912. embedHls: function(url, autoplay) {
  2913. var thisTemp = this;
  2914. if(Hls.isSupported()) {
  2915. var hls = new Hls();
  2916. hls.loadSource(url);
  2917. hls.attachMedia(this.V);
  2918. hls.on(Hls.Events.MANIFEST_PARSED, function() {
  2919. thisTemp.playerLoad();
  2920. if(autoplay) {
  2921. thisTemp.videoPlay();
  2922. }
  2923. });
  2924. }
  2925. },
  2926. /*
  2927. 内部函数
  2928. 构建提示点
  2929. */
  2930. prompt: function() {
  2931. if(!this.showFace) {
  2932. return;
  2933. }
  2934. var thisTemp = this;
  2935. var prompt = this.vars['promptSpot'];
  2936. if(prompt == null || this.promptArr.length > 0) {
  2937. return;
  2938. }
  2939. var showPrompt = function(event) {
  2940. if(thisTemp.promptElement == null) {
  2941. var random2 = 'prompte' + thisTemp.randomString(5);
  2942. var ele2 = document.createElement('div');
  2943. ele2.className = random2;
  2944. thisTemp.PD.appendChild(ele2);
  2945. thisTemp.promptElement = thisTemp.getByElement(random2);
  2946. thisTemp.css(thisTemp.promptElement, {
  2947. overflowX: 'hidden',
  2948. lineHeight: '22px',
  2949. fontSize: '14px',
  2950. color: '#FFFFFF',
  2951. position: 'absolute',
  2952. display: 'block',
  2953. zIndex: '90'
  2954. });
  2955. }
  2956. var pcon = thisTemp.getPromptTest();
  2957. var pW = pcon['pW'],
  2958. pT = pcon['pT'],
  2959. pL = parseInt(thisTemp.css(this, 'left')) - parseInt(pW * 0.5);
  2960. if(pcon['pL'] > 10) {
  2961. pL = pcon['pL'];
  2962. }
  2963. if(pL < 0) {
  2964. pL = 0;
  2965. }
  2966. thisTemp.css(thisTemp.promptElement, {
  2967. width: pW + 'px',
  2968. left: (-pW - 10) + 'px',
  2969. display: 'block'
  2970. });
  2971. thisTemp.promptElement.innerHTML = thisTemp.getDataset(this, 'words');
  2972. thisTemp.css(thisTemp.promptElement, {
  2973. left: pL + 'px',
  2974. top: (pT - thisTemp.promptElement.offsetHeight - 10) + 'px'
  2975. });
  2976. };
  2977. var hidePrompt = function(event) {
  2978. if(thisTemp.promptElement != null) {
  2979. thisTemp.css(thisTemp.promptElement, {
  2980. display: 'none'
  2981. });
  2982. }
  2983. };
  2984. var i = 0;
  2985. for(i = 0; i < prompt.length; i++) {
  2986. var pr = prompt[i];
  2987. var words = pr['words'];
  2988. var time = pr['time'];
  2989. var random = 'prompt' + this.randomString(5);
  2990. var ele = document.createElement('div');
  2991. ele.className = random;
  2992. this.CB['timeBoBg'].appendChild(ele);
  2993. var div = this.getByElement(random);
  2994. div.setAttribute('data-time', time);
  2995. div.setAttribute('data-words', words);
  2996. this.css(div, {
  2997. width: '6px',
  2998. height: '6px',
  2999. backgroundColor: '#FFFFFF',
  3000. position: 'absolute',
  3001. top: '4px',
  3002. left: '-100px',
  3003. display: 'none',
  3004. zIndex: '1',
  3005. borderRadius: '6px'
  3006. });
  3007. this.addListenerInside('mouseover', showPrompt, div);
  3008. this.addListenerInside('mouseout', hidePrompt, div);
  3009. this.promptArr.push(div);
  3010. }
  3011. this.changePrompt();
  3012. },
  3013. /*
  3014. 内部函数
  3015. 计算提示文本的位置
  3016. */
  3017. getPromptTest: function() {
  3018. var pW = this.previewWidth,
  3019. pT = this.getCoor(this.CB['timeButton'])['y'],
  3020. pL = 0;
  3021. if(this.previewTop != null) {
  3022. pT -= parseInt(this.css(this.previewTop, 'height'));
  3023. pL = parseInt(this.css(this.previewTop, 'left'));
  3024. } else {
  3025. pT -= 35;
  3026. }
  3027. pL += 2;
  3028. if(pL < 0) {
  3029. pL = 0;
  3030. }
  3031. if(pL > this.PD.offsetWidth - pW) {
  3032. pL = this.PD.offsetWidth - pW;
  3033. }
  3034. return {
  3035. pW: pW,
  3036. pT: pT,
  3037. pL: pL
  3038. };
  3039. },
  3040. /*
  3041. 内部函数
  3042. 删除提示点
  3043. */
  3044. deletePrompt: function() {
  3045. var arr = this.promptArr;
  3046. if(arr.length > 0) {
  3047. for(var i = 0; i < arr.length; i++) {
  3048. if(arr[i]) {
  3049. this.deleteChild(arr[i]);
  3050. }
  3051. }
  3052. }
  3053. this.promptArr = [];
  3054. },
  3055. /*
  3056. 内部函数
  3057. 计算提示点坐标
  3058. */
  3059. changePrompt: function() {
  3060. if(this.promptArr.length == 0) {
  3061. return;
  3062. }
  3063. var arr = this.promptArr;
  3064. var duration = this.getMetaDate()['duration'];
  3065. var bw = this.CB['timeBoBg'].offsetWidth;
  3066. for(var i = 0; i < arr.length; i++) {
  3067. var time = parseInt(this.getDataset(arr[i], 'time'));
  3068. var left = parseInt(time * bw / duration) - parseInt(arr[i].offsetWidth * 0.5);
  3069. if(left < 0) {
  3070. left = 0;
  3071. }
  3072. if(left > bw - parseInt(arr[i].offsetWidth * 0.5)) {
  3073. left = bw - parseInt(arr[i].offsetWidth * 0.5);
  3074. }
  3075. this.css(arr[i], {
  3076. left: left + 'px',
  3077. display: 'block'
  3078. });
  3079. }
  3080. },
  3081. /*
  3082. 内部函数
  3083. 构建预览图片效果
  3084. */
  3085. preview: function(obj) {
  3086. var thisTemp = this;
  3087. var preview = {
  3088. file: null,
  3089. scale: 0
  3090. };
  3091. preview = this.standardization(preview, this.vars['preview']);
  3092. if(preview['file'] == null || preview['scale'] <= 0) {
  3093. return;
  3094. }
  3095. var srcArr = preview['file'];
  3096. if(this.previewStart == 0) { //如果还没有构建,则先进行构建
  3097. this.previewStart = 1;
  3098. if(srcArr.length > 0) {
  3099. var i = 0;
  3100. var imgW = 0,
  3101. imgH = 0;
  3102. var random = thisTemp.randomString(10);
  3103. var loadNum = 0;
  3104. var loadImg = function(i) {
  3105. srcArr[i] = thisTemp.getNewUrl(srcArr[i]);
  3106. var n = 0;
  3107. var img = new Image();
  3108. img.src = srcArr[i];
  3109. img.className = random + i;
  3110. img.onload = function(event) {
  3111. loadNum++;
  3112. if(thisTemp.previewDiv == null) { //如果没有建立DIV,则建
  3113. imgW = img.width;
  3114. imgH = img.height;
  3115. thisTemp.previewWidth = parseInt(imgW * 0.1);
  3116. var ele = document.createElement('div');
  3117. ele.className = random;
  3118. thisTemp.PD.appendChild(ele);
  3119. thisTemp.previewDiv = thisTemp.getByElement(random);
  3120. var eleTop = (obj['y'] - parseInt(imgH * 0.1) + 2);
  3121. thisTemp.css(thisTemp.previewDiv, {
  3122. width: srcArr.length * imgW * 10 + 'px',
  3123. height: parseInt(imgH * 0.1) + 'px',
  3124. backgroundColor: '#000000',
  3125. position: 'absolute',
  3126. left: '0px',
  3127. top: eleTop + 'px',
  3128. display: 'none',
  3129. zIndex: '80'
  3130. });
  3131. ele.setAttribute('data-x', '0');
  3132. ele.setAttribute('data-y', eleTop);
  3133. var ele2 = document.createElement('div');
  3134. ele2.className = random + 'd2';
  3135. thisTemp.PD.appendChild(ele2);
  3136. thisTemp.previewTop = thisTemp.getByElement(ele2.className);
  3137. thisTemp.css(thisTemp.previewTop, {
  3138. width: parseInt(imgW * 0.1) + 'px',
  3139. height: parseInt(imgH * 0.1) + 'px',
  3140. position: 'absolute',
  3141. border: '5px solid ' + thisTemp.css(thisTemp.CB['timeProgress'], 'backgroundColor'),
  3142. left: '0px',
  3143. top: (obj['y'] - parseInt(imgH * 0.1) + 2) + 'px',
  3144. display: 'none',
  3145. zIndex: '81'
  3146. });
  3147. var html = '';
  3148. for(n = 0; n < srcArr.length; n++) {
  3149. html += thisTemp.newCanvas(random + n, imgW * 10, parseInt(imgH * 0.1))
  3150. }
  3151. thisTemp.previewDiv.innerHTML = html;
  3152. }
  3153. thisTemp.previewDiv.appendChild(img);
  3154. var cimg = thisTemp.getByElement(img.className);
  3155. var canvas = thisTemp.getByElement(img.className + '-canvas');
  3156. var context = canvas.getContext('2d');
  3157. var sx = 0,
  3158. sy = 0,
  3159. x = 0,
  3160. h = parseInt(imgH * 0.1);
  3161. for(n = 0; n < 100; n++) {
  3162. x = parseInt(n * imgW * 0.1);
  3163. context.drawImage(cimg, sx, sy, parseInt(imgW * 0.1), h, x, 0, parseInt(imgW * 0.1), h);
  3164. sx += parseInt(imgW * 0.1);
  3165. if(sx >= imgW) {
  3166. sx = 0;
  3167. sy += h;
  3168. }
  3169. thisTemp.css(cimg, 'display', 'none');
  3170. }
  3171. if(loadNum == srcArr.length) {
  3172. thisTemp.previewStart = 2;
  3173. } else {
  3174. i++;
  3175. loadImg(i);
  3176. }
  3177. };
  3178. };
  3179. }
  3180. loadImg(i);
  3181. return;
  3182. }
  3183. if(this.previewStart == 2) {
  3184. var isTween = true;
  3185. var nowNum = parseInt(obj['time'] / this.vars['preview']['scale']);
  3186. var numTotal = parseInt(thisTemp.getMetaDate()['duration'] / this.vars['preview']['scale']);
  3187. if(thisTemp.css(thisTemp.previewDiv, 'display') == 'none') {
  3188. isTween = false;
  3189. }
  3190. thisTemp.css(thisTemp.previewDiv, 'display', 'block');
  3191. var imgWidth = thisTemp.previewDiv.offsetWidth * 0.01 / srcArr.length;
  3192. var left = (imgWidth * nowNum) - obj['x'] + parseInt(imgWidth * 0.5),
  3193. top = obj['y'] - thisTemp.previewDiv.offsetHeight;
  3194. thisTemp.css(thisTemp.previewDiv, 'top', top + 2 + 'px');
  3195. var topLeft = obj['x'] - parseInt(imgWidth * 0.5);
  3196. var timepieces = 0;
  3197. if(topLeft < 0) {
  3198. topLeft = 0;
  3199. timepieces = obj['x'] - topLeft - imgWidth * 0.5;
  3200. }
  3201. if(topLeft > thisTemp.PD.offsetWidth - imgWidth) {
  3202. topLeft = thisTemp.PD.offsetWidth - imgWidth;
  3203. timepieces = obj['x'] - topLeft - imgWidth * 0.5;
  3204. }
  3205. if(left < 0) {
  3206. left = 0;
  3207. }
  3208. if(left > numTotal * imgWidth - thisTemp.PD.offsetWidth) {
  3209. left = numTotal * imgWidth - thisTemp.PD.offsetWidth;
  3210. }
  3211. thisTemp.css(thisTemp.previewTop, {
  3212. left: topLeft + 'px',
  3213. top: top + 2 + 'px',
  3214. display: 'block'
  3215. });
  3216. if(thisTemp.previewTop.offsetHeight > thisTemp.previewDiv.offsetHeight) {
  3217. thisTemp.css(thisTemp.previewTop, {
  3218. height: thisTemp.previewDiv.offsetHeight - (thisTemp.previewTop.offsetHeight - thisTemp.previewDiv.offsetHeight) + 'px'
  3219. });
  3220. }
  3221. if(this.previewTween != null) {
  3222. this.animatePause(this.previewTween);
  3223. this.previewTween = null
  3224. }
  3225. var nowLeft = parseInt(thisTemp.css(thisTemp.previewDiv, 'left'));
  3226. var leftC = nowLeft + left;
  3227. if(nowLeft == -(left + timepieces)) {
  3228. return;
  3229. }
  3230. if(isTween) {
  3231. var obj = {
  3232. element: thisTemp.previewDiv,
  3233. start: null,
  3234. end: -(left + timepieces),
  3235. speed: 0.3
  3236. };
  3237. this.previewTween = this.animate(obj);
  3238. } else {
  3239. thisTemp.css(thisTemp.previewDiv, 'left', -(left + timepieces) + 'px')
  3240. }
  3241. }
  3242. },
  3243. /*
  3244. 内部函数
  3245. 删除预览图节点
  3246. */
  3247. deletePreview: function() {
  3248. if(this.previewDiv != null) {
  3249. this.deleteChild(this.previewDiv);
  3250. this.previewDiv = null;
  3251. this.previewStart = 0;
  3252. }
  3253. },
  3254. /*
  3255. 内部函数
  3256. 修改视频地址,属性
  3257. */
  3258. changeVideo: function() {
  3259. if(!this.html5Video) {
  3260. this.getVarsObject();
  3261. this.V.newVideo(this.vars);
  3262. return;
  3263. }
  3264. var vArr = this.VA;
  3265. var v = this.vars;
  3266. var i = 0;
  3267. if(vArr.length < 1) {
  3268. return;
  3269. }
  3270. if(this.V != null && this.needSeek == 0) {
  3271. this.needSeek = this.V.currentTime;
  3272. }
  3273. if(v['poster']) {
  3274. this.V.poster = v['poster'];
  3275. } else {
  3276. this.V.removeAttribute('poster');
  3277. }
  3278. if(v['loop']) {
  3279. this.V.loop = 'loop';
  3280. } else {
  3281. this.V.removeAttribute('loop');
  3282. }
  3283. if(v['seek'] > 0) {
  3284. this.needSeek = v['seek'];
  3285. } else {
  3286. this.needSeek = 0;
  3287. }
  3288. if(this.getFileExt(vArr[0][0]) != '.m3u8') {
  3289. this.isM3u8 = false;
  3290. }
  3291. if(!this.isM3u8) {
  3292. if(vArr.length == 1) {
  3293. this.V.innerHTML = '';
  3294. this.V.src = vArr[0][0];
  3295. } else {
  3296. var source = '';
  3297. vArr = this.arrSort(vArr);
  3298. for(i = 0; i < vArr.length; i++) {
  3299. var type = '';
  3300. var va = vArr[i];
  3301. if(va[1]) {
  3302. type = ' type="' + va[1] + '"';
  3303. }
  3304. source += '<source src="' + va[0] + '"' + type + '>';
  3305. }
  3306. this.V.removeAttribute('src');
  3307. this.V.innerHTML = source;
  3308. }
  3309. //分析视频地址结束
  3310. if(v['autoplay']) {
  3311. this.V.autoplay = 'autoplay';
  3312. } else {
  3313. this.V.removeAttribute('autoplay');
  3314. }
  3315. this.V.load();
  3316. } else {
  3317. this.embedHls(vArr[0][0], v['autoplay']);
  3318. }
  3319. if(!this.isUndefined(v['volume'])) {
  3320. this.changeVolume(v['volume']);
  3321. }
  3322. this.resetPlayer(); //重置界面元素
  3323. this.timerErrorFun();
  3324. //如果存在字幕则加载
  3325. if(this.vars['cktrack']) {
  3326. this.loadTrack();
  3327. }
  3328. },
  3329. /*
  3330. 内部函数
  3331. 调整中间暂停按钮,缓冲loading,错误提示文本框的位置
  3332. */
  3333. elementCoordinate: function() {
  3334. this.pdCoor = this.getXY(this.PD);
  3335. this.css(this.CB['pauseCenter'], {
  3336. left: parseInt((this.PD.offsetWidth - 80) * 0.5) + 'px',
  3337. top: parseInt((this.PD.offsetHeight - 80) * 0.5) + 'px'
  3338. });
  3339. this.css(this.CB['loading'], {
  3340. left: parseInt((this.PD.offsetWidth - 60) * 0.5) + 'px',
  3341. top: parseInt((this.PD.offsetHeight - 60) * 0.5) + 'px'
  3342. });
  3343. this.css(this.CB['errorText'], {
  3344. left: parseInt((this.PD.offsetWidth - 120) * 0.5) + 'px',
  3345. top: parseInt((this.PD.offsetHeight - 30) * 0.5) + 'px'
  3346. });
  3347. this.css(this.CB['logo'], {
  3348. left: parseInt(this.PD.offsetWidth - this.CB['logo'].offsetWidth - 20) + 'px',
  3349. top: '20px'
  3350. });
  3351. this.checkBarWidth();
  3352. },
  3353. /*
  3354. 内部函数
  3355. 当播放器尺寸变化时,显示和隐藏相关节点
  3356. */
  3357. checkBarWidth: function() {
  3358. if(!this.showFace) {
  3359. return;
  3360. }
  3361. var controlBarW = this.CB['controlBar'].offsetWidth;
  3362. var ele = [];
  3363. ele.push([
  3364. [this.CB['full'], this.CB['escFull'], this.CB['fullLine']], this.buttonWidth['full'] + 2, 'full'
  3365. ]);
  3366. if(this.vars['front'] != '') {
  3367. ele.push([
  3368. [this.CB['front'], this.CB['frontLine']], this.buttonWidth['front'] + 2
  3369. ]);
  3370. }
  3371. if(this.vars['next'] != '') {
  3372. ele.push([
  3373. [this.CB['next'], this.CB['nextLine']], this.buttonWidth['next'] + 2
  3374. ]);
  3375. }
  3376. if(this.CB['definition'].innerHTML != '') {
  3377. ele.push([
  3378. [this.CB['definition'], this.CB['definitionLine']], this.buttonWidth['definition'] + 2
  3379. ]);
  3380. }
  3381. ele.push([
  3382. [this.CB['volume']], this.buttonWidth['volume']
  3383. ]);
  3384. ele.push([
  3385. [this.CB['mute'], this.CB['escMute'], this.CB['muteLine']], this.buttonWidth['mute'] + 2, 'mute'
  3386. ]);
  3387. ele.push([
  3388. [this.CB['timeText']], this.buttonWidth['timeText']
  3389. ]);
  3390. ele.push([
  3391. [this.CB['play'], this.CB['pause'], this.CB['playLine']], this.buttonWidth['play'] + 2, 'play'
  3392. ]);
  3393. var i = 0;
  3394. var len = 0;
  3395. var isc = true;
  3396. //计算所有要显示的节点的总宽度
  3397. for(var i = 0; i < ele.length; i++) {
  3398. var nlen = ele[i][1];
  3399. if(nlen > 2) {
  3400. len += nlen;
  3401. } else {
  3402. isc = false;
  3403. }
  3404. }
  3405. if(isc) {
  3406. this.buttonLen = len;
  3407. this.buttonArr = ele;
  3408. }
  3409. len = this.buttonLen;
  3410. ele = this.buttonArr;
  3411. for(var i = 0; i < ele.length; i++) {
  3412. if(len > controlBarW) {
  3413. len -= ele[i][1];
  3414. this.css(ele[i][0], 'display', 'none');
  3415. } else {
  3416. this.css(ele[i][0], 'display', 'block');
  3417. if(ele[i].length == 3) {
  3418. var name = ele[i][2];
  3419. switch(name) {
  3420. case 'mute':
  3421. if(this.volume == 0) {
  3422. this.css(this.CB['mute'], 'display', 'none');
  3423. } else {
  3424. this.css(this.CB['escMute'], 'display', 'none');
  3425. }
  3426. break;
  3427. case 'play':
  3428. this.playShow(this.V.paused ? false : true);
  3429. break;
  3430. case 'full':
  3431. if(this.full) {
  3432. this.css(this.CB['full'], 'display', 'none');
  3433. } else {
  3434. this.css(this.CB['escFull'], 'display', 'none');
  3435. }
  3436. break;
  3437. }
  3438. }
  3439. }
  3440. }
  3441. },
  3442. /*
  3443. 内部函数
  3444. 初始化暂停或播放按钮
  3445. */
  3446. initPlayPause: function() {
  3447. if(!this.showFace) {
  3448. return;
  3449. }
  3450. if(this.vars['autoplay']) {
  3451. this.css([this.CB['play'], this.CB['pauseCenter']], 'display', 'none');
  3452. this.css(this.CB['pause'], 'display', 'block');
  3453. } else {
  3454. this.css(this.CB['play'], 'display', 'block');
  3455. if(this.css(this.CB['errorText'], 'display') == 'none') {
  3456. this.css(this.CB['pauseCenter'], 'display', 'block');
  3457. }
  3458. this.css(this.CB['pause'], 'display', 'none');
  3459. }
  3460. },
  3461. /*
  3462. 下面为监听事件
  3463. 内部函数
  3464. 监听元数据已加载
  3465. */
  3466. loadedHandler: function() {
  3467. this.loaded = true;
  3468. if(this.vars['loaded'] != '') {
  3469. try {
  3470. eval(this.vars['loaded'] + '()');
  3471. } catch(event) {
  3472. this.log(event);
  3473. }
  3474. }
  3475. },
  3476. /*
  3477. 内部函数
  3478. 监听播放
  3479. */
  3480. playingHandler: function() {
  3481. this.playShow(true);
  3482. if(this.needSeek > 0) {
  3483. this.videoSeek(this.needSeek);
  3484. this.needSeek = 0;
  3485. }
  3486. if(this.animatePauseArray.length > 0) {
  3487. this.animateResume('pause');
  3488. }
  3489. if(this.playerType == 'html5video' && this.V != null && this.config['videoDrawImage']) {
  3490. this.sendVCanvas();
  3491. }
  3492. },
  3493. /*
  3494. 内部函数
  3495. 使用画布附加视频
  3496. */
  3497. sendVCanvas: function() {
  3498. if(this.timerVCanvas == null) {
  3499. this.css(this.V, 'display', 'none');
  3500. this.css(this.MD, 'display', 'block');
  3501. var thisTemp = this;
  3502. var videoCanvas = function() {
  3503. if(thisTemp.MDCX.width != thisTemp.PD.offsetWidth) {
  3504. thisTemp.MDC.width = thisTemp.PD.offsetWidth;
  3505. }
  3506. if(thisTemp.MDCX.height != thisTemp.PD.offsetHeight) {
  3507. thisTemp.MDC.height = thisTemp.PD.offsetHeight;
  3508. }
  3509. thisTemp.MDCX.clearRect(0, 0, thisTemp.MDCX.width, thisTemp.MDCX.height);
  3510. var coor = thisTemp.getProportionCoor(thisTemp.PD.offsetWidth, thisTemp.PD.offsetHeight, thisTemp.V.videoWidth, thisTemp.V.videoHeight);
  3511. thisTemp.MDCX.drawImage(thisTemp.V, 0, 0, thisTemp.V.videoWidth, thisTemp.V.videoHeight, coor['x'], coor['y'], coor['width'], coor['height']);
  3512. };
  3513. this.timerVCanvas = new this.timer(0, videoCanvas);
  3514. }
  3515. },
  3516. /*
  3517. 内部函数
  3518. 监听暂停
  3519. */
  3520. pauseHandler: function() {
  3521. this.playShow(false);
  3522. if(this.animatePauseArray.length > 0) {
  3523. this.animatePause('pause');
  3524. }
  3525. if(this.playerType == 'html5video' && this.V != null && this.config['videoDrawImage']) {
  3526. this.stopVCanvas();
  3527. }
  3528. },
  3529. /*
  3530. 内部函数
  3531. 停止画布
  3532. */
  3533. stopVCanvas: function() {
  3534. if(this.timerVCanvas != null) {
  3535. this.css(this.V, 'display', 'block');
  3536. this.css(this.MD, 'display', 'none');
  3537. if(this.timerVCanvas.runing) {
  3538. this.timerVCanvas.stop();
  3539. }
  3540. this.timerVCanvas = null;
  3541. }
  3542. },
  3543. /*
  3544. 内部函数
  3545. 根据当前播放还是暂停确认图标显示
  3546. */
  3547. playShow: function(b) {
  3548. if(!this.showFace) {
  3549. return;
  3550. }
  3551. if(b) {
  3552. this.css(this.CB['play'], 'display', 'none');
  3553. this.css(this.CB['pauseCenter'], 'display', 'none');
  3554. this.css(this.CB['pause'], 'display', 'block');
  3555. } else {
  3556. this.css(this.CB['play'], 'display', 'block');
  3557. if(this.css(this.CB['errorText'], 'display') == 'none') {
  3558. this.css(this.CB['pauseCenter'], 'display', 'block');
  3559. } else {
  3560. this.css(this.CB['pauseCenter'], 'display', 'none');
  3561. }
  3562. this.css(this.CB['pause'], 'display', 'none');
  3563. }
  3564. },
  3565. /*
  3566. 内部函数
  3567. 监听seek结束
  3568. */
  3569. seekedHandler: function() {
  3570. this.resetTrack();
  3571. this.isTimeButtonMove = true;
  3572. if(this.V.paused) {
  3573. this.videoPlay();
  3574. }
  3575. },
  3576. /*
  3577. 内部函数
  3578. 监听播放结束
  3579. */
  3580. endedHandler: function() {
  3581. if(!this.vars['loop']) {
  3582. this.videoPause();
  3583. }
  3584. },
  3585. /*
  3586. 内部函数
  3587. 监听音量改变
  3588. */
  3589. volumechangeHandler: function() {
  3590. if(!this.showFace) {
  3591. return;
  3592. }
  3593. try {
  3594. if(this.V.volume > 0) {
  3595. this.css(this.CB['mute'], 'display', 'block');
  3596. this.css(this.CB['escMute'], 'display', 'none');
  3597. } else {
  3598. this.css(this.CB['mute'], 'display', 'none');
  3599. this.css(this.CB['escMute'], 'display', 'block');
  3600. }
  3601. } catch(event) {}
  3602. },
  3603. /*
  3604. 内部函数
  3605. 监听播放时间调节进度条
  3606. */
  3607. timeUpdateHandler: function() {
  3608. var duration = 0;
  3609. if(this.playerType == 'html5video') {
  3610. try {
  3611. duration = this.V.duration;
  3612. } catch(event) {}
  3613. }
  3614. if(duration > 0) {
  3615. this.time = this.V.currentTime;
  3616. this.timeTextHandler();
  3617. this.trackShowHandler();
  3618. if(this.isTimeButtonMove) {
  3619. this.timeProgress(this.time, duration);
  3620. }
  3621. }
  3622. },
  3623. /*
  3624. 内部函数
  3625. 按时间改变进度条
  3626. */
  3627. timeProgress: function(time, duration) {
  3628. if(!this.showFace) {
  3629. return;
  3630. }
  3631. var timeProgressBgW = this.CB['timeProgressBg'].offsetWidth;
  3632. var timeBOW = parseInt((time * timeProgressBgW / duration) - (this.CB['timeButton'].offsetWidth * 0.5));
  3633. if(timeBOW > timeProgressBgW - this.CB['timeButton'].offsetWidth) {
  3634. timeBOW = timeProgressBgW - this.CB['timeButton'].offsetWidth;
  3635. }
  3636. if(timeBOW < 0) {
  3637. timeBOW = 0;
  3638. }
  3639. this.css(this.CB['timeProgress'], 'width', timeBOW + 'px');
  3640. this.css(this.CB['timeButton'], 'left', parseInt(timeBOW) + 'px');
  3641. },
  3642. /*
  3643. 内部函数
  3644. 监听播放时间改变时间显示文本框
  3645. */
  3646. timeTextHandler: function() { //显示时间/总时间
  3647. if(!this.showFace) {
  3648. return;
  3649. }
  3650. var duration = this.V.duration;
  3651. var time = this.V.currentTime;
  3652. if(isNaN(duration) || parseInt(duration) < 0.2) {
  3653. duration = this.vars['duration'];
  3654. }
  3655. this.CB['timeText'].innerHTML = this.formatTime(time) + ' / ' + this.formatTime(duration);
  3656. if(this.CB['timeText'].offsetWidth > 0) {
  3657. this.buttonWidth['timeText'] = this.CB['timeText'].offsetWidth;
  3658. }
  3659. },
  3660. /*
  3661. 内部函数
  3662. 监听是否是缓冲状态
  3663. */
  3664. bufferEdHandler: function() {
  3665. if(!this.showFace || this.playerType == 'flashplayer') {
  3666. return;
  3667. }
  3668. var thisTemp = this;
  3669. var clearTimerBuffer = function() {
  3670. if(thisTemp.timerBuffer != null) {
  3671. if(thisTemp.timerBuffer.runing) {
  3672. thisTemp.sendJS('buffer', 100);
  3673. thisTemp.timerBuffer.stop();
  3674. }
  3675. thisTemp.timerBuffer = null;
  3676. }
  3677. };
  3678. clearTimerBuffer();
  3679. var bufferFun = function() {
  3680. if(thisTemp.V.buffered.length > 0) {
  3681. var duration = thisTemp.V.duration;
  3682. var len = thisTemp.V.buffered.length;
  3683. var bufferStart = thisTemp.V.buffered.start(len - 1);
  3684. var bufferEnd = thisTemp.V.buffered.end(len - 1);
  3685. var loadTime = bufferStart + bufferEnd;
  3686. var loadProgressBgW = thisTemp.CB['timeProgressBg'].offsetWidth;
  3687. var timeButtonW = thisTemp.CB['timeButton'].offsetWidth;
  3688. var loadW = parseInt((loadTime * loadProgressBgW / duration) + timeButtonW);
  3689. if(loadW >= loadProgressBgW) {
  3690. loadW = loadProgressBgW;
  3691. clearTimerBuffer();
  3692. }
  3693. thisTemp.changeLoad(loadTime);
  3694. }
  3695. };
  3696. this.timerBuffer = new this.timer(200, bufferFun);
  3697. },
  3698. /*
  3699. 内部函数
  3700. 单独计算加载进度
  3701. */
  3702. changeLoad: function(loadTime) {
  3703. if(this.V == null) {
  3704. return;
  3705. }
  3706. if(!this.showFace) {
  3707. return;
  3708. }
  3709. var loadProgressBgW = this.CB['timeProgressBg'].offsetWidth;
  3710. var timeButtonW = this.CB['timeButton'].offsetWidth;
  3711. var duration = this.V.duration;
  3712. if(this.isUndefined(loadTime)) {
  3713. loadTime = this.loadTime;
  3714. } else {
  3715. this.loadTime = loadTime;
  3716. }
  3717. var loadW = parseInt((loadTime * loadProgressBgW / duration) + timeButtonW);
  3718. this.css(this.CB['loadProgress'], 'width', loadW + 'px');
  3719. },
  3720. /*
  3721. 内部函数
  3722. 判断是否是直播
  3723. */
  3724. judgeIsLive: function() {
  3725. var thisTemp = this;
  3726. if(this.timerError != null) {
  3727. if(this.timerError.runing) {
  3728. this.timerError.stop();
  3729. }
  3730. this.timerError = null;
  3731. }
  3732. this.error = false;
  3733. if(this.showFace) {
  3734. this.css(this.CB['errorText'], 'display', 'none');
  3735. }
  3736. var timeupdate = function(event) {
  3737. thisTemp.timeUpdateHandler();
  3738. };
  3739. if(!this.vars['live']) {
  3740. if(this.V != null && this.playerType == 'html5video') {
  3741. this.addListenerInside('timeupdate', timeupdate);
  3742. thisTemp.timeTextHandler();
  3743. thisTemp.prompt(); //添加提示点
  3744. window.setTimeout(function() {
  3745. thisTemp.bufferEdHandler();
  3746. }, 200);
  3747. }
  3748. } else {
  3749. this.removeListenerInside('timeupdate', timeupdate);
  3750. if(this.timerTime != null) {
  3751. window.clearInterval(this.timerTime);
  3752. timerTime = null;
  3753. }
  3754. if(this.timerTime != null) {
  3755. if(this.timerTime.runing) {
  3756. this.timerTime.stop();
  3757. }
  3758. this.timerTime = null;
  3759. }
  3760. var timeFun = function() {
  3761. if(thisTemp.V != null && !thisTemp.V.paused && thisTemp.showFace) {
  3762. thisTemp.CB['timeText'].innerHTML = thisTemp.getNowDate();
  3763. }
  3764. };
  3765. this.timerTime = new this.timer(1000, timeFun);
  3766. //timerTime.start();
  3767. }
  3768. this.definition();
  3769. },
  3770. /*
  3771. 内部函数
  3772. 加载字幕
  3773. */
  3774. loadTrack: function() {
  3775. if(this.playerType == 'flashplayer' || this.vars['flashplayer'] == true) {
  3776. return;
  3777. }
  3778. var thisTemp = this;
  3779. var track = this.vars['cktrack'];
  3780. var obj = {
  3781. method: 'get',
  3782. dataType: 'text',
  3783. url: track,
  3784. charset: 'utf-8',
  3785. success: function(data) {
  3786. thisTemp.track = thisTemp.parseSrtSubtitles(data);
  3787. thisTemp.trackIndex = 0;
  3788. thisTemp.nowTrackShow = {
  3789. sn: ''
  3790. };
  3791. }
  3792. };
  3793. this.ajax(obj);
  3794. },
  3795. /*
  3796. 内部函数
  3797. 重置字幕
  3798. */
  3799. resetTrack: function() {
  3800. this.trackIndex = 0;
  3801. this.nowTrackShow = {
  3802. sn: ''
  3803. };
  3804. },
  3805. /*
  3806. 内部函数
  3807. 根据时间改变读取显示字幕
  3808. */
  3809. trackShowHandler: function() {
  3810. if(!this.showFace) {
  3811. return;
  3812. }
  3813. if(this.track.length < 1) {
  3814. return;
  3815. }
  3816. if(this.trackIndex >= this.track.length) {
  3817. this.trackIndex = 0;
  3818. }
  3819. var nowTrack = this.track[this.trackIndex]; //当前编号对应的字幕内容
  3820. /*
  3821. this.nowTrackShow=当前显示在界面上的内容
  3822. 如果当前时间正好在nowTrack时间内,则需要判断
  3823. */
  3824. if(this.time >= nowTrack['startTime'] && this.time <= nowTrack['endTime']) {
  3825. /*
  3826. 如果当前显示的内容不等于当前需要显示的内容时,则需要显示正确的内容
  3827. */
  3828. var nowShow = this.nowTrackShow;
  3829. if(nowShow['sn'] != nowTrack['sn']) {
  3830. this.trackHide();
  3831. this.trackShow(nowTrack);
  3832. }
  3833. } else {
  3834. /*
  3835. * 如果当前播放时间不在当前编号字幕内,则需要先清空当前的字幕内容,再显示新的字幕内容
  3836. */
  3837. this.trackHide();
  3838. this.checkTrack();
  3839. }
  3840. },
  3841. /*
  3842. 内部函数
  3843. 显示字幕内容
  3844. */
  3845. trackShow: function(track) {
  3846. this.nowTrackShow = track;
  3847. var arr = track['content'];
  3848. for(var i = 0; i < arr.length; i++) {
  3849. var obj = {
  3850. list: [{
  3851. type: 'text',
  3852. text: arr[i],
  3853. color: '#FFFFFF',
  3854. size: 16,
  3855. font: this.fontFamily,
  3856. lineHeight: 30
  3857. }],
  3858. position: [1, 2, null, -(arr.length - i) * 30 - 50]
  3859. };
  3860. var ele = this.addElement(obj);
  3861. this.trackElement.push(ele);
  3862. }
  3863. },
  3864. /*
  3865. 内部函数
  3866. 隐藏字字幕内容
  3867. */
  3868. trackHide: function() {
  3869. for(var i = 0; i < this.trackElement.length; i++) {
  3870. this.deleteElement(this.trackElement[i]);
  3871. }
  3872. this.trackElement = [];
  3873. },
  3874. /*
  3875. 内部函数
  3876. 重新计算字幕的编号
  3877. */
  3878. checkTrack: function() {
  3879. var num = this.trackIndex;
  3880. var arr = this.track;
  3881. var i = 0;
  3882. for(i = num; i < arr.length; i++) {
  3883. if(this.time >= arr[i]['startTime'] && this.time <= arr[i]['endTime']) {
  3884. this.trackIndex = i;
  3885. break;
  3886. }
  3887. }
  3888. },
  3889. /*
  3890. -----------------------------------------------------------------------------接口函数开始
  3891. 接口函数
  3892. 在播放和暂停之间切换
  3893. */
  3894. playOrPause: function() {
  3895. if(!this.loaded) {
  3896. return;
  3897. }
  3898. if(this.config['videoClick']) {
  3899. if(this.V == null) {
  3900. return;
  3901. }
  3902. if(this.playerType == 'flashplayer') {
  3903. this.V.playOrPause();
  3904. return;
  3905. }
  3906. if(this.V.paused) {
  3907. this.videoPlay();
  3908. } else {
  3909. this.videoPause();
  3910. }
  3911. }
  3912. },
  3913. /*
  3914. 接口函数
  3915. 播放动作
  3916. */
  3917. videoPlay: function() {
  3918. if(!this.loaded) {
  3919. return;
  3920. }
  3921. if(this.playerType == 'flashplayer') {
  3922. this.V.videoPlay();
  3923. return;
  3924. }
  3925. this.V.play();
  3926. },
  3927. /*
  3928. 接口函数
  3929. 暂停动作
  3930. */
  3931. videoPause: function() {
  3932. if(!this.loaded) {
  3933. return;
  3934. }
  3935. if(this.playerType == 'flashplayer') {
  3936. this.V.videoPause();
  3937. return;
  3938. }
  3939. this.V.pause();
  3940. },
  3941. /*
  3942. 接口函数
  3943. 跳转时间动作
  3944. */
  3945. videoSeek: function(time) {
  3946. if(!this.loaded) {
  3947. return;
  3948. }
  3949. if(this.playerType == 'flashplayer') {
  3950. this.V.videoSeek(time);
  3951. return;
  3952. }
  3953. var meta = this.getMetaDate();
  3954. var duration = meta['duration'];
  3955. if(duration > 0 && time > duration) {
  3956. time = duration;
  3957. }
  3958. if(time >= 0) {
  3959. this.V.currentTime = time;
  3960. this.sendJS('seekTime', time);
  3961. }
  3962. },
  3963. /*
  3964. 接口函数
  3965. 调节音量/获取音量
  3966. */
  3967. changeVolume: function(vol, bg, button) {
  3968. if(this.loaded) {
  3969. if(this.playerType == 'flashplayer') {
  3970. this.V.changeVolume(time);
  3971. return;
  3972. }
  3973. }
  3974. if(isNaN(vol) || this.isUndefined(vol)) {
  3975. vol = 0;
  3976. }
  3977. if(!this.loaded) {
  3978. this.vars['volume'] = vol;
  3979. }
  3980. if(!this.html5Video) {
  3981. this.V.changeVolume(vol);
  3982. return;
  3983. }
  3984. try {
  3985. if(this.isUndefined(bg)) {
  3986. bg = true;
  3987. }
  3988. } catch(e) {}
  3989. try {
  3990. if(this.isUndefined(button)) {
  3991. button = true;
  3992. }
  3993. } catch(e) {}
  3994. if(!vol) {
  3995. vol = 0;
  3996. }
  3997. if(vol < 0) {
  3998. vol = 0;
  3999. }
  4000. if(vol > 1) {
  4001. vol = 1;
  4002. }
  4003. try {
  4004. this.V.volume = vol;
  4005. } catch(error) {}
  4006. this.volume = vol;
  4007. if(bg && this.showFace) {
  4008. var bgW = vol * this.CB['volumeBg'].offsetWidth;
  4009. if(bgW < 0) {
  4010. bgW = 0;
  4011. }
  4012. if(bgW > this.CB['volumeBg'].offsetWidth) {
  4013. bgW = this.CB['volumeBg'].offsetWidth;
  4014. }
  4015. this.css(this.CB['volumeUp'], 'width', bgW + 'px');
  4016. }
  4017. if(button && this.showFace) {
  4018. var buLeft = parseInt(this.CB['volumeUp'].offsetWidth - (this.CB['volumeBO'].offsetWidth * 0.5));
  4019. if(buLeft > this.CB['volumeBg'].offsetWidth - this.CB['volumeBO'].offsetWidth) {
  4020. buLeft = this.CB['volumeBg'].offsetWidth - this.CB['volumeBO'].offsetWidth
  4021. }
  4022. if(buLeft < 0) {
  4023. buLeft = 0;
  4024. }
  4025. this.css(this.CB['volumeBO'], 'left', buLeft + 'px');
  4026. }
  4027. },
  4028. /*
  4029. 接口函数
  4030. 静音
  4031. */
  4032. videoMute: function() {
  4033. if(!this.loaded) {
  4034. return;
  4035. }
  4036. if(this.playerType == 'flashplayer') {
  4037. this.V.videoMute();
  4038. return;
  4039. }
  4040. this.volumeTemp = this.V ? (this.V.volume > 0 ? this.V.volume : this.vars['volume']) : this.vars['volume'];
  4041. this.changeVolume(0);
  4042. },
  4043. /*
  4044. 接口函数
  4045. 取消静音
  4046. */
  4047. videoEscMute: function() {
  4048. if(!this.loaded) {
  4049. return;
  4050. }
  4051. if(this.playerType == 'flashplayer') {
  4052. this.V.videoEscMute();
  4053. return;
  4054. }
  4055. this.changeVolume(this.volumeTemp > 0 ? this.volumeTemp : this.vars['volume']);
  4056. },
  4057. /*
  4058. 接口函数
  4059. 快退
  4060. */
  4061. fastBack: function() {
  4062. if(!this.loaded) {
  4063. return;
  4064. }
  4065. if(this.playerType == 'flashplayer') {
  4066. this.V.fastBack();
  4067. return;
  4068. }
  4069. var time = this.time - this.ckplayerConfig['config']['timeJump'];
  4070. if(time < 0) {
  4071. time = 0;
  4072. }
  4073. this.videoSeek(time);
  4074. },
  4075. /*
  4076. 接口函数
  4077. 快进
  4078. */
  4079. fastNext: function() {
  4080. if(!this.loaded) {
  4081. return;
  4082. }
  4083. if(this.playerType == 'flashplayer') {
  4084. this.V.fastNext();
  4085. return;
  4086. }
  4087. var time = this.time + this.ckplayerConfig['config']['timeJump'];
  4088. if(time > this.V.duration) {
  4089. time = this.V.duration;
  4090. }
  4091. this.videoSeek(time);
  4092. },
  4093. /*
  4094. 接口函数
  4095. 获取当前播放的地址
  4096. */
  4097. getCurrentSrc:function(){
  4098. if(!this.loaded) {
  4099. return;
  4100. }
  4101. if(this.playerType == 'flashplayer') {
  4102. return this.V.getCurrentSrc();
  4103. }
  4104. return this.V.currentSrc;
  4105. },
  4106. /*
  4107. 内置函数
  4108. 全屏/退出全屏动作,该动作只能是用户操作才可以触发,比如用户点击按钮触发该事件
  4109. */
  4110. switchFull: function() {
  4111. if(this.full) {
  4112. this.quitFullScreen();
  4113. } else {
  4114. this.fullScreen();
  4115. }
  4116. },
  4117. /*
  4118. 内置函数
  4119. 全屏动作,该动作只能是用户操作才可以触发,比如用户点击按钮触发该事件
  4120. */
  4121. fullScreen: function() {
  4122. if(this.html5Video && this.playerType == 'html5video') {
  4123. var element = this.PD;
  4124. if(element.requestFullscreen) {
  4125. element.requestFullscreen();
  4126. } else if(element.mozRequestFullScreen) {
  4127. element.mozRequestFullScreen();
  4128. } else if(element.webkitRequestFullscreen) {
  4129. element.webkitRequestFullscreen();
  4130. } else if(element.msRequestFullscreen) {
  4131. element.msRequestFullscreen();
  4132. } else if(element.oRequestFullscreen) {
  4133. element.oRequestFullscreen();
  4134. }
  4135. this.judgeFullScreen();
  4136. } else {
  4137. //this.V.fullScreen();
  4138. }
  4139. },
  4140. /*
  4141. 接口函数
  4142. 退出全屏动作
  4143. */
  4144. quitFullScreen: function() {
  4145. if(this.html5Video && this.playerType == 'html5video') {
  4146. if(document.exitFullscreen) {
  4147. document.exitFullscreen();
  4148. } else if(document.msExitFullscreen) {
  4149. document.msExitFullscreen();
  4150. } else if(document.mozCancelFullScreen) {
  4151. document.mozCancelFullScreen();
  4152. } else if(document.oRequestFullscreen) {
  4153. document.oCancelFullScreen();
  4154. } else if(document.requestFullscreen) {
  4155. document.requestFullscreen();
  4156. } else if(document.webkitExitFullscreen) {
  4157. document.webkitExitFullscreen();
  4158. } else {
  4159. this.css(document.documentElement, 'cssText', '');
  4160. this.css(document.document.body, 'cssText', '');
  4161. this.css(this.PD, 'cssText', '');
  4162. }
  4163. this.judgeFullScreen();
  4164. }
  4165. },
  4166. /*
  4167. 下面列出只有flashplayer里支持的
  4168. */
  4169. videoRotation: function(n) {
  4170. if(!this.loaded) {
  4171. return;
  4172. }
  4173. if(this.playerType == 'flashplayer') {
  4174. this.V.videoRotation(n);
  4175. return;
  4176. }
  4177. if(this.isUndefined(n)) {
  4178. n = 0;
  4179. }
  4180. var tf = this.css(this.V, 'transform');
  4181. if(this.isUndefined(tf) && !tf) {
  4182. tf = 'rotate(0deg)';
  4183. }
  4184. var reg = tf.match(/rotate\([^)]+\)/);
  4185. reg = reg ? reg[0].replace('rotate(', '').replace('deg)', '') : '';
  4186. if(reg == '') {
  4187. reg = 0;
  4188. } else {
  4189. reg = parseInt(reg);
  4190. }
  4191. if(n == -1) {
  4192. reg -= 90;
  4193. } else if(n == 1) {
  4194. reg += 90;
  4195. } else {
  4196. if(n != 90 && n != 180 && n != 270 && n != -90 && n != -180 && n != -270) {
  4197. reg = 0;
  4198. } else {
  4199. reg = n;
  4200. }
  4201. }
  4202. n = reg;
  4203. tf = tf.replace(/rotate\([^)]+\)/, '') + ' rotate(' + n + 'deg)';
  4204. this.css(this.V, 'transform', tf);
  4205. return;
  4206. },
  4207. videoBrightness: function(n) {
  4208. if(!this.loaded) {
  4209. return;
  4210. }
  4211. if(this.playerType == 'flashplayer') {
  4212. this.V.videoBrightness(n);
  4213. return;
  4214. }
  4215. },
  4216. videoContrast: function(n) {
  4217. if(!this.loaded) {
  4218. return;
  4219. }
  4220. if(this.playerType == 'flashplayer') {
  4221. this.V.videoContrast(n);
  4222. return;
  4223. }
  4224. },
  4225. videoSaturation: function(n) {
  4226. if(!this.loaded) {
  4227. return;
  4228. }
  4229. if(this.playerType == 'flashplayer') {
  4230. this.V.videoSaturation(n);
  4231. return;
  4232. }
  4233. },
  4234. videoHue: function(n) {
  4235. if(!this.loaded) {
  4236. return;
  4237. }
  4238. if(this.playerType == 'flashplayer') {
  4239. this.V.videoHue(n);
  4240. return;
  4241. }
  4242. },
  4243. videoZoom: function(n) {
  4244. if(!this.loaded) {
  4245. return;
  4246. }
  4247. if(this.playerType == 'flashplayer') {
  4248. this.V.videoZoom(n);
  4249. return;
  4250. }
  4251. if(this.isUndefined(n)) {
  4252. n = 1;
  4253. }
  4254. if(n < 0) {
  4255. n = 0;
  4256. }
  4257. if(n > 2) {
  4258. n = 2;
  4259. }
  4260. var tf = this.css(this.V, 'transform');
  4261. tf = tf.replace(/scale\([^)]+\)/, '') + ' scale(' + n + ')';
  4262. this.css(this.V, 'transform', tf);
  4263. return;
  4264. },
  4265. videoProportion: function(w, h) {
  4266. if(!this.loaded) {
  4267. return;
  4268. }
  4269. if(this.playerType == 'flashplayer') {
  4270. this.V.videoProportion(w, h);
  4271. return;
  4272. }
  4273. },
  4274. adPlay: function() {
  4275. if(!this.loaded) {
  4276. return;
  4277. }
  4278. if(this.playerType == 'flashplayer') {
  4279. this.V.adPlay();
  4280. return;
  4281. }
  4282. },
  4283. adPause: function() {
  4284. if(!this.loaded) {
  4285. return;
  4286. }
  4287. if(this.playerType == 'flashplayer') {
  4288. this.V.adPause();
  4289. return;
  4290. }
  4291. },
  4292. videoError: function(n) {
  4293. if(!this.loaded) {
  4294. return;
  4295. }
  4296. if(this.playerType == 'flashplayer') {
  4297. this.V.videoError(n);
  4298. return;
  4299. }
  4300. },
  4301. changeConfig: function() {
  4302. if(!this.loaded) {
  4303. return;
  4304. }
  4305. if(this.playerType == 'flashplayer') {
  4306. this.V.changeConfig(arguments);
  4307. return;
  4308. }
  4309. var obj = this.ckplayerConfig;
  4310. var arg = arguments;
  4311. for(var i = 0; i < arg.length - 1; i++) {
  4312. if(obj.hasOwnProperty(arg[i])) {
  4313. obj = obj[arg[i]];
  4314. } else {
  4315. return;
  4316. }
  4317. }
  4318. var val = arg[arg.length - 1];
  4319. switch(arg.length) {
  4320. case 2:
  4321. this.ckplayerConfig[arg[0]] = val;
  4322. break;
  4323. case 3:
  4324. this.ckplayerConfig[arg[0]][arg[1]] = val;
  4325. break;
  4326. case 4:
  4327. this.ckplayerConfig[arg[0]][arg[1]][arg[2]] = val;
  4328. break;
  4329. case 5:
  4330. this.ckplayerConfig[arg[0]][arg[1]][arg[2]][arg[3]] = val;
  4331. break;
  4332. case 6:
  4333. this.ckplayerConfig[arg[0]][arg[1]][arg[2]][arg[3]][arg[4]] = val;
  4334. break;
  4335. case 7:
  4336. this.ckplayerConfig[arg[0]][arg[1]][arg[2]][arg[3]][arg[4]][arg[5]] = val;
  4337. break;
  4338. case 8:
  4339. this.ckplayerConfig[arg[0]][arg[1]][arg[2]][arg[3]][arg[4]][arg[5]][arg[6]] = val;
  4340. break;
  4341. case 9:
  4342. this.ckplayerConfig[arg[0]][arg[1]][arg[2]][arg[3]][arg[4]][arg[5]][arg[6]][arg[7]] = val;
  4343. break;
  4344. case 10:
  4345. this.ckplayerConfig[arg[0]][arg[1]][arg[2]][arg[3]][arg[4]][arg[5]][arg[6]][arg[7]][arg[8]] = val;
  4346. break;
  4347. default:
  4348. return;
  4349. break;
  4350. }
  4351. this.sendJS('configChange', this.ckplayerConfig);
  4352. },
  4353. custom: function() {
  4354. if(!this.loaded) {
  4355. return;
  4356. }
  4357. if(this.playerType == 'flashplayer') {
  4358. this.V.custom(arguments);
  4359. return;
  4360. }
  4361. },
  4362. getConfig: function() {
  4363. if(!this.loaded) {
  4364. return null;
  4365. }
  4366. if(this.playerType == 'flashplayer') {
  4367. return this.V.getConfig(arguments);
  4368. }
  4369. },
  4370. openUrl: function(n) {
  4371. if(!this.loaded) {
  4372. return;
  4373. }
  4374. if(this.playerType == 'flashplayer') {
  4375. this.V.openUrl(n);
  4376. return;
  4377. }
  4378. },
  4379. /*
  4380. 接口函数
  4381. 清除视频
  4382. */
  4383. videoClear: function() {
  4384. if(!this.loaded) {
  4385. return;
  4386. }
  4387. if(this.playerType == 'flashplayer') {
  4388. this.V.videoClear();
  4389. return;
  4390. }
  4391. },
  4392. /*
  4393. 接口函数
  4394. 向播放器传递新的视频地址
  4395. */
  4396. newVideo: function(c) {
  4397. if(this.playerType == 'flashplayer') {
  4398. this.V.newVideo(c);
  4399. return;
  4400. } else {
  4401. this.embed(c);
  4402. }
  4403. },
  4404. /*
  4405. 接口函数
  4406. 截图
  4407. */
  4408. screenshot: function(obj, save, name) {
  4409. if(!this.loaded) {
  4410. return;
  4411. }
  4412. if(this.playerType == 'flashplayer') {
  4413. try {
  4414. this.V.screenshot(obj, save, name);
  4415. } catch(error) {
  4416. this.log(error);
  4417. }
  4418. return;
  4419. }
  4420. if(obj == 'video') {
  4421. var newCanvas = document.createElement('canvas');
  4422. newCanvas.width = this.V.videoWidth;
  4423. newCanvas.height = this.V.videoHeight;
  4424. newCanvas.getContext('2d').drawImage(this.V, 0, 0, this.V.videoWidth, this.V.videoHeight);
  4425. try {
  4426. var base64 = newCanvas.toDataURL('image/jpeg');
  4427. this.sendJS('screenshot', {
  4428. object: obj,
  4429. save: save,
  4430. name: name,
  4431. base64: base64
  4432. });
  4433. } catch(error) {
  4434. this.log(error);
  4435. }
  4436. }
  4437. },
  4438. /*
  4439. 接口函数
  4440. 改变播放器尺寸
  4441. */
  4442. changeSize: function(w, h) {
  4443. if(this.isUndefined(w)) {
  4444. w = 0;
  4445. }
  4446. if(this.isUndefined(h)) {
  4447. h = 0;
  4448. }
  4449. if(w > 0) {
  4450. this.css(this.CD, 'width', w + 'px');
  4451. }
  4452. if(h > 0) {
  4453. this.css(this.CD, 'height', h + 'px');
  4454. }
  4455. if(this.html5Video) {
  4456. this.elementCoordinate();
  4457. }
  4458. },
  4459. /*
  4460. 接口函数
  4461. 改变视频播放速度
  4462. */
  4463. changePlaybackRate: function(n) {
  4464. if(this.html5Video) {
  4465. var arr = this.playbackRateArr;
  4466. n = parseInt(n);
  4467. if(n < arr.length) {
  4468. this.newPlaybackrate(arr[n][1]);
  4469. }
  4470. }
  4471. },
  4472. /*
  4473. 内部函数
  4474. 注册控制控制栏显示与隐藏函数
  4475. */
  4476. changeControlBarShow: function(show) {
  4477. if(!this.loaded) {
  4478. return;
  4479. }
  4480. if(this.playerType == 'flashplayer') {
  4481. this.V.changeControlBarShow(show);
  4482. return;
  4483. }
  4484. if(show) {
  4485. this.controlBarIsShow = true;
  4486. this.controlBarHide(false);
  4487. } else {
  4488. this.controlBarIsShow = false;
  4489. this.controlBarHide(true);
  4490. }
  4491. },
  4492. /*
  4493. -----------------------------------------------------------------------
  4494. 调用flashplayer
  4495. */
  4496. embedSWF: function() {
  4497. var vid = this.randomString();
  4498. var flashvars = this.getFlashVars();
  4499. var param = this.getFlashplayerParam();
  4500. var flashplayerUrl = 'http://www.macromedia.com/go/getflashplayer';
  4501. var html = '',
  4502. src = javascriptPath + 'ckplayer.swf';
  4503. id = 'id="' + vid + '" name="' + vid + '" ';
  4504. html += '<object pluginspage="' + flashplayerUrl + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=11,3,0,0" width="100%" height="100%" ' + id + ' align="middle">';
  4505. html += param['v'];
  4506. html += '<param name="movie" value="' + src + '">';
  4507. html += '<param name="flashvars" value="' + flashvars + '">';
  4508. html += '<embed ' + param['w'] + ' src="' + src + '" flashvars="' + flashvars + '" width="100%" height="100%" ' + id + ' align="middle" type="application/x-shockwave-flash" pluginspage="' + flashplayerUrl + '" />';
  4509. html += '</object>';
  4510. this.PD.innerHTML = html;
  4511. this.V = this.getObjectById(vid); //V:定义播放器对象全局变量
  4512. this.playerType = 'flashplayer';
  4513. //this.loaded=true;
  4514. },
  4515. /*
  4516. 内置函数
  4517. 将vars对象转换成字符
  4518. */
  4519. getFlashVars: function() {
  4520. this.getVarsObject();
  4521. var v = this.vars;
  4522. var z = '';
  4523. for(k in v) {
  4524. if(k != 'flashplayer' && k != 'container' && v[k] != '') {
  4525. if(z != '') {
  4526. z += '&';
  4527. }
  4528. var vk = v[k];
  4529. if(vk == true) {
  4530. vk = 1;
  4531. }
  4532. if(vk == false) {
  4533. vk = 0;
  4534. }
  4535. z += k + '=' + vk;
  4536. }
  4537. }
  4538. if(!v.hasOwnProperty('volume') || !v['volume']) {
  4539. if(z != '') {
  4540. z += '&';
  4541. }
  4542. z += 'volume=0';
  4543. }
  4544. return z;
  4545. },
  4546. /*
  4547. 内置函数
  4548. 将vars格式化成flash能接受的对象。再由getFlashVars函数转化成字符串或由newVideo直接使用
  4549. */
  4550. getVarsObject: function() {
  4551. var v = this.vars;
  4552. var f = '',
  4553. d = '',
  4554. w = ''; //f=视频地址,d=清晰度地址,w=权重,z=最终地址
  4555. var arr = this.VA;
  4556. var prompt = v['promptSpot'];
  4557. var i = 0;
  4558. var video = this.vars['video'];
  4559. if(typeof(video) == 'object') { //对象或数组
  4560. if(!this.isUndefined(typeof(video.length))) { //说明是数组
  4561. var arr = video;
  4562. for(i = 0; i < arr.length; i++) {
  4563. var arr2 = arr[i];
  4564. if(arr2) {
  4565. if(f != '') {
  4566. f += this.ckplayerConfig['config']['split'];
  4567. d += ',';
  4568. w += ',';
  4569. v['type']+=this.ckplayerConfig['config']['split'];
  4570. }
  4571. f += encodeURIComponent(decodeURIComponent(arr2[0]));
  4572. d += arr2[2];
  4573. w += arr2[3];
  4574. v['type']+=arr2[1].replace('video/','');
  4575. }
  4576. }
  4577. } else {
  4578. f = encodeURIComponent(decodeURIComponent(video['file']));
  4579. if(!this.isUndefined(video['type'])) {
  4580. v['type'] = video['type'];
  4581. }
  4582. d = '';
  4583. w = '';
  4584. }
  4585. } else {
  4586. f = encodeURIComponent(decodeURIComponent(video));
  4587. }
  4588. if(v['preview'] != null) {
  4589. v['previewscale'] = v['preview']['scale'];
  4590. v['preview'] = v['preview']['file'].join(',');
  4591. }
  4592. if(prompt != null) {
  4593. v['promptspot'] = '';
  4594. v['promptspottime'] = '';
  4595. for(i = 0; i < prompt.length; i++) {
  4596. if(v['promptspot'] != '') {
  4597. v['promptspot'] += ',';
  4598. v['promptspottime'] += ',';
  4599. }
  4600. v['promptspot'] += prompt[i]['words'];
  4601. v['promptspottime'] += prompt[i]['time'];
  4602. }
  4603. }
  4604. if(f != '') {
  4605. v['video'] = f;
  4606. v['definition'] = d;
  4607. v['weight'] = w;
  4608. }
  4609. if(!v['volume']) {
  4610. v['volume'] = 0;
  4611. }
  4612. var newV = {};
  4613. for(var k in v) {
  4614. if(v[k] != null) {
  4615. newV[k] = v[k];
  4616. }
  4617. if(k == 'type') {
  4618. newV[k] = v[k].replace('video/m3u8', 'm3u8');
  4619. }
  4620. }
  4621. this.vars = newV;
  4622. },
  4623. /*
  4624. 内置函数
  4625. 将embedSWF里的param的对象进行转换
  4626. */
  4627. getFlashplayerParam: function() {
  4628. var w = '',
  4629. v = '',
  4630. o = {
  4631. allowScriptAccess: 'always',
  4632. allowFullScreen: true,
  4633. quality: 'high',
  4634. bgcolor: '#000'
  4635. };
  4636. for(var e in o) {
  4637. w += e + '="' + o[e] + '" ';
  4638. v += '<param name="' + e + '" value="' + o[e] + '" />';
  4639. }
  4640. w = w.replace('movie=', 'src=');
  4641. return {
  4642. w: w,
  4643. v: v
  4644. };
  4645. },
  4646. /*
  4647. 操作动作结束
  4648. -----------------------------------------------------------------------
  4649. 接口函数
  4650. 获取元数据部分
  4651. */
  4652. getMetaDate: function() {
  4653. if(!this.loaded || this.V == null) {
  4654. return false;
  4655. }
  4656. if(this.playerType == 'html5video') {
  4657. var duration = 0;
  4658. try {
  4659. duration = !isNaN(this.V.duration) ? this.V.duration : 0;
  4660. } catch(event) {this.log(event);}
  4661. var data = {
  4662. duration: duration,
  4663. volume: this.V.volume,
  4664. playbackRate: this.V.playbackRate,
  4665. width: this.PD.offsetWidth || this.V.offsetWidth || this.V.width,
  4666. height: this.PD.offsetHeight || this.V.offsetHeight || this.V.height,
  4667. streamWidth: this.V.videoWidth,
  4668. streamHeight: this.V.videoHeight,
  4669. videoWidth: this.V.offsetWidth,
  4670. videoHeight: this.V.offsetHeight,
  4671. paused: this.V.paused
  4672. };
  4673. return data;
  4674. } else {
  4675. try{
  4676. return this.V.getMetaDate();
  4677. }
  4678. catch(event){
  4679. this.log(event);
  4680. }
  4681. }
  4682. return false;
  4683. },
  4684. /*
  4685. 接口函数
  4686. 取当前提供给播放器播放的视频列表
  4687. */
  4688. getVideoUrl: function() {
  4689. if(this.playerType == 'flashplayer') {
  4690. return this.V.getVideoUrl();
  4691. }
  4692. var arr = [];
  4693. if(this.V.src) {
  4694. arr.push(this.V.src);
  4695. } else {
  4696. var uArr = this.V.childNodes;
  4697. for(var i = 0; i < uArr.length; i++) {
  4698. arr.push(uArr[i].src);
  4699. }
  4700. }
  4701. return arr;
  4702. },
  4703. /*
  4704. 内置函数
  4705. 格式化函数
  4706. */
  4707. clickEvent: function(call) {
  4708. if(call == 'none' || call == '' || call == null) {
  4709. return {
  4710. type: 'none'
  4711. };
  4712. }
  4713. var callArr = call.split('->');
  4714. var type = '',
  4715. fun = '',
  4716. link = '',
  4717. target = '';
  4718. if(callArr.length == 2) {
  4719. var callM = callArr[0];
  4720. var callE = callArr[1];
  4721. if(!callE) {
  4722. return {
  4723. type: 'none'
  4724. };
  4725. }
  4726. var val = '';
  4727. var eArr = [];
  4728. type = callM;
  4729. switch(callM) {
  4730. case 'actionScript':
  4731. //trace(THIS.hasOwnProperty(callE));
  4732. if(callE.indexOf('(') > -1) {
  4733. eArr = callE.split('(');
  4734. callE = eArr[0];
  4735. val = eArr[1].replace(')', '');
  4736. }
  4737. if(val == '') {
  4738. fun = 'thisTemp.' + callE + '()';
  4739. } else {
  4740. fun = 'thisTemp.' + callE + '(' + val + ')';
  4741. }
  4742. break;
  4743. case 'javaScript':
  4744. if(callE.substr(0, 11) == '[flashvars]') {
  4745. callE = callE.substr(11);
  4746. if(this.vars.hasOwnProperty(callE)) {
  4747. callE = this.vars[callE];
  4748. } else {
  4749. break;
  4750. }
  4751. }
  4752. if(callE.indexOf('(') > -1) {
  4753. eArr = callE.split('(');
  4754. callE = eArr[0];
  4755. val = eArr[1].replace(')', '');
  4756. }
  4757. if(val == '') {
  4758. fun = callE + '()';
  4759. } else {
  4760. fun = callE + '(' + val + ')';
  4761. }
  4762. break;
  4763. case "link":
  4764. var callLink = (callE + ',').split(',');
  4765. if(callLink[0].substr(0, 11) == '[flashvars]') {
  4766. var fl = callLink[0].replace('[flashvars]', '');
  4767. if(this.vars.hasOwnProperty(fl)) {
  4768. callLink[0] = this.vars[fl];
  4769. } else {
  4770. break;
  4771. }
  4772. }
  4773. if(!callLink[1]) {
  4774. callLink[1] = '_blank';
  4775. }
  4776. link = callLink[0];
  4777. target = callLink[1];
  4778. break;
  4779. }
  4780. }
  4781. return {
  4782. type: type,
  4783. fun: fun,
  4784. link: link,
  4785. target: target
  4786. }
  4787. },
  4788. /*
  4789. 内置函数
  4790. 向播放器界面添加一个文本
  4791. */
  4792. addElement: function(attribute) {
  4793. var thisTemp = this;
  4794. if(this.playerType == 'flashplayer') {
  4795. return this.V.addElement(attribute);
  4796. }
  4797. var i = 0;
  4798. var obj = {
  4799. list: null,
  4800. x: '100%',
  4801. y: "50%",
  4802. position: null,
  4803. alpha: 1,
  4804. backgroundColor: '',
  4805. backAlpha: 1,
  4806. backRadius: 0,
  4807. clickEvent: ''
  4808. };
  4809. obj = this.standardization(obj, attribute);
  4810. var list = obj['list'];
  4811. if(list == null) {
  4812. return '';
  4813. }
  4814. var id = 'element' + this.randomString(10);
  4815. var ele = document.createElement('div');
  4816. ele.className = id;
  4817. if(obj['x']) {
  4818. ele.setAttribute('data-x', obj['x']);
  4819. }
  4820. if(obj['y']) {
  4821. ele.setAttribute('data-y', obj['y']);
  4822. }
  4823. if(obj['position'] != null) {
  4824. ele.setAttribute('data-position', obj['position'].join(','));
  4825. }
  4826. this.PD.appendChild(ele);
  4827. var eid = this.getByElement(id);
  4828. this.css(eid, {
  4829. position: 'absolute',
  4830. filter: 'alpha(opacity:' + obj['alpha'] + ')',
  4831. opacity: obj['alpha'].toString(),
  4832. width: '800px',
  4833. zIndex: '20'
  4834. });
  4835. var bgid = 'elementbg' + this.randomString(10);
  4836. var bgAlpha = obj['alpha'].toString();
  4837. var bgColor = obj['backgroundColor'].replace('0x', '#');
  4838. var html = '';
  4839. var idArr = [];
  4840. var clickArr = [];
  4841. if(!this.isUndefined(list) && list.length > 0) {
  4842. var textObj, returnObj, clickEvent;
  4843. for(i = 0; i < list.length; i++) {
  4844. var newEleid = 'elementnew' + this.randomString(10);
  4845. switch(list[i]['type']) {
  4846. case 'image':
  4847. case 'png':
  4848. case 'jpg':
  4849. case 'jpeg':
  4850. case 'gif':
  4851. textObj = {
  4852. type: 'image',
  4853. file: '',
  4854. radius: 0, //圆角弧度
  4855. width: 30, //定义宽,必需要定义
  4856. height: 30, //定义高,必需要定义
  4857. alpha: 1, //透明度
  4858. paddingLeft: 0, //左边距离
  4859. paddingRight: 0, //右边距离
  4860. paddingTop: 0,
  4861. paddingBottom: 0,
  4862. marginLeft: 0,
  4863. marginRight: 0,
  4864. marginTop: 0,
  4865. marginBottom: 0,
  4866. backgroundColor: '',
  4867. clickEvent: ''
  4868. };
  4869. list[i] = this.standardization(textObj, list[i]);
  4870. clickEvent = this.clickEvent(list[i]['clickEvent']);
  4871. clickArr.push(clickEvent);
  4872. if(clickEvent['type'] == 'link') {
  4873. html += '<div class="' + newEleid + '" data-i="' + i + '"><a href="' + clickEvent['link'] + '" target="' + clickEvent['target'] + '"><img class="' + newEleid + '_image" src="' + list[i]['file'] + '" style="border:0;"></a></div>';
  4874. } else {
  4875. html += '<div class="' + newEleid + '" data-i="' + i + '"><img class="' + newEleid + '_image" src="' + list[i]['file'] + '" style="border:0;"></div>';
  4876. }
  4877. break;
  4878. case 'text':
  4879. textObj = {
  4880. type: 'text', //说明是文本
  4881. text: '', //文本内容
  4882. color: '0xFFFFFF',
  4883. size: 14,
  4884. font: this.fontFamily,
  4885. leading: 0,
  4886. alpha: 1, //透明度
  4887. paddingLeft: 0, //左边距离
  4888. paddingRight: 0, //右边距离
  4889. paddingTop: 0,
  4890. paddingBottom: 0,
  4891. marginLeft: 0,
  4892. marginRight: 0,
  4893. marginTop: 0,
  4894. marginBottom: 0,
  4895. backgroundColor: '',
  4896. backAlpha: 1,
  4897. backRadius: 0, //背景圆角弧度,支持数字统一设置,也支持分开设置[30,20,20,50],对应上左,上右,下右,下左
  4898. clickEvent: ''
  4899. };
  4900. list[i] = this.standardization(textObj, list[i]);
  4901. clickEvent = this.clickEvent(list[i]['clickEvent']);
  4902. clickArr.push(clickEvent);
  4903. if(clickEvent['type'] == 'link') {
  4904. html += '<div class="' + newEleid + '" data-i="' + i + '"><div class="' + newEleid + '_bg"></div><div class="' + newEleid + '_text"><a href="' + clickEvent['link'] + '" target="' + clickEvent['target'] + '">' + list[i]['text'] + '</a></div></div>';
  4905. } else {
  4906. html += '<div class="' + newEleid + '" data-i="' + i + '"><div class="' + newEleid + '_bg"></div><div class="' + newEleid + '_text">' + list[i]['text'] + '</div></div>';
  4907. }
  4908. break;
  4909. default:
  4910. break;
  4911. }
  4912. idArr.push(newEleid);
  4913. }
  4914. }
  4915. var objClickEvent = this.clickEvent(obj['clickEvent']);
  4916. /*if(objClickEvent['type']=='link'){
  4917. html = '<a href="'+objClickEvent['link']+'" target="'+objClickEvent['target']+'">' + html + '</a>';
  4918. }*/
  4919. eid.innerHTML = '<div class="' + bgid + '"></div><div class="' + bgid + '_c">' + html + '</div>';
  4920. if(objClickEvent['type'] == 'javaScript' || objClickEvent['type'] == 'actionScript') {
  4921. var objClickHandler = function() {
  4922. eval(objClickEvent['fun']);
  4923. thisTemp.sendJS('clickEvent', clk['type'] + '->' + clk['fun'].replace('thisTemp.', '').replace('()', ''));
  4924. };
  4925. this.addListenerInside('click', objClickHandler, this.getByElement(bgid + '_c'))
  4926. }
  4927. this.css(bgid + '_c', {
  4928. position: 'absolute',
  4929. zIndex: '2'
  4930. });
  4931. for(i = 0; i < idArr.length; i++) {
  4932. var clk = clickArr[i];
  4933. if(clk['type'] == 'javaScript' || clk['type'] == 'actionScript') {
  4934. var clickHandler = function() {
  4935. clk = clickArr[this.getAttribute('data-i')];
  4936. eval(clk['fun']);
  4937. thisTemp.sendJS('clickEvent', clk['type'] + '->' + clk['fun'].replace('thisTemp.', '').replace('()', ''));
  4938. };
  4939. this.addListenerInside('click', clickHandler, this.getByElement(idArr[i]))
  4940. }
  4941. switch(list[i]['type']) {
  4942. case 'image':
  4943. case 'png':
  4944. case 'jpg':
  4945. case 'jpeg':
  4946. case 'gif':
  4947. this.css(idArr[i], {
  4948. float: 'left',
  4949. width: list[i]['width'] + 'px',
  4950. height: list[i]['height'] + 'px',
  4951. filter: 'alpha(opacity:' + list[i]['alpha'] + ')',
  4952. opacity: list[i]['alpha'].toString(),
  4953. marginLeft: list[i]['marginLeft'] + 'px',
  4954. marginRight: list[i]['marginRight'] + 'px',
  4955. marginTop: list[i]['marginTop'] + 'px',
  4956. marginBottom: list[i]['marginBottom'] + 'px',
  4957. borderRadius: list[i]['radius'] + 'px',
  4958. cursor: 'pointer'
  4959. });
  4960. this.css(idArr[i] + '_image', {
  4961. width: list[i]['width'] + 'px',
  4962. height: list[i]['height'] + 'px',
  4963. borderRadius: list[i]['radius'] + 'px'
  4964. });
  4965. break;
  4966. case 'text':
  4967. this.css(idArr[i] + '_text', {
  4968. filter: 'alpha(opacity:' + list[i]['alpha'] + ')',
  4969. opacity: list[i]['alpha'].toString(),
  4970. borderRadius: list[i]['radius'] + 'px',
  4971. fontFamily: list[i]['font'],
  4972. fontSize: list[i]['size'] + 'px',
  4973. color: list[i]['color'].replace('0x', '#'),
  4974. lineHeight: list[i]['leading'] > 0 ? list[i]['leading'] + 'px' : '',
  4975. paddingLeft: list[i]['paddingLeft'] + 'px',
  4976. paddingRight: list[i]['paddingRight'] + 'px',
  4977. paddingTop: list[i]['paddingTop'] + 'px',
  4978. paddingBottom: list[i]['paddingBottom'] + 'px',
  4979. whiteSpace: 'nowrap',
  4980. position: 'absolute',
  4981. zIndex: '3',
  4982. cursor: 'pointer'
  4983. });
  4984. this.css(idArr[i], {
  4985. float: 'left',
  4986. width: this.getByElement(idArr[i] + '_text').offsetWidth + 'px',
  4987. height: this.getByElement(idArr[i] + '_text').offsetHeight + 'px',
  4988. marginLeft: list[i]['marginLeft'] + 'px',
  4989. marginRight: list[i]['marginRight'] + 'px',
  4990. marginTop: list[i]['marginTop'] + 'px',
  4991. marginBottom: list[i]['marginBottom'] + 'px'
  4992. });
  4993. this.css(idArr[i] + '_bg', {
  4994. width: this.getByElement(idArr[i] + '_text').offsetWidth + 'px',
  4995. height: this.getByElement(idArr[i] + '_text').offsetHeight + 'px',
  4996. filter: 'alpha(opacity:' + list[i]['backAlpha'] + ')',
  4997. opacity: list[i]['backAlpha'].toString(),
  4998. borderRadius: list[i]['backRadius'] + 'px',
  4999. backgroundColor: list[i]['backgroundColor'].replace('0x', '#'),
  5000. position: 'absolute',
  5001. zIndex: '2'
  5002. });
  5003. break;
  5004. default:
  5005. break;
  5006. }
  5007. }
  5008. this.css(bgid, {
  5009. width: this.getByElement(bgid + '_c').offsetWidth + 'px',
  5010. height: this.getByElement(bgid + '_c').offsetHeight + 'px',
  5011. position: 'absolute',
  5012. filter: 'alpha(opacity:' + bgAlpha + ')',
  5013. opacity: bgAlpha,
  5014. backgroundColor: bgColor.replace('0x', '#'),
  5015. borderRadius: obj['backRadius'] + 'px',
  5016. zIndex: '1'
  5017. });
  5018. this.css(eid, {
  5019. width: this.getByElement(bgid).offsetWidth + 'px',
  5020. height: this.getByElement(bgid).offsetHeight + 'px'
  5021. });
  5022. var eidCoor = this.calculationCoor(eid);
  5023. this.css(eid, {
  5024. left: eidCoor['x'] + 'px',
  5025. top: eidCoor['y'] + 'px'
  5026. });
  5027. this.elementArr.push(eid.className);
  5028. return eid;
  5029. },
  5030. /*
  5031. 内置函数
  5032. 获取元件的属性,包括x,y,width,height,alpha
  5033. */
  5034. getElement: function(element) {
  5035. if(this.playerType == 'flashplayer') {
  5036. return this.V.getElement(element);
  5037. }
  5038. var ele = element;
  5039. if(typeof(element) == 'string') {
  5040. ele = this.getByElement(element);
  5041. }
  5042. var coor = this.getCoor(ele);
  5043. return {
  5044. x: coor['x'],
  5045. y: coor['y'],
  5046. width: ele.offsetWidth,
  5047. height: ele.offsetHeight,
  5048. alpha: !this.isUndefined(this.css(ele, 'opacity')) ? parseFloat(this.css(ele, 'opacity')) : 1
  5049. };
  5050. },
  5051. /*
  5052. 内置函数
  5053. 根据节点的x,y计算在播放器里的坐标
  5054. */
  5055. calculationCoor: function(ele) {
  5056. if(this.playerType == 'flashplayer') {
  5057. return this.V.calculationCoor(ele);
  5058. }
  5059. if(ele == []) {
  5060. return;
  5061. }
  5062. var x, y, position = [];
  5063. var w = this.PD.offsetWidth,
  5064. h = this.PD.offsetHeight;
  5065. var ew = ele.offsetWidth,
  5066. eh = ele.offsetHeight;
  5067. if(!this.isUndefined(this.getDataset(ele, 'x'))) {
  5068. x = this.getDataset(ele, 'x');
  5069. }
  5070. if(!this.isUndefined(this.getDataset(ele, 'y'))) {
  5071. y = this.getDataset(ele, 'y');
  5072. }
  5073. if(!this.isUndefined(this.getDataset(ele, 'position'))) {
  5074. try{
  5075. position = this.getDataset(ele, 'position').toString().split(',');
  5076. }
  5077. catch(event){}
  5078. }
  5079. if(position.length > 0) {
  5080. position.push(null, null, null, null);
  5081. var i = 0;
  5082. for(i = 0; i < position.length; i++) {
  5083. if(this.isUndefined(position[i]) || position[i] == null || position[i] == 'null' || position[i] == '') {
  5084. position[i] = null;
  5085. } else {
  5086. position[i] = parseFloat(position[i]);
  5087. }
  5088. }
  5089. if(position[2] == null) {
  5090. switch(position[0]) {
  5091. case 0:
  5092. x = 0;
  5093. break;
  5094. case 1:
  5095. x = parseInt((w - ew) * 0.5);
  5096. break;
  5097. default:
  5098. x = w - ew;
  5099. break;
  5100. }
  5101. } else {
  5102. switch(position[0]) {
  5103. case 0:
  5104. x = position[2];
  5105. break;
  5106. case 1:
  5107. x = parseInt(w * 0.5) + position[2];
  5108. break;
  5109. default:
  5110. x = w + position[2];
  5111. break;
  5112. }
  5113. }
  5114. if(position[3] == null) {
  5115. switch(position[1]) {
  5116. case 0:
  5117. y = 0;
  5118. break;
  5119. case 1:
  5120. y = parseInt((h - eh) * 0.5);
  5121. break;
  5122. default:
  5123. y = h - eh;
  5124. break;
  5125. }
  5126. } else {
  5127. switch(position[1]) {
  5128. case 0:
  5129. y = position[3];
  5130. break;
  5131. case 1:
  5132. y = parseInt(h * 0.5) + position[3];
  5133. break;
  5134. default:
  5135. y = h + position[3];
  5136. break;
  5137. }
  5138. }
  5139. } else {
  5140. if(x.substring(x.length - 1, x.length) == '%') {
  5141. x = Math.floor(parseInt(x.substring(0, x.length - 1)) * w * 0.01);
  5142. }
  5143. if(y.substring(y.length - 1, y.length) == '%') {
  5144. y = Math.floor(parseInt(y.substring(0, y.length - 1)) * h * 0.01);
  5145. }
  5146. }
  5147. return {
  5148. x: x,
  5149. y: y
  5150. }
  5151. },
  5152. /*
  5153. 内置函数
  5154. 修改新增元件的坐标
  5155. */
  5156. changeElementCoor: function() {
  5157. for(var i = 0; i < this.elementArr.length; i++) {
  5158. if(this.getByElement(this.elementArr[i]) != []) {
  5159. var c = this.calculationCoor(this.getByElement(this.elementArr[i]));
  5160. if(c['x'] && c['y']){
  5161. this.css(this.elementArr[i], {
  5162. top: c['y'] + 'px',
  5163. left: c['x'] + 'px'
  5164. });
  5165. }
  5166. }
  5167. }
  5168. },
  5169. /*
  5170. 内置函数
  5171. 缓动效果集
  5172. */
  5173. tween: function() {
  5174. var Tween = {
  5175. None: { //均速运动
  5176. easeIn: function(t, b, c, d) {
  5177. return c * t / d + b;
  5178. },
  5179. easeOut: function(t, b, c, d) {
  5180. return c * t / d + b;
  5181. },
  5182. easeInOut: function(t, b, c, d) {
  5183. return c * t / d + b;
  5184. }
  5185. },
  5186. Quadratic: {
  5187. easeIn: function(t, b, c, d) {
  5188. return c * (t /= d) * t + b;
  5189. },
  5190. easeOut: function(t, b, c, d) {
  5191. return -c * (t /= d) * (t - 2) + b;
  5192. },
  5193. easeInOut: function(t, b, c, d) {
  5194. if((t /= d / 2) < 1) return c / 2 * t * t + b;
  5195. return -c / 2 * ((--t) * (t - 2) - 1) + b;
  5196. }
  5197. },
  5198. Cubic: {
  5199. easeIn: function(t, b, c, d) {
  5200. return c * (t /= d) * t * t + b;
  5201. },
  5202. easeOut: function(t, b, c, d) {
  5203. return c * ((t = t / d - 1) * t * t + 1) + b;
  5204. },
  5205. easeInOut: function(t, b, c, d) {
  5206. if((t /= d / 2) < 1) return c / 2 * t * t * t + b;
  5207. return c / 2 * ((t -= 2) * t * t + 2) + b;
  5208. }
  5209. },
  5210. Quartic: {
  5211. easeIn: function(t, b, c, d) {
  5212. return c * (t /= d) * t * t * t + b;
  5213. },
  5214. easeOut: function(t, b, c, d) {
  5215. return -c * ((t = t / d - 1) * t * t * t - 1) + b;
  5216. },
  5217. easeInOut: function(t, b, c, d) {
  5218. if((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
  5219. return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
  5220. }
  5221. },
  5222. Quintic: {
  5223. easeIn: function(t, b, c, d) {
  5224. return c * (t /= d) * t * t * t * t + b;
  5225. },
  5226. easeOut: function(t, b, c, d) {
  5227. return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
  5228. },
  5229. easeInOut: function(t, b, c, d) {
  5230. if((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
  5231. return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
  5232. }
  5233. },
  5234. Sine: {
  5235. easeIn: function(t, b, c, d) {
  5236. return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
  5237. },
  5238. easeOut: function(t, b, c, d) {
  5239. return c * Math.sin(t / d * (Math.PI / 2)) + b;
  5240. },
  5241. easeInOut: function(t, b, c, d) {
  5242. return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
  5243. }
  5244. },
  5245. Exponential: {
  5246. easeIn: function(t, b, c, d) {
  5247. return(t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
  5248. },
  5249. easeOut: function(t, b, c, d) {
  5250. return(t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
  5251. },
  5252. easeInOut: function(t, b, c, d) {
  5253. if(t == 0) return b;
  5254. if(t == d) return b + c;
  5255. if((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
  5256. return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
  5257. }
  5258. },
  5259. Circular: {
  5260. easeIn: function(t, b, c, d) {
  5261. return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
  5262. },
  5263. easeOut: function(t, b, c, d) {
  5264. return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
  5265. },
  5266. easeInOut: function(t, b, c, d) {
  5267. if((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
  5268. return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
  5269. }
  5270. },
  5271. Elastic: {
  5272. easeIn: function(t, b, c, d, a, p) {
  5273. if(t == 0) return b;
  5274. if((t /= d) == 1) return b + c;
  5275. if(!p) p = d * .3;
  5276. if(!a || a < Math.abs(c)) {
  5277. a = c;
  5278. var s = p / 4;
  5279. } else var s = p / (2 * Math.PI) * Math.asin(c / a);
  5280. return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
  5281. },
  5282. easeOut: function(t, b, c, d, a, p) {
  5283. if(t == 0) return b;
  5284. if((t /= d) == 1) return b + c;
  5285. if(!p) p = d * .3;
  5286. if(!a || a < Math.abs(c)) {
  5287. a = c;
  5288. var s = p / 4;
  5289. } else var s = p / (2 * Math.PI) * Math.asin(c / a);
  5290. return(a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b);
  5291. },
  5292. easeInOut: function(t, b, c, d, a, p) {
  5293. if(t == 0) return b;
  5294. if((t /= d / 2) == 2) return b + c;
  5295. if(!p) p = d * (.3 * 1.5);
  5296. if(!a || a < Math.abs(c)) {
  5297. a = c;
  5298. var s = p / 4;
  5299. } else var s = p / (2 * Math.PI) * Math.asin(c / a);
  5300. if(t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
  5301. return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
  5302. }
  5303. },
  5304. Back: {
  5305. easeIn: function(t, b, c, d, s) {
  5306. if(s == undefined) s = 1.70158;
  5307. return c * (t /= d) * t * ((s + 1) * t - s) + b;
  5308. },
  5309. easeOut: function(t, b, c, d, s) {
  5310. if(s == undefined) s = 1.70158;
  5311. return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
  5312. },
  5313. easeInOut: function(t, b, c, d, s) {
  5314. if(s == undefined) s = 1.70158;
  5315. if((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
  5316. return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
  5317. }
  5318. },
  5319. Bounce: {
  5320. easeIn: function(t, b, c, d) {
  5321. return c - Tween.Bounce.easeOut(d - t, 0, c, d) + b;
  5322. },
  5323. easeOut: function(t, b, c, d) {
  5324. if((t /= d) < (1 / 2.75)) {
  5325. return c * (7.5625 * t * t) + b;
  5326. } else if(t < (2 / 2.75)) {
  5327. return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
  5328. } else if(t < (2.5 / 2.75)) {
  5329. return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
  5330. } else {
  5331. return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
  5332. }
  5333. },
  5334. easeInOut: function(t, b, c, d) {
  5335. if(t < d / 2) return Tween.Bounce.easeIn(t * 2, 0, c, d) * .5 + b;
  5336. else return Tween.Bounce.easeOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
  5337. }
  5338. }
  5339. };
  5340. return Tween;
  5341. },
  5342. /*
  5343. 接口函数
  5344. 缓动效果
  5345. ele:Object=需要缓动的对象,
  5346. parameter:String=需要改变的属性:x,y,width,height,alpha,
  5347. effect:String=效果名称,
  5348. start:Int=起始值,
  5349. end:Int=结束值,
  5350. speed:Number=运动的总秒数,支持小数
  5351. */
  5352. animate: function(attribute) {
  5353. if(this.playerType == 'flashplayer') {
  5354. return this.V.animate(attribute);
  5355. }
  5356. var thisTemp = this;
  5357. var animateId = 'animate_' + this.randomString();
  5358. var obj = {
  5359. element: null,
  5360. parameter: 'x',
  5361. static: false,
  5362. effect: 'None.easeIn',
  5363. start: null,
  5364. end: null,
  5365. speed: 0,
  5366. overStop: false,
  5367. pauseStop: false, //暂停播放时缓动是否暂停
  5368. callBack: null
  5369. };
  5370. obj = this.standardization(obj, attribute);
  5371. if(obj['element'] == null || obj['speed'] == 0) {
  5372. return false;
  5373. }
  5374. var w = this.PD.offsetWidth,
  5375. h = this.PD.offsetHeight;
  5376. var effArr = (obj['effect'] + '.').split('.');
  5377. var tweenFun = this.tween()[effArr[0]][effArr[1]];
  5378. var eleCoor = {
  5379. x: 0,
  5380. y: 0
  5381. };
  5382. if(this.isUndefined(tweenFun)) {
  5383. return false;
  5384. }
  5385. //先将该元件从元件数组里删除,让其不再跟随播放器的尺寸改变而改变位置
  5386. var def = this.arrIndexOf(this.elementArr, obj['element'].className);
  5387. if(def > -1) {
  5388. this.elementArr.splice(def, 1);
  5389. }
  5390. //var run = true;
  5391. var css = {};
  5392. //对传递的参数进行转化,x和y转化成left,top
  5393. var pm = this.getElement(obj['element']); //包含x,y,width,height,alpha属性
  5394. var t = 0; //当前时间
  5395. var b = 0; //初始值
  5396. var c = 0; //变化量
  5397. var d = obj['speed'] * 1000; //持续时间
  5398. var timerTween = null;
  5399. var tweenObj = null;
  5400. var start = obj['start'] == null ? '' : obj['start'].toString();
  5401. var end = obj['end'] == null ? '' : obj['end'].toString();
  5402. switch(obj['parameter']) {
  5403. case 'x':
  5404. if(obj['start'] == null) {
  5405. b = pm['x'];
  5406. } else {
  5407. if(start.substring(start.length - 1, start.length) == '%') {
  5408. b = parseInt(start) * w * 0.01;
  5409. } else {
  5410. b = parseInt(start);
  5411. }
  5412. }
  5413. if(obj['end'] == null) {
  5414. c = pm['x'] - b;
  5415. } else {
  5416. if(end.substring(end.length - 1, end.length) == '%') {
  5417. c = parseInt(end) * w * 0.01 - b;
  5418. } else if(end.substring(0, 1) == '-' || end.substring(0, 1) == '+') {
  5419. if(typeof(obj['end']) == 'number') {
  5420. c = parseInt(obj['end']) - b;
  5421. } else {
  5422. c = parseInt(end);
  5423. }
  5424. } else {
  5425. c = parseInt(end) - b;
  5426. }
  5427. }
  5428. break;
  5429. case 'y':
  5430. if(obj['start'] == null) {
  5431. b = pm['y'];
  5432. } else {
  5433. if(start.substring(start.length - 1, start.length) == '%') {
  5434. b = parseInt(start) * h * 0.01;
  5435. } else {
  5436. b = parseInt(start);
  5437. }
  5438. }
  5439. if(obj['end'] == null) {
  5440. c = pm['y'] - b;
  5441. } else {
  5442. if(end.substring(end.length - 1, end.length) == '%') {
  5443. c = parseInt(end) * h * 0.01 - b;
  5444. } else if(end.substring(0, 1) == '-' || end.substring(0, 1) == '+') {
  5445. if(typeof(obj['end']) == 'number') {
  5446. c = parseInt(obj['end']) - b;
  5447. } else {
  5448. c = parseInt(end);
  5449. }
  5450. } else {
  5451. c = parseInt(end) - b;
  5452. }
  5453. }
  5454. break;
  5455. case 'alpha':
  5456. if(obj['start'] == null) {
  5457. b = pm['alpha'] * 100;
  5458. } else {
  5459. if(start.substring(start.length - 1, start.length) == '%') {
  5460. b = parseInt(obj['start']);
  5461. } else {
  5462. b = parseInt(obj['start'] * 100);
  5463. }
  5464. }
  5465. if(obj['end'] == null) {
  5466. c = pm['alpha'] * 100 - b;
  5467. } else {
  5468. if(end.substring(end.length - 1, end.length) == '%') {
  5469. c = parseInt(end) - b;
  5470. } else if(end.substring(0, 1) == '-' || end.substring(0, 1) == '+') {
  5471. if(typeof(obj['end']) == 'number') {
  5472. c = parseInt(obj['end']) * 100 - b;
  5473. } else {
  5474. c = parseInt(obj['end']) * 100;
  5475. }
  5476. } else {
  5477. c = parseInt(obj['end']) * 100 - b;
  5478. }
  5479. }
  5480. break;
  5481. }
  5482. var callBack = function() {
  5483. var index = thisTemp.arrIndexOf(thisTemp.animateElementArray, animateId);
  5484. if(index > -1) {
  5485. thisTemp.animateArray.splice(index, 1);
  5486. thisTemp.animateElementArray.splice(index, 1);
  5487. }
  5488. index = thisTemp.arrIndexOf(thisTemp.animatePauseArray, animateId);
  5489. if(index > -1) {
  5490. thisTemp.animatePauseArray.splice(index, 1);
  5491. }
  5492. if(obj['callBack'] != null && obj['element'] && obj['callBack'] != 'callBack' && obj['callBack'] != 'tweenX' && obj['tweenY'] != 'callBack' && obj['callBack'] != 'tweenAlpha') {
  5493. var cb = eval(obj['callBack']);
  5494. cb(obj['element']);
  5495. obj['callBack'] = null;
  5496. }
  5497. };
  5498. var stopTween = function() {
  5499. if(timerTween != null) {
  5500. if(timerTween.runing) {
  5501. timerTween.stop();
  5502. }
  5503. timerTween = null;
  5504. }
  5505. };
  5506. var tweenX = function() {
  5507. if(t < d) {
  5508. t += 10;
  5509. css = {
  5510. left: Math.ceil(tweenFun(t, b, c, d)) + 'px'
  5511. };
  5512. if(obj['static']) {
  5513. eleCoor = thisTemp.calculationCoor(obj['element']);
  5514. css['top'] = eleCoor['y'] + 'px';
  5515. }
  5516. thisTemp.css(obj['element'], css);
  5517. } else {
  5518. stopTween();
  5519. thisTemp.elementArr.push(obj['element'].className);
  5520. callBack();
  5521. }
  5522. };
  5523. var tweenY = function() {
  5524. if(t < d) {
  5525. t += 10;
  5526. css = {
  5527. top: Math.ceil(tweenFun(t, b, c, d)) + 'px'
  5528. };
  5529. if(obj['static']) {
  5530. eleCoor = thisTemp.calculationCoor(obj['element']);
  5531. css['left'] = eleCoor['x'] + 'px';
  5532. }
  5533. thisTemp.css(obj['element'], css);
  5534. } else {
  5535. stopTween();
  5536. thisTemp.elementArr.push(obj['element'].className);
  5537. callBack();
  5538. }
  5539. };
  5540. var tweenAlpha = function() {
  5541. if(t < d) {
  5542. t += 10;
  5543. eleCoor = thisTemp.calculationCoor(obj['element']);
  5544. var ap = Math.ceil(tweenFun(t, b, c, d)) * 0.01;
  5545. css = {
  5546. filter: 'alpha(opacity:' + ap + ')',
  5547. opacity: ap.toString()
  5548. };
  5549. if(obj['static']) {
  5550. eleCoor = thisTemp.calculationCoor(obj['element']);
  5551. css['top'] = eleCoor['y'] + 'px';
  5552. css['left'] = eleCoor['x'] + 'px';
  5553. }
  5554. thisTemp.css(obj['element'], css);
  5555. } else {
  5556. stopTween();
  5557. thisTemp.elementArr.push(obj['element'].className);
  5558. callBack();
  5559. }
  5560. };
  5561. switch(obj['parameter']) {
  5562. case 'x':
  5563. tweenObj = tweenX;
  5564. break;
  5565. case 'y':
  5566. tweenObj = tweenY;
  5567. break;
  5568. case 'alpha':
  5569. tweenObj = tweenAlpha;
  5570. break;
  5571. default:
  5572. break;
  5573. }
  5574. timerTween = new thisTemp.timer(10, tweenObj);
  5575. timerTween.callBackFunction=callBack;
  5576. if(obj['overStop']) {
  5577. var mouseOver = function() {
  5578. if(timerTween != null && timerTween.runing) {
  5579. timerTween.stop();
  5580. }
  5581. };
  5582. this.addListenerInside('mouseover', mouseOver, obj['element']);
  5583. var mouseOut = function() {
  5584. var start = true;
  5585. if(obj['pauseStop'] && thisTemp.getMetaDate()['paused']) {
  5586. start = false;
  5587. }
  5588. if(timerTween != null && !timerTween.runing && start) {
  5589. timerTween.start();
  5590. }
  5591. };
  5592. this.addListenerInside('mouseout', mouseOut, obj['element']);
  5593. }
  5594. this.animateArray.push(timerTween);
  5595. this.animateElementArray.push(animateId);
  5596. if(obj['pauseStop']) {
  5597. this.animatePauseArray.push(animateId);
  5598. }
  5599. return animateId;
  5600. },
  5601. /*
  5602. 接口函数函数
  5603. 继续运行animate
  5604. */
  5605. animateResume: function(id) {
  5606. if(this.playerType == 'flashplayer') {
  5607. this.V.animateResume(this.isUndefined(id) ? '' : id);
  5608. return;
  5609. }
  5610. var arr = [];
  5611. if(id != '' && !this.isUndefined(id) && id != 'pause') {
  5612. arr.push(id);
  5613. } else {
  5614. if(id === 'pause') {
  5615. arr = this.animatePauseArray;
  5616. } else {
  5617. arr = this.animateElementArray;
  5618. }
  5619. }
  5620. for(var i = 0; i < arr.length; i++) {
  5621. var index = this.arrIndexOf(this.animateElementArray, arr[i]);
  5622. if(index > -1) {
  5623. this.animateArray[index].start();
  5624. }
  5625. }
  5626. },
  5627. /*
  5628. 接口函数
  5629. 暂停运行animate
  5630. */
  5631. animatePause: function(id) {
  5632. if(this.playerType == 'flashplayer') {
  5633. this.V.animatePause(this.isUndefined(id) ? '' : id);
  5634. return;
  5635. }
  5636. var arr = [];
  5637. if(id != '' && !this.isUndefined(id) && id != 'pause') {
  5638. arr.push(id);
  5639. } else {
  5640. if(id === 'pause') {
  5641. arr = this.animatePauseArray;
  5642. } else {
  5643. arr = this.animateElementArray;
  5644. }
  5645. }
  5646. for(var i = 0; i < arr.length; i++) {
  5647. var index = this.arrIndexOf(this.animateElementArray, arr[i]);
  5648. if(index > -1) {
  5649. this.animateArray[index].stop();
  5650. }
  5651. }
  5652. },
  5653. /*
  5654. 内置函数
  5655. 根据ID删除数组里对应的内容
  5656. */
  5657. deleteAnimate: function(id) {
  5658. if(this.playerType == 'flashplayer' && this.V) {
  5659. try {
  5660. this.V.deleteAnimate(id);
  5661. } catch(event) {this.log(event);}
  5662. return;
  5663. }
  5664. //console.log(this.animateElementArray)
  5665. var index = this.arrIndexOf(this.animateElementArray, id);
  5666. if(index > -1) {
  5667. this.animateArray[index].callBackFunction();
  5668. this.animateArray.splice(index, 1);
  5669. this.animateElementArray.splice(index, 1);
  5670. }
  5671. },
  5672. /*
  5673. 内置函数
  5674. 删除外部新建的元件
  5675. */
  5676. deleteElement: function(ele) {
  5677. if(this.playerType == 'flashplayer' && this.V) {
  5678. try {
  5679. this.V.deleteElement(ele);
  5680. } catch(event) {}
  5681. return;
  5682. }
  5683. //先将该元件从元件数组里删除,让其不再跟随播放器的尺寸改变而改变位置
  5684. var def = this.arrIndexOf(this.elementArr, ele.className);
  5685. if(def > -1) {
  5686. this.elementArr.splice(def, 1);
  5687. }
  5688. this.deleteAnimate(ele);
  5689. this.deleteChild(ele);
  5690. },
  5691. /*
  5692. --------------------------------------------------------------
  5693. 共用函数部分
  5694. 以下函数并非只能在本程序中使用,也可以在页面其它项目中使用
  5695. 根据ID获取元素对象
  5696. */
  5697. getByElement: function(obj, parent) {
  5698. if(this.isUndefined(parent)) {
  5699. parent = document;
  5700. }
  5701. var num = obj.substr(0, 1);
  5702. var res = [];
  5703. if(num != '#') {
  5704. if(num == '.') {
  5705. obj = obj.substr(1, obj.length);
  5706. }
  5707. if(parent.getElementsByClassName) {
  5708. res = parent.getElementsByClassName(obj);
  5709. } else {
  5710. var reg = new RegExp(' ' + obj + ' ', 'i');
  5711. var ele = parent.getElementsByTagName('*');
  5712. for(var i = 0; i < ele.length; i++) {
  5713. if(reg.test(' ' + ele[i].className + ' ')) {
  5714. res.push(ele[i]);
  5715. }
  5716. }
  5717. }
  5718. if(res.length > 0) {
  5719. return res[0];
  5720. } else {
  5721. return res;
  5722. }
  5723. } else {
  5724. if(num == '#') {
  5725. obj = obj.substr(1, obj.length);
  5726. }
  5727. return document.getElementById(obj);
  5728. }
  5729. },
  5730. /*
  5731. 共用函数
  5732. 功能:修改样式或获取指定样式的值,
  5733. elem:ID对象或ID对应的字符,如果多个对象一起设置,则可以使用数组
  5734. attribute:样式名称或对象,如果是对象,则省略掉value值
  5735. value:attribute为样式名称时,定义的样式值
  5736. 示例一:
  5737. this.css(ID,'width','100px');
  5738. 示例二:
  5739. this.css('id','width','100px');
  5740. 示例三:
  5741. this.css([ID1,ID2,ID3],'width','100px');
  5742. 示例四:
  5743. this.css(ID,{
  5744. width:'100px',
  5745. height:'100px'
  5746. });
  5747. 示例五(获取宽度):
  5748. var width=this.css(ID,'width');
  5749. */
  5750. css: function(elem, attribute, value) {
  5751. var i = 0;
  5752. var k = '';
  5753. if(typeof(elem) == 'object') { //对象或数组
  5754. if(!this.isUndefined(typeof(elem.length))) { //说明是数组
  5755. for(i = 0; i < elem.length; i++) {
  5756. var el;
  5757. if(typeof(elem[i]) == 'string') {
  5758. el = this.getByElement(elem[i])
  5759. } else {
  5760. el = elem[i];
  5761. }
  5762. if(typeof(attribute) != 'object') {
  5763. if(!this.isUndefined(value)) {
  5764. el.style[attribute] = value;
  5765. }
  5766. } else {
  5767. for(k in attribute) {
  5768. if(!this.isUndefined(attribute[k])) {
  5769. el.style[k] = attribute[k];
  5770. }
  5771. }
  5772. }
  5773. }
  5774. return;
  5775. }
  5776. }
  5777. if(typeof(elem) == 'string') {
  5778. elem = this.getByElement(elem);
  5779. }
  5780. if(typeof(attribute) != 'object') {
  5781. if(!this.isUndefined(value)) {
  5782. elem.style[attribute] = value;
  5783. } else {
  5784. if(!this.isUndefined(this.getStyle(elem, attribute))) {
  5785. return this.getStyle(elem, attribute);
  5786. } else {
  5787. return false;
  5788. }
  5789. }
  5790. } else {
  5791. for(k in attribute) {
  5792. if(!this.isUndefined(attribute[k])) {
  5793. elem.style[k] = attribute[k];
  5794. }
  5795. }
  5796. }
  5797. },
  5798. /*
  5799. 内置函数
  5800. 兼容型获取style
  5801. */
  5802. getStyle: function(obj, attr) {
  5803. if(!this.isUndefined(obj.style[attr])) {
  5804. return obj.style[attr];
  5805. } else {
  5806. if(obj.currentStyle) {
  5807. return obj.currentStyle[attr];
  5808. } else {
  5809. return getComputedStyle(obj, false)[attr];
  5810. }
  5811. }
  5812. },
  5813. /*
  5814. 共用函数
  5815. 判断变量是否存在或值是否为undefined
  5816. */
  5817. isUndefined: function(value) {
  5818. try {
  5819. if(value == 'undefined' || value == undefined) {
  5820. return true;
  5821. }
  5822. } catch(event) {this.log(event);}
  5823. return false;
  5824. },
  5825. /*
  5826. 共用函数
  5827. 外部监听函数
  5828. */
  5829. addListener: function(name, funName) {
  5830. if(name && funName) {
  5831. if(this.playerType == 'flashplayer') {
  5832. var ff = ''; //定义用来向flashplayer传递的函数字符
  5833. if(typeof(funName) == 'function') {
  5834. ff = this.getParameterNames(funName);
  5835. }
  5836. this.V.addListener(name, ff);
  5837. return;
  5838. }
  5839. var have = false;
  5840. for(var i = 0; i < this.listenerJsArr.length; i++) {
  5841. var arr = this.listenerJsArr[i];
  5842. if(arr[0] == name && arr[1] == funName) {
  5843. have = true;
  5844. break;
  5845. }
  5846. }
  5847. if(!have) {
  5848. this.listenerJsArr.push([name, funName]);
  5849. }
  5850. }
  5851. },
  5852. /*
  5853. 共用函数
  5854. 外部删除监听函数
  5855. */
  5856. removeListener: function(name, funName) {
  5857. if(name && funName) {
  5858. if(this.playerType == 'flashplayer') {
  5859. var ff = ''; //定义用来向flashplayer传递的函数字符
  5860. if(typeof(funName) == 'function') {
  5861. ff = this.getParameterNames(funName);
  5862. }
  5863. this.V.removeListener(name, ff);
  5864. return;
  5865. }
  5866. for(var i = 0; i < this.listenerJsArr.length; i++) {
  5867. var arr = this.listenerJsArr[i];
  5868. if(arr[0] == name && arr[1] == funName) {
  5869. this.listenerJsArr.splice(i, 1);
  5870. break;
  5871. }
  5872. }
  5873. }
  5874. },
  5875. /*
  5876. 内部监听函数,调用方式:
  5877. this.addListenerInside('click',function(event){},[ID]);
  5878. d值为空时,则表示监听当前的视频播放器
  5879. */
  5880. addListenerInside: function(e, f, d, t) {
  5881. if(this.isUndefined(t)) {
  5882. t = false;
  5883. }
  5884. var o = this.V;
  5885. if(!this.isUndefined(d)) {
  5886. o = d;
  5887. }
  5888. if(o.addEventListener) {
  5889. try {
  5890. o.addEventListener(e, f, t);
  5891. } catch(event) {}
  5892. } else if(o.attachEvent) {
  5893. try {
  5894. o.attachEvent('on' + e, f);
  5895. } catch(event) {}
  5896. } else {
  5897. o['on' + e] = f;
  5898. }
  5899. },
  5900. /*
  5901. 删除内部监听函数,调用方式:
  5902. this.removeListenerInside('click',function(event){}[,ID]);
  5903. d值为空时,则表示监听当前的视频播放器
  5904. */
  5905. removeListenerInside: function(e, f, d, t) {
  5906. /*if(this.playerType=='flashplayer' && this.getParameterNames(f) && this.isUndefined(d)) {
  5907. return;
  5908. }*/
  5909. if(this.isUndefined(t)) {
  5910. t = false;
  5911. }
  5912. var o = this.V;
  5913. if(!this.isUndefined(d)) {
  5914. o = d;
  5915. }
  5916. if(o.removeEventListener) {
  5917. try {
  5918. this.addNum--;
  5919. o.removeEventListener(e, f, t);
  5920. } catch(e) {}
  5921. } else if(o.detachEvent) {
  5922. try {
  5923. o.detachEvent('on' + e, f);
  5924. } catch(e) {}
  5925. } else {
  5926. o['on' + e] = null;
  5927. }
  5928. },
  5929. /*
  5930. 共用函数
  5931. 统一分配监听,以达到跟as3同样效果
  5932. */
  5933. sendJS: function(name, val) {
  5934. var list = this.listenerJsArr;
  5935. var obj = {
  5936. variable: this.vars['variable']
  5937. };
  5938. if(this.vars['playerID']) {
  5939. obj['playerID'] = this.vars['playerID'];
  5940. }
  5941. for(var i = 0; i < list.length; i++) {
  5942. var arr = list[i];
  5943. if(arr[0] == name) {
  5944. if(val) {
  5945. switch(arr[1].length) {
  5946. case 1:
  5947. arr[1](val);
  5948. break;
  5949. case 2:
  5950. arr[1](val, obj);
  5951. break;
  5952. default:
  5953. arr[1]();
  5954. break;
  5955. }
  5956. } else {
  5957. switch(arr[1].length) {
  5958. case 1:
  5959. arr[1](obj);
  5960. break;
  5961. default:
  5962. arr[1]();
  5963. break;
  5964. }
  5965. }
  5966. }
  5967. }
  5968. },
  5969. /*
  5970. 共用函数
  5971. 获取函数名称,如 function ckplayer(){} var fun=ckplayer,则getParameterNames(fun)=ckplayer
  5972. */
  5973. getParameterNames: function(fn) {
  5974. if(typeof(fn) !== 'function') {
  5975. return false;
  5976. }
  5977. var COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
  5978. var code = fn.toString().replace(COMMENTS, '');
  5979. var result = code.slice(code.indexOf(' ') + 1, code.indexOf('('));
  5980. return result === null ? false : result;
  5981. },
  5982. /*
  5983. 共用函数
  5984. 获取当前本地时间
  5985. */
  5986. getNowDate: function() {
  5987. var nowDate = new Date();
  5988. var month = nowDate.getMonth() + 1;
  5989. var date = nowDate.getDate();
  5990. var hours = nowDate.getHours();
  5991. var minutes = nowDate.getMinutes();
  5992. var seconds = nowDate.getSeconds();
  5993. var tMonth = '',
  5994. tDate = '',
  5995. tHours = '',
  5996. tMinutes = '',
  5997. tSeconds = '',
  5998. tSeconds = (seconds < 10) ? '0' + seconds : seconds + '',
  5999. tMinutes = (minutes < 10) ? '0' + minutes : minutes + '',
  6000. tHours = (hours < 10) ? '0' + hours : hours + '',
  6001. tDate = (date < 10) ? '0' + date : date + '',
  6002. tMonth = (month < 10) ? '0' + month : month + '';
  6003. return tMonth + '/' + tDate + ' ' + tHours + ':' + tMinutes + ':' + tSeconds;
  6004. },
  6005. /*
  6006. 共用函数
  6007. 格式化时分秒
  6008. seconds:Int:秒数
  6009. ishours:Boolean:是否显示小时,如果设置成false,则会显示如80:20,表示1小时20分钟20秒
  6010. */
  6011. formatTime: function(seconds, ishours) {
  6012. var tSeconds = '',
  6013. tMinutes = '',
  6014. tHours = '';
  6015. if(isNaN(seconds)) {
  6016. seconds = 0;
  6017. }
  6018. var s = Math.floor(seconds % 60),
  6019. m = 0,
  6020. h = 0;
  6021. if(ishours) {
  6022. m = Math.floor(seconds / 60) % 60;
  6023. h = Math.floor(seconds / 3600);
  6024. } else {
  6025. m = Math.floor(seconds / 60);
  6026. }
  6027. tSeconds = (s < 10) ? '0' + s : s + '';
  6028. tMinutes = (m > 0) ? ((m < 10) ? '0' + m + ':' : m + ':') : '00:';
  6029. tHours = (h > 0) ? ((h < 10) ? '0' + h + ':' : h + ':') : '';
  6030. if(ishours) {
  6031. return tHours + tMinutes + tSeconds;
  6032. } else {
  6033. return tMinutes + tSeconds;
  6034. }
  6035. },
  6036. /*
  6037. 共用函数
  6038. 获取一个随机字符
  6039. len:随机字符长度
  6040. */
  6041. randomString: function(len) {
  6042. len = len || 16;
  6043. var chars = 'abcdefghijklmnopqrstuvwxyz';
  6044. var maxPos = chars.length;
  6045. var val = '';
  6046. for(i = 0; i < len; i++) {
  6047. val += chars.charAt(Math.floor(Math.random() * maxPos));
  6048. }
  6049. return 'ch' + val;
  6050. },
  6051. /*
  6052. 共用函数
  6053. 获取字符串长度,中文算两,英文数字算1
  6054. */
  6055. getStringLen: function(str) {
  6056. var len = 0;
  6057. for(var i = 0; i < str.length; i++) {
  6058. if(str.charCodeAt(i) > 127 || str.charCodeAt(i) == 94) {
  6059. len += 2;
  6060. } else {
  6061. len++;
  6062. }
  6063. }
  6064. return len;
  6065. },
  6066. /*
  6067. 内部函数
  6068. 用来为ajax提供支持
  6069. */
  6070. createXHR: function() {
  6071. if(window.XMLHttpRequest) {
  6072. //IE7+、Firefox、Opera、Chrome 和Safari
  6073. return new XMLHttpRequest();
  6074. } else if(window.ActiveXObject) {
  6075. //IE6 及以下
  6076. try {
  6077. return new ActiveXObject('Microsoft.XMLHTTP');
  6078. } catch(event) {
  6079. try {
  6080. return new ActiveXObject('Msxml2.XMLHTTP');
  6081. } catch(event) {
  6082. this.eject(this.errorList[7]);
  6083. }
  6084. }
  6085. } else {
  6086. this.eject(this.errorList[8]);
  6087. }
  6088. },
  6089. /*
  6090. 共用函数
  6091. ajax调用
  6092. */
  6093. ajax: function(cObj) {
  6094. var thisTemp = this;
  6095. var callback = null;
  6096. var obj = {
  6097. method: 'get', //请求类型
  6098. dataType: 'json', //请求的数据类型
  6099. charset: 'utf-8',
  6100. async: false, //true表示异步,false表示同步
  6101. url: '',
  6102. data: null,
  6103. success: null
  6104. };
  6105. if(typeof(cObj) != 'object') {
  6106. this.eject(this.errorList[9]);
  6107. return;
  6108. }
  6109. obj = this.standardization(obj, cObj);
  6110. if(obj.dataType === 'json' || obj.dataType === 'text' || obj.dataType === 'html') {
  6111. var xhr = this.createXHR();
  6112. callback = function() {
  6113. //判断http的交互是否成功
  6114. if(xhr.status == 200) {
  6115. if(obj.success == null) {
  6116. return;
  6117. }
  6118. if(obj.dataType === 'json') {
  6119. try {
  6120. obj.success(eval('(' + xhr.responseText + ')')); //回调传递参数
  6121. } catch(event) {
  6122. obj.success(null);
  6123. }
  6124. } else {
  6125. obj.success(xhr.responseText); //回调传递参数
  6126. }
  6127. } else {
  6128. thisTemp.eject(thisTemp.errorList[10], 'Ajax.status:' + xhr.status);
  6129. }
  6130. };
  6131. obj.url = obj.url + '?rand=' + this.randomString(6);
  6132. obj.data = this.formatParams(obj.data); //通过params()将名值对转换成字符串
  6133. if(obj.method === 'get' && !this.isUndefined(obj.data)) {
  6134. obj.url += obj.url.indexOf('?') == -1 ? '?' + obj.data : '&' + obj.data;
  6135. }
  6136. if(obj.async === true) { //true表示异步,false表示同步
  6137. xhr.onreadystatechange = function() {
  6138. if(xhr.readyState == 4) { //判断对象的状态是否交互完成
  6139. callback(); //回调
  6140. }
  6141. };
  6142. }
  6143. xhr.open(obj.method, obj.url, obj.async);
  6144. if(obj.method === 'post') {
  6145. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  6146. xhr.setRequestHeader('charset', obj['charset']);
  6147. xhr.send(obj.data);
  6148. } else {
  6149. xhr.send(null); //get方式则填null
  6150. }
  6151. if(obj.async === false) { //同步
  6152. callback();
  6153. }
  6154. } else if(obj.dataType === 'jsonp') {
  6155. var oHead = document.getElementsByTagName('head')[0];
  6156. var oScript = document.createElement('script');
  6157. var callbackName = 'callback' + new Date().getTime();
  6158. var params = this.formatParams(obj.data) + '&callback=' + callbackName; //按时间戳拼接字符串
  6159. callback = obj.success;
  6160. //拼接好src
  6161. oScript.src = obj.url.split('?') + '?' + params;
  6162. //插入script标签
  6163. oHead.insertBefore(oScript, oHead.firstChild);
  6164. //jsonp的回调函数
  6165. window[callbackName] = function(json) {
  6166. callback(json);
  6167. oHead.removeChild(oScript);
  6168. };
  6169. }
  6170. },
  6171. /*
  6172. 内置函数
  6173. 动态加载js
  6174. */
  6175. loadJs: function(path, success) {
  6176. var oHead = document.getElementsByTagName('HEAD').item(0);
  6177. var oScript = document.createElement('script');
  6178. oScript.type = 'text/javascript';
  6179. oScript.src = this.getNewUrl(path);
  6180. oHead.appendChild(oScript);
  6181. oScript.onload = function() {
  6182. success();
  6183. }
  6184. },
  6185. /*
  6186. 共用函数
  6187. 排除IE6-9
  6188. */
  6189. isMsie: function() {
  6190. var browser = navigator.appName;
  6191. var b_version = navigator.appVersion;
  6192. var version = b_version.split(';');
  6193. var trim_Version = '';
  6194. if(version.length > 1) {
  6195. trim_Version = version[1].replace(/[ ]/g, '');
  6196. }
  6197. if(browser == 'Microsoft Internet Explorer' && (trim_Version == 'MSIE6.0' || trim_Version == 'MSIE7.0' || trim_Version == 'MSIE8.0' || trim_Version == 'MSIE9.0' || trim_Version == 'MSIE10.0')) {
  6198. return false;
  6199. }
  6200. return true;
  6201. },
  6202. /*
  6203. 共用函数
  6204. 判断是否安装了flashplayer
  6205. */
  6206. uploadFlash: function() {
  6207. var swf;
  6208. if(navigator.userAgent.indexOf('MSIE') > 0) {
  6209. try {
  6210. var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
  6211. return true;
  6212. } catch(e) {
  6213. return false;
  6214. }
  6215. }
  6216. if(navigator.userAgent.indexOf('Firefox') > 0) {
  6217. swf = navigator.plugins['Shockwave Flash'];
  6218. if(swf) {
  6219. return true
  6220. } else {
  6221. return false;
  6222. }
  6223. }
  6224. return true;
  6225. },
  6226. /*
  6227. 共用函数
  6228. 检测浏览器是否支持HTML5-Video
  6229. */
  6230. supportVideo: function() {
  6231. if(!this.isMsie()) {
  6232. return false;
  6233. }
  6234. if(!!document.createElement('video').canPlayType) {
  6235. var vidTest = document.createElement('video');
  6236. var oggTest;
  6237. try {
  6238. oggTest = vidTest.canPlayType('video/ogg; codecs="theora, vorbis"');
  6239. } catch(error) {
  6240. oggTest = false;
  6241. }
  6242. if(!oggTest) {
  6243. var h264Test;
  6244. try {
  6245. h264Test = vidTest.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');
  6246. } catch(error) {
  6247. h264Test = false;
  6248. }
  6249. if(!h264Test) {
  6250. return false;
  6251. } else {
  6252. if(h264Test == "probably") {
  6253. return true;
  6254. } else {
  6255. return false;
  6256. }
  6257. }
  6258. } else {
  6259. if(oggTest == "probably") {
  6260. return true;
  6261. } else {
  6262. return false;
  6263. }
  6264. }
  6265. } else {
  6266. return false;
  6267. }
  6268. },
  6269. /*
  6270. 共用函数
  6271. 获取属性值
  6272. */
  6273. getDataset: function(ele, z) {
  6274. try {
  6275. return ele.dataset[z];
  6276. } catch(error) {
  6277. try {
  6278. return ele.getAttribute('data-' + z)
  6279. } catch(error) {
  6280. return false;
  6281. }
  6282. }
  6283. },
  6284. /*
  6285. 共用函数
  6286. 返回flashplayer的对象
  6287. */
  6288. getObjectById: function(id) {
  6289. var x = null;
  6290. var y = this.getByElement('#' + id);
  6291. var r = 'embed';
  6292. if(y && y.nodeName == 'OBJECT') {
  6293. if(typeof(y.SetVariable) != 'undefined') {
  6294. x = y;
  6295. } else {
  6296. var z = y.getElementsByTagName(r)[0];
  6297. if(z) {
  6298. x = z;
  6299. }
  6300. }
  6301. }
  6302. return x;
  6303. },
  6304. /*
  6305. 共用函数
  6306. 对象转地址字符串
  6307. */
  6308. formatParams: function(data) {
  6309. var arr = [];
  6310. for(var i in data) {
  6311. arr.push(encodeURIComponent(i) + '=' + encodeURIComponent(data[i]));
  6312. }
  6313. return arr.join('&');
  6314. },
  6315. /*
  6316. 内置函数
  6317. 对地址进行冒泡排序
  6318. */
  6319. arrSort: function(arr) {
  6320. var temp = [];
  6321. for(var i = 0; i < arr.length; i++) {
  6322. for(var j = 0; j < arr.length - i; j++) {
  6323. if(!this.isUndefined(arr[j + 1]) && arr[j][3] < arr[j + 1][3]) {
  6324. temp = arr[j + 1];
  6325. arr[j + 1] = arr[j];
  6326. arr[j] = temp;
  6327. }
  6328. }
  6329. }
  6330. return arr;
  6331. },
  6332. /*
  6333. 内置函数
  6334. 判断文件后缀
  6335. */
  6336. getFileExt: function(filepath) {
  6337. if(filepath != '' && !this.isUndefined(filepath)) {
  6338. if(filepath.indexOf('?') > -1) {
  6339. filepath = filepath.split('?')[0];
  6340. }
  6341. var pos = '.' + filepath.replace(/.+\./, '');
  6342. return pos;
  6343. }
  6344. return '';
  6345. },
  6346. /*
  6347. 内置函数
  6348. 判断是否是移动端
  6349. */
  6350. isMobile: function() {
  6351. if(navigator.userAgent.match(/(iPhone|iPad|iPod|Android|ios)/i)) {
  6352. return true;
  6353. }
  6354. return false;
  6355. },
  6356. /*
  6357. 内置函数
  6358. 搜索字符串str是否包含key
  6359. */
  6360. isContains: function(str, key) {
  6361. return str.indexOf(key) > -1;
  6362. },
  6363. /*
  6364. 内置函数
  6365. 给地址添加随机数
  6366. */
  6367. getNewUrl: function(url) {
  6368. if(this.isContains(url, '?')) {
  6369. return url += '&' + this.randomString(8) + '=' + this.randomString(8);
  6370. } else {
  6371. return url += '?' + this.randomString(8) + '=' + this.randomString(8);
  6372. }
  6373. },
  6374. /*
  6375. 共用函数
  6376. 获取clientX和clientY
  6377. */
  6378. client: function(event) {
  6379. var eve = event || window.event;
  6380. if(this.isUndefined(eve)) {
  6381. eve = {
  6382. clientX: 0,
  6383. clientY: 0
  6384. };
  6385. }
  6386. return {
  6387. x: eve.clientX + (document.documentElement.scrollLeft || this.body.scrollLeft) - this.pdCoor['x'],
  6388. y: eve.clientY + (document.documentElement.scrollTop || this.body.scrollTop) - this.pdCoor['y']
  6389. }
  6390. },
  6391. /*
  6392. 内置函数
  6393. 获取节点的绝对坐标
  6394. */
  6395. getCoor: function(obj) {
  6396. var coor = this.getXY(obj);
  6397. return {
  6398. x: coor['x'] - this.pdCoor['x'],
  6399. y: coor['y'] - this.pdCoor['y']
  6400. };
  6401. },
  6402. getXY: function(obj) {
  6403. var parObj = obj;
  6404. var left = obj.offsetLeft;
  6405. var top = obj.offsetTop;
  6406. while(parObj = parObj.offsetParent) {
  6407. left += parObj.offsetLeft;
  6408. top += parObj.offsetTop;
  6409. }
  6410. return {
  6411. x: left,
  6412. y: top
  6413. };
  6414. },
  6415. /*
  6416. 内置函数
  6417. 删除本对象的所有属性
  6418. */
  6419. removeChild: function() {
  6420. if(this.playerType == 'html5video') {
  6421. //删除计时器
  6422. var i = 0;
  6423. var timerArr = [this.timerError, this.timerFull, this.timerTime, this.timerBuffer, this.timerClick, this.timerLoading, this.timerCBar, this.timerVCanvas];
  6424. for(i = 0; i < timerArr.length; i++) {
  6425. if(timerArr[i] != null) {
  6426. if(timerArr[i].runing) {
  6427. timerArr[i].stop();
  6428. }
  6429. timerArr[i] = null;
  6430. }
  6431. }
  6432. //删除事件监听
  6433. var ltArr = this.listenerJsArr;
  6434. for(i = 0; i < ltArr.length; i++) {
  6435. this.removeListener(ltArr[i][0], ltArr[i][1]);
  6436. }
  6437. }
  6438. this.playerType == '';
  6439. this.V = null;
  6440. if(this.showFace) {
  6441. this.deleteChild(this.CB['menu']);
  6442. }
  6443. this.deleteChild(this.PD);
  6444. this.CD.innerHTML = '';
  6445. },
  6446. /*
  6447. 内置函数
  6448. 画封闭的图形
  6449. */
  6450. canvasFill: function(name, path) {
  6451. name.beginPath();
  6452. for(var i = 0; i < path.length; i++) {
  6453. var d = path[i];
  6454. if(i > 0) {
  6455. name.lineTo(d[0], d[1]);
  6456. } else {
  6457. name.moveTo(d[0], d[1]);
  6458. }
  6459. }
  6460. name.closePath();
  6461. name.fill();
  6462. },
  6463. /*
  6464. 内置函数
  6465. 画矩形
  6466. */
  6467. canvasFillRect: function(name, path) {
  6468. for(var i = 0; i < path.length; i++) {
  6469. var d = path[i];
  6470. name.fillRect(d[0], d[1], d[2], d[3]);
  6471. }
  6472. },
  6473. /*
  6474. 共用函数
  6475. 删除容器节点
  6476. */
  6477. deleteChild: function(f) {
  6478. var def = this.arrIndexOf(this.elementArr, f.className);
  6479. if(def > -1) {
  6480. this.elementArr.splice(def, 1);
  6481. }
  6482. var childs = f.childNodes;
  6483. for(var i = childs.length - 1; i >= 0; i--) {
  6484. f.removeChild(childs[i]);
  6485. }
  6486. if(f && f != null && f.parentNode) {
  6487. try {
  6488. if(f.parentNode) {
  6489. f.parentNode.removeChild(f);
  6490. }
  6491. } catch(event) {}
  6492. }
  6493. },
  6494. /*
  6495. 内置函数
  6496. 根据容器的宽高,内部节点的宽高计算出内部节点的宽高及坐标
  6497. */
  6498. getProportionCoor: function(stageW, stageH, vw, vh) {
  6499. var w = 0,
  6500. h = 0,
  6501. x = 0,
  6502. y = 0;
  6503. if(stageW / stageH < vw / vh) {
  6504. w = stageW;
  6505. h = w * vh / vw;
  6506. } else {
  6507. h = stageH;
  6508. w = h * vw / vh;
  6509. }
  6510. x = (stageW - w) * 0.5;
  6511. y = (stageH - h) * 0.5;
  6512. return {
  6513. width: parseInt(w),
  6514. height: parseInt(h),
  6515. x: parseInt(x),
  6516. y: parseInt(y)
  6517. };
  6518. },
  6519. /*
  6520. 共用函数
  6521. 将字幕文件内容转换成数组
  6522. */
  6523. parseSrtSubtitles: function(srt) {
  6524. var subtitles = [];
  6525. var textSubtitles = [];
  6526. var i = 0;
  6527. var arrs = srt.split('\n');
  6528. var arr = [];
  6529. var delHtmlTag = function(str) {
  6530. return str.replace(/<[^>]+>/g, ''); //去掉所有的html标记
  6531. };
  6532. for(i = 0; i < arrs.length; i++) {
  6533. if(arrs[i].replace(/\s/g, '').length > 0) {
  6534. arr.push(arrs[i]);
  6535. } else {
  6536. if(arr.length > 0) {
  6537. textSubtitles.push(arr);
  6538. }
  6539. arr = [];
  6540. }
  6541. }
  6542. for(i = 0; i < textSubtitles.length; ++i) {
  6543. var textSubtitle = textSubtitles[i];
  6544. if(textSubtitle.length >= 2) {
  6545. var sn = textSubtitle[0]; // 字幕的序号
  6546. var startTime = this.toSeconds(this.trim(textSubtitle[1].split(' --> ')[0])); // 字幕的开始时间
  6547. var endTime = this.toSeconds(this.trim(textSubtitle[1].split(' --> ')[1])); // 字幕的结束时间
  6548. var content = [delHtmlTag(textSubtitle[2])]; // 字幕的内容
  6549. // 字幕可能有多行
  6550. if(textSubtitle.length > 2) {
  6551. for(var j = 3; j < textSubtitle.length; j++) {
  6552. content.push(delHtmlTag(textSubtitle[j]));
  6553. }
  6554. }
  6555. // 字幕对象
  6556. var subtitle = {
  6557. sn: sn,
  6558. startTime: startTime,
  6559. endTime: endTime,
  6560. content: content
  6561. };
  6562. subtitles.push(subtitle);
  6563. }
  6564. }
  6565. return subtitles;
  6566. },
  6567. /*
  6568. 共用函数
  6569. 计时器,该函数模拟as3中的timer原理
  6570. time:计时时间,单位:毫秒
  6571. fun:接受函数
  6572. number:运行次数,不设置则无限运行
  6573. */
  6574. timer: function(time, fun, number) {
  6575. var thisTemp = this;
  6576. this.time = 10; //运行间隔
  6577. this.fun = null; //监听函数
  6578. this.timeObj = null; //setInterval对象
  6579. this.number = 0; //已运行次数
  6580. this.numberTotal = null; //总至需要次数
  6581. this.runing = false; //当前状态
  6582. this.startFun = function() {
  6583. thisTemp.number++;
  6584. thisTemp.fun();
  6585. if(thisTemp.numberTotal != null && thisTemp.number >= thisTemp.numberTotal) {
  6586. thisTemp.stop();
  6587. }
  6588. };
  6589. this.start = function() {
  6590. if(!thisTemp.runing) {
  6591. thisTemp.runing = true;
  6592. thisTemp.timeObj = window.setInterval(thisTemp.startFun, time);
  6593. }
  6594. };
  6595. this.stop = function() {
  6596. if(thisTemp.runing) {
  6597. thisTemp.runing = false;
  6598. window.clearInterval(thisTemp.timeObj);
  6599. thisTemp.timeObj = null;
  6600. }
  6601. };
  6602. if(time) {
  6603. this.time = time;
  6604. }
  6605. if(fun) {
  6606. this.fun = fun;
  6607. }
  6608. if(number) {
  6609. this.numberTotal = number;
  6610. }
  6611. this.start();
  6612. },
  6613. /*
  6614. 共用函数
  6615. 将时分秒转换成秒
  6616. */
  6617. toSeconds: function(t) {
  6618. var s = 0.0;
  6619. if(t) {
  6620. var p = t.split(':');
  6621. for(i = 0; i < p.length; i++) {
  6622. s = s * 60 + parseFloat(p[i].replace(',', '.'));
  6623. }
  6624. }
  6625. return s;
  6626. },
  6627. /*
  6628. 共用函数
  6629. 将对象Object标准化
  6630. */
  6631. standardization: function(o, n) { //n替换进o
  6632. var h = {};
  6633. var k;
  6634. for(k in o) {
  6635. h[k] = o[k];
  6636. }
  6637. for(k in n) {
  6638. var type = typeof(h[k]);
  6639. switch(type) {
  6640. case 'number':
  6641. h[k] = parseFloat(n[k]);
  6642. break;
  6643. default:
  6644. h[k] = n[k];
  6645. break;
  6646. }
  6647. }
  6648. return h;
  6649. },
  6650. /*
  6651. 共用函数
  6652. 搜索数组
  6653. */
  6654. arrIndexOf: function(arr, key) {
  6655. var re = new RegExp(key, ['']);
  6656. return(arr.toString().replace(re, '┢').replace(/[^,┢]/g, '')).indexOf('┢');
  6657. },
  6658. /*
  6659. 共用函数
  6660. 去掉空格
  6661. */
  6662. trim: function(str) {
  6663. if(str!=''){
  6664. return str.replace(/(^\s*)|(\s*$)/g, '');
  6665. }
  6666. return '';
  6667. },
  6668. /*
  6669. 共用函数
  6670. 输出内容到控制台
  6671. */
  6672. log: function(val) {
  6673. try {
  6674. console.log(val);
  6675. } catch(e) {}
  6676. },
  6677. /*
  6678. 共用函数
  6679. 弹出提示
  6680. */
  6681. eject: function(er, val) {
  6682. if(!this.vars['debug']) {
  6683. return;
  6684. }
  6685. var errorVal = er[1];
  6686. if(!this.isUndefined(val)) {
  6687. errorVal = errorVal.replace('[error]', val);
  6688. }
  6689. var value = 'error ' + er[0] + ':' + errorVal;
  6690. try {
  6691. this.log(value);
  6692. } catch(e) {}
  6693. }
  6694. };
  6695. window.ckplayer = ckplayer;
  6696. })();