ckplayer.js 207 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421
  1. /*
  2. * 软件名称:ckplayer
  3. * 版本:X3
  4. * 版权:www.ckplayer.com
  5. * 开源协议:MIT
  6. */
  7. (function (global, factory) {
  8. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  9. typeof define === 'function' && define.amd ? define(factory) :
  10. (global = global || self, global.ckplayer = factory());
  11. }(this, function () { 'use strict';
  12. /*
  13. * language
  14. * 功能:静态变量,包含播放器用到的默认语言包
  15. * 引入其它语言js后该变量将被替换成新引入的语言包
  16. */
  17. var language={
  18. play:'%E6%92%AD%E6%94%BE',
  19. pause:'%E6%9A%82%E5%81%9C',
  20. refresh:'%E9%87%8D%E6%92%AD',
  21. full:'%E5%85%A8%E5%B1%8F',
  22. exitFull:'%E9%80%80%E5%87%BA%E5%85%A8%E5%B1%8F',
  23. webFull:'%E9%A1%B5%E9%9D%A2%E5%85%A8%E5%B1%8F',
  24. exitWebFull:'%E9%80%80%E5%87%BA%E9%A1%B5%E9%9D%A2%E5%85%A8%E5%B1%8F',
  25. theatre:'%E5%89%A7%E5%9C%BA%E6%A8%A1%E5%BC%8F',
  26. exitTheatre:'%E9%80%80%E5%87%BA%E5%89%A7%E5%9C%BA%E6%A8%A1%E5%BC%8F',
  27. volume:'%E9%9F%B3%E9%87%8F%EF%BC%9A',
  28. muted:'%E9%9D%99%E9%9F%B3',
  29. exitmuted:'%E6%81%A2%E5%A4%8D%E9%9F%B3%E9%87%8F',
  30. seek:'seek%EF%BC%9A',
  31. waiting:'%E7%BC%93%E5%86%B2',
  32. live:'%E7%9B%B4%E6%92%AD%E4%B8%AD',
  33. backLive:'%E8%BF%94%E5%9B%9E%E7%9B%B4%E6%92%AD',
  34. lookBack:'%E5%9B%9E%E7%9C%8B%EF%BC%9A',
  35. next:'%E4%B8%8B%E4%B8%80%E9%9B%86',
  36. screenshot:'%E8%A7%86%E9%A2%91%E6%88%AA%E5%9B%BE',
  37. smallwindows:'%E5%B0%8F%E7%AA%97%E5%8F%A3%E6%92%AD%E6%94%BE%E5%8A%9F%E8%83%BD',
  38. playbackrate:'%E5%80%8D%E9%80%9F',
  39. playbackrateSuffix:'%E5%80%8D',
  40. track:'%E5%AD%97%E5%B9%95',
  41. noTrack:'%E6%97%A0%E5%AD%97%E5%B9%95',
  42. definition:'%E6%B8%85%E6%99%B0%E5%BA%A6',
  43. switchTo:'%E5%88%87%E6%8D%A2%E6%88%90%EF%BC%9A',
  44. closeTime:'%7Bseconds%7D%E7%A7%92%E5%90%8E%E5%8F%AF%E5%85%B3%E9%97%AD%E5%B9%BF%E5%91%8A',
  45. closeAd:'%E5%85%B3%E9%97%AD%E5%B9%BF%E5%91%8A',
  46. second:'%E7%A7%92',
  47. details:'%E6%9F%A5%E7%9C%8B%E8%AF%A6%E6%83%85',
  48. copy:'%E5%A4%8D%E5%88%B6',
  49. copySucceeded:'%E5%A4%8D%E5%88%B6%E6%88%90%E5%8A%9F%EF%BC%8C%E5%8F%AF%E8%B4%B4%E7%B2%98%EF%BC%81',
  50. smallwindowsOpen:'%E5%B0%8F%E7%AA%97%E5%8F%A3%E5%8A%9F%E8%83%BD%E5%B7%B2%E5%BC%80%E5%90%AF',
  51. smallwindowsClose:'%E5%B0%8F%E7%AA%97%E5%8F%A3%E5%8A%9F%E8%83%BD%E5%B7%B2%E5%85%B3%E9%97%AD',
  52. screenshotStart:'%E6%88%AA%E5%9B%BE%E4%B8%AD%EF%BC%8C%E8%AF%B7%E7%A8%8D%E5%80%99...',
  53. screenshotClose:'%E6%88%AA%E5%9B%BE%E5%8A%9F%E8%83%BD%E5%B7%B2%E5%85%B3%E9%97%AD',
  54. loopOpen:'%E5%BE%AA%E7%8E%AF%E6%92%AD%E6%94%BE',
  55. loopClose:'%E5%B7%B2%E5%85%B3%E9%97%AD%E5%BE%AA%E7%8E%AF%E6%92%AD%E6%94%BE',
  56. close:'%E5%85%B3%E9%97%AD',
  57. down:'%E4%B8%8B%E8%BD%BD',
  58. p50:'50%25',
  59. p75:'75%25',
  60. p100:'100%25',
  61. timeScheduleAdjust:{
  62. prohibit:'%E8%A7%86%E9%A2%91%E7%A6%81%E6%AD%A2%E6%8B%96%E5%8A%A8',
  63. prohibitBackOff:'%E8%A7%86%E9%A2%91%E7%A6%81%E6%AD%A2%E9%87%8D%E5%A4%8D%E8%A7%82%E7%9C%8B',
  64. prohibitForward:'%E8%A7%86%E9%A2%91%E7%A6%81%E6%AD%A2%E5%BF%AB%E8%BF%9B',
  65. prohibitLookBack:'%E8%A7%86%E9%A2%91%E7%A6%81%E6%AD%A2%E6%92%AD%E6%94%BE%E9%83%A8%E5%88%86%E5%86%85%E5%AE%B9',
  66. prohibitForwardNotViewed:'%E8%A7%86%E9%A2%91%E7%A6%81%E6%AD%A2%E6%92%AD%E6%94%BE%E6%9C%AA%E8%A7%82%E7%9C%8B%E7%9A%84%E9%83%A8%E5%88%86'
  67. },
  68. error:{
  69. noMessage:'%E6%9C%AA%E7%9F%A5%E9%94%99%E8%AF%AF',
  70. supportVideoError:'%E8%AF%A5%E6%B5%8F%E8%A7%88%E5%99%A8%E7%89%88%E6%9C%AC%E5%A4%AA%E4%BD%8E%EF%BC%8C%E5%BB%BA%E8%AE%AE%E6%9B%B4%E6%8D%A2%E6%88%90%E5%85%B6%E5%AE%83%E6%B5%8F%E8%A7%88%E5%99%A8',
  71. videoTypeError:'%E8%AF%A5%E6%B5%8F%E8%A7%88%E5%99%A8%E4%B8%8D%E6%94%AF%E6%8C%81%E6%92%AD%E6%94%BE%E8%AF%A5%E8%A7%86%E9%A2%91%EF%BC%8C%E5%BB%BA%E8%AE%AE%E6%9B%B4%E6%8D%A2%E6%88%90%E5%85%B6%E5%AE%83%E6%B5%8F%E8%A7%88%E5%99%A8',
  72. loadingFailed:'%E5%8A%A0%E8%BD%BD%E5%A4%B1%E8%B4%A5',
  73. emptied:'%E8%A7%86%E9%A2%91%E6%96%87%E4%BB%B6%E5%8A%A0%E8%BD%BD%E8%BF%87%E7%A8%8B%E4%B8%AD%E5%87%BA%E7%8E%B0%E9%94%99%E8%AF%AF',
  74. screenshot:'%E8%A7%86%E9%A2%91%E6%88%AA%E5%9B%BE%E5%A4%B1%E8%B4%A5',
  75. ajax:'Ajax%E6%95%B0%E6%8D%AE%E8%AF%B7%E6%B1%82%E9%94%99%E8%AF%AF',
  76. noVideoContainer:'%E6%9C%AA%E6%89%BE%E5%88%B0%E6%94%BE%E7%BD%AE%E8%A7%86%E9%A2%91%E7%9A%84%E5%AE%B9%E5%99%A8'
  77. }
  78. };
  79. /*
  80. * videoObjectDefault
  81. * 功能:静态变量,默认播放配置,当外部传递过来的配置有未包含在varsDefault里的,则使用varsDefault里的配置
  82. */
  83. var videoObjectDefault= {
  84. container: '',//视频容器的ID
  85. volume: 0.8,//默认音量,范围0-1
  86. poster: '',//封面图片地址
  87. autoplay: false,//是否自动播放
  88. loop: false,//是否需要循环播放
  89. live: false,//是否是直播
  90. rotate:0,//视频旋转角度
  91. zoom:0,//默认缩放比例
  92. ad:null,//广告
  93. backLive:false,//显示返回直播按钮
  94. seek: 0,//默认需要跳转的秒数
  95. next: null,//下一集按钮动作
  96. loaded: '',//加载播放器后调用的函数
  97. plug: '',//使用插件
  98. duration:0,//视频总时间
  99. preview: null,//预览图片对象
  100. prompt: null,//提示点功能
  101. crossOrigin:'',//跨域请求字符
  102. video: null,//视频地址
  103. type:'',//视频类型
  104. playbackrate: 1,//默认倍速
  105. ended:null,//结束显示的内容
  106. webFull:false,//页面全屏按钮事件
  107. theatre:null,//剧场模式
  108. controls:false,//是否显示自带控制栏
  109. rightBar:null,//是否开启右边控制栏
  110. smallWindows:null,//是否启用小窗口模式
  111. smallWindowsDrag:true,//当处于小窗口模式时是否可拖动播放器
  112. screenshot:false,//截图功能是否开启
  113. timeScheduleAdjust:1,//是否可调节播放进度,0不启用,1是启用,2是只能前进(向右拖动),3是只能后退,4是只能前进但能回到第一次拖动时的位置,5是看过的地方可以随意拖动
  114. logo:'',//logo
  115. menu:null,//右键菜单
  116. information:{//关于
  117. 'Load:':'{loadTime} second',
  118. 'Duration:':'{duration} second',
  119. 'Size:':'{videoWidth}x{videoHeight}',
  120. 'Volume:':'{volume}%',
  121. 'Fps:':'{fps}fps',
  122. 'Sudio decoded:':'{audioDecodedByteCount} Byte',
  123. 'Video decoded:':'{videoDecodedByteCount} Byte'
  124. },
  125. track:null,//字幕
  126. title:'',//视频标题
  127. language:'',//语言包文件
  128. barHideTime:1500,//控制栏隐藏时间
  129. playbackrateOpen:true,//是否开启控制栏倍速选项
  130. playbackrateList:[0.75,1,1.25,1.5,2,4],//倍速配置值
  131. cookie:null,//开启cookie功能
  132. domain:null,//指定cookie保存的域
  133. cookiePath:'/',//指定cookie保存路径
  134. documentFocusPause:false,//窗口失去焦点后暂停播放
  135. mouseWheelVolume:2,//是否启用鼠标滚轮调节音量功能,0=不启用,1=启用,2=全屏时才启用
  136. keyVolume:2,//是否启用键盘控制音量调节,0=不启用,1=启用,2=全屏时才启用
  137. errorShow:true//是否显示错误信息
  138. };
  139. function ckplayerEmbed(videoObj){
  140. /*
  141. * rightMenu
  142. * 功能:全局变量,右键内容
  143. * 初始化设置menu可替换该变量内容
  144. */
  145. var rightMenu=[
  146. {
  147. title:'ckplayer',
  148. link:'http://www.ckplayer.com'
  149. },
  150. {
  151. title:'version:X3',
  152. underline:true
  153. },
  154. {
  155. title:'about',
  156. click:'aboutShow'
  157. }
  158. ];
  159. var vars={},varsTemp={};//保存传递过来的videoObject
  160. var video=null;//视频播放器对象
  161. var duration=0;//总时间
  162. var mutedState='';//默认静音状态
  163. var recoveryVolume=false;//是否需要在播放时恢复音量
  164. var waited=true;//是否缓冲结束
  165. var paused=true;//默认暂停状态
  166. var loadTime=0;//已加载部分
  167. var seekTime=0;//需要跳转的时间,初次播放以及切换清晰度后会用该变量记录需要seek的时间
  168. var oldTime=0,playTime=0,firstSeekTime=-1,maxSeeTime=0;//oldTime=记录上次播放时间,playTime=当前播放时间,firstSeekTime=记录第一次拖动的时间,maxSeeTime=看过的最大时间
  169. var isChangeDef=true;//是否需要重置清晰度
  170. var playType='';//播放类别,默认='',是通过api接口播放,='button'则判定是通过点击按钮播放
  171. var msgSetTime=null,tipSetTime=null,mouseSetTime=null;//用于显示提示后自动隐藏的计时器
  172. var adFrontSetTime=null,adPauseSetTime=null;//贴片广告和暂停广告的计时器
  173. var closeTipFun=null;//关闭提示的函数
  174. var closeTipMouseOut=null;//鼠标离开节点时执行的函数
  175. var waitingMessage=true;//显示缓冲提示
  176. var hidePreviewSetTime=null;//隐藏预览图的计时器
  177. var pSliderMouseDown=false;//判断是否在进度条上的滑块上按下
  178. var playbackTime=0;//记录回放时间
  179. var loadedmetadataNum=0;//记录元数据加载成功次数,记录视频播放数量
  180. var screenshotImg=null;//记录最新一张截图
  181. var ad=null;//广告对象
  182. var frontAdPlay=false,pauseAdPlay=false;//贴片广告是否播放,暂停广告是否播放
  183. var barShow=true,rightBarShow=true;
  184. var EventTarget=null,newEvent=null,eventTargetList=null;//注册监听
  185. var loadedTrack=false;//默认未加载字幕
  186. var C={};//保存播放器界面上的所有节点
  187. var CT=null,CK=null,CM=null,CV=null;//CT=播放器容器,页面中已存的,CT>CK>CM>CV>video
  188. var pugPlayer=null;//插件播放器
  189. var hls=null;//播放hls
  190. var loadMeta=true;//第一次加载到元数据
  191. var app='';//平台类型
  192. var nowRotate=0;//当前视频旋转角度
  193. var nowZoom=100;//当前缩放比例
  194. var smallWindowsState=false;//当前是否处理小窗口状态
  195. var isDrag=false;//是否在播放器上按下并且拖动
  196. var ckplayerCookie='ckplayer-player-cookie';
  197. var cookieName='';//cookie名称
  198. var cookieTime=0;//cookie保存时间,单位:秒
  199. var cookieArray=[];//保存当前所有记录
  200. var focusPause=true;//失去焦点前是否是暂停状态
  201. var existenceObj=false;//是否使用源码里已有的dom
  202. /*
  203. * into
  204. * 功能:初始化,调用播放器则首先调用该函数
  205. * @obj=初始化时的配置对象:videoObject
  206. */
  207. var into=function(obj){
  208. /*
  209. * 如果未传递初始化配置对象,则为player变量增加一个add函数,功能相当于into
  210. */
  211. if(isUndefined(obj)){
  212. player.add=player.into=into;
  213. return player;
  214. }
  215. /*
  216. * 转码默认语言包
  217. */
  218. language=decodeURIString(language);
  219. /*
  220. * 检查是否在顶部引入了外部语言包文件,如果引入了,则使用外部语言包替换进language变量
  221. */
  222. if(!isUndefined(window.ckplayerLanguage)){
  223. language=mergeObj(language,window.ckplayerLanguage);
  224. }
  225. /*
  226. * 初始化注册事件函数,该函数的作用是将所有相关的事件都注册进一个变量newEvent
  227. * newEvent是提供给播放器外部监听函数使用的,如监听时间player.time(function(t){console.log('已播放:'+t);});
  228. */
  229. eventTarget();
  230. /*
  231. * 监听页面标签状态(判断是否失去焦点)
  232. */
  233. documentHidden(function(state){
  234. eventTarget('visibilityState',state);
  235. });
  236. /*
  237. * 判断平台类型,主要是判断是否是iphone类型的平台
  238. */
  239. app=getApp();
  240. /*
  241. * 简单复制一下初始化时的默认配置
  242. */
  243. varsTemp={};
  244. for(var key in videoObjectDefault){
  245. varsTemp[key]=videoObjectDefault[key];
  246. }
  247. /*
  248. * 如果初始化配置是字符串并且是以website:开头或url:开头的,则认为需要请求一个json文件来获取配置
  249. */
  250. if(valType(obj)=='string' && (obj.substr(0,8)=='website:' || obj.substr(0,4)=='url:')){
  251. var ajaxUrl='';
  252. if(obj.substr(0,8)=='website:'){
  253. ajaxUrl=obj.substring(8);
  254. }
  255. if(obj.substr(0,4)=='url:'){
  256. ajaxUrl=obj.substring(4);
  257. }
  258. ajax({url:ajaxUrl,success:function(data){
  259. if(data){
  260. return into(data);
  261. }
  262. else{
  263. showWindowsError(language['error']['ajax']+',url:'+ajaxUrl);
  264. return null;
  265. }
  266. }});
  267. }
  268. /*
  269. * 如果初始化配置是一个object,则进行下面的操作
  270. */
  271. else if(valType(obj)=='object'){
  272. varsTemp = standardization(varsTemp, obj);//将obj合并到varsTemp对象里
  273. if(!isUndefined(obj['container']) && obj['container']){
  274. CT=$(obj['container']);
  275. if(CT){//如果播放容器存在,则调用语言判断函数
  276. return loadLanguage(obj);
  277. }
  278. else{//如果播放容器不存在,则则等页面加载完成后运行
  279. return bodyReady(obj);
  280. }
  281. }
  282. else{//不存在播放容器配置则等页面加载完成后运行
  283. return bodyReady(obj);
  284. }
  285. }
  286. else{
  287. showWindowsError(language['error']['noVideoContainer']);
  288. return null;
  289. }
  290. },
  291. /*
  292. * bodyReady
  293. * 功能:页面加载完成后构建播放器
  294. * @obj=初始化时的配置对象
  295. */
  296. bodyReady=function (obj){
  297. documentReady(function(){
  298. if(!isUndefined(obj['container'])){
  299. CT=$(obj['container']);
  300. if(CT){//如果播放容器存在,则调用语言判断函数
  301. return loadLanguage(obj);
  302. }
  303. else{
  304. showWindowsError(language['error']['noVideoContainer']);
  305. return null;
  306. }
  307. }
  308. else{//不存在播放容器则重新判断
  309. return ajaxWebsite(obj);
  310. }
  311. });
  312. return null;
  313. },
  314. /*
  315. * ajaxWebsite
  316. * 功能:页面加载完成后重新初始化
  317. * @obj=初始化时的配置对象
  318. */
  319. ajaxWebsite=function (obj){
  320. if(valType(obj['video'])=='string' && (obj['video'].substr(0,8)=='website:' || obj['video'].substr(0,4)=='url:')){
  321. varsTemp = standardization(varsTemp, obj);
  322. var ajaxUrl='';
  323. if(obj['video'].substr(0,8)=='website:'){
  324. ajaxUrl=obj['video'].substring(8);
  325. }
  326. if(obj['video'].substr(0,4)=='url:'){
  327. ajaxUrl=obj['video'].substring(4);
  328. }
  329. ajax({url:ajaxUrl,success:function(data){
  330. if(data){
  331. return into(data);
  332. }
  333. else{
  334. showWindowsError(language['error']['ajax']+',url:'+ajaxUrl);
  335. return null;
  336. }
  337. }});
  338. }
  339. else{
  340. showWindowsError(language['error']['noVideoContainer']);
  341. return null;
  342. }
  343. },
  344. /*
  345. * loadLanguage
  346. * 功能:加载Language
  347. * @obj=初始化时的配置对象
  348. */
  349. loadLanguage=function (obj){
  350. vars = standardization(varsTemp, obj);
  351. if(vars['language']){
  352. var path=getPath('language')+vars['language']+'.js';
  353. loadJs(path,function(){
  354. if(!isUndefined(window['ckplayerLanguage'])){
  355. language=mergeObj(language,window['ckplayerLanguage']);
  356. }
  357. return embed(obj);
  358. });
  359. }
  360. else{
  361. return embed(obj);
  362. }
  363. },
  364. /*
  365. * embed
  366. * 功能:构建播放器
  367. * @obj=初始化时的配置对象
  368. */
  369. embed=function (obj){
  370. /*
  371. * 判断静音状态
  372. */
  373. mutedState=vars['volume']>0?false:true;
  374. if(!isUndefined(CT) && CT!=null){
  375. if(valType(CT)=='htmlarray'){
  376. CT=CT.eq(0);
  377. }
  378. }
  379. else{
  380. return null;
  381. }
  382. /*
  383. * 注册获取fps的函数
  384. */
  385. calculationFps();
  386. /*
  387. * 如果video指向一个已存在的video标签对象
  388. */
  389. existenceObj=valType(vars['video'])=='string' && ((vars['video'].substr(0,1)=='.' && vars['video'].indexOf('/')==-1) || vars['video'].substr(0,1)=='#');
  390. /*
  391. * 清空容器
  392. */
  393. if(existenceObj){
  394. CK=CT.find('.ckplayer-ckplayer')?CT.find('.ckplayer-ckplayer').eq(0):null;
  395. if(CK){
  396. CM=CK.find('.ck-main')?CK.find('.ck-main').eq(0):null;
  397. }
  398. if(CM){
  399. CV=CM.find('.ck-video')?CM.find('.ck-video').eq(0):null;
  400. }
  401. }
  402. if(!CK || !CM || !CV){
  403. CT.htm('');
  404. /*
  405. * 在播放容器里新建一个总的容器
  406. */
  407. CK=createlDiv('ckplayer-ckplayer');
  408. CT.append(CK);
  409. /*
  410. * 在总容器里再新建一个容器
  411. */
  412. CM=createlDiv('ck-main');
  413. CK.append(CM);
  414. /*
  415. * 新建一个放置video标签的容器
  416. */
  417. CV=createlDiv('ck-video');
  418. CM.append(CV);
  419. }
  420. /*
  421. * 如果已存在video.则先设置成空
  422. */
  423. if(video){
  424. video.remove();
  425. video=null;
  426. }
  427. /*
  428. * 如果video指向一个已存在的video标签对象,则直接调用该对象
  429. */
  430. if(existenceObj){
  431. video=$(vars['video'])?$(vars['video']).eq(0):null;
  432. }
  433. /*
  434. * 新建一个video标签
  435. */
  436. if(!video){
  437. video = createlVideo();
  438. video.attr('width','100%').attr('height','100%');
  439. CV.append(video);
  440. }
  441. video.volume=vars['volume'];
  442. if(vars['autoplay']){
  443. player.volume(0);
  444. player.muted();
  445. recoveryVolume=true;
  446. video.attr('autoplay','autoplay');
  447. paused=false;
  448. }
  449. else{
  450. video.attr('preload','metadata');
  451. }
  452. CT.loop=vars['loop'];
  453. if(CT.loop){
  454. video.attr('loop','loop');
  455. }
  456. if(vars['controls']){
  457. video.controls=true;
  458. }
  459. else{
  460. video.controls=false;
  461. }
  462. try{
  463. if(!existenceObj){
  464. video.attr('controlslist','nodownload');
  465. video.attr('x-webkit-airplay','true');
  466. video.attr('x5-video-orientation','portraint');
  467. video.attr('playsinline','true');
  468. video.attr('webkit-playsinline','true');
  469. video.attr('x5-playsinline','true');
  470. }
  471. if(vars['crossOrigin']){
  472. video.useCORS=true;//解决跨域
  473. video.crossOrigin=vars['crossOrigin'];//解决跨域
  474. }
  475. }
  476. catch(event){}
  477. /*
  478. * 默认设置支持小窗口模式
  479. */
  480. CT.smallWindows=true;
  481. /*
  482. * 默认设置不显示页面全屏按钮
  483. */
  484. CT.webFull=false;
  485. /*
  486. * 默认设置不显示剧场模式按钮
  487. */
  488. CT.theatre=false;
  489. /*
  490. * 加载播放器界面
  491. */
  492. loadFace();
  493. /*
  494. * 判断是否需要默认旋转视频
  495. */
  496. if(vars['rotate']>0){
  497. player.rotate(vars['rotate']);
  498. }
  499. /*
  500. * 判断是否需要默认缩放视频
  501. */
  502. if(vars['zoom']>0){
  503. player.zoom(vars['zoom']);
  504. }
  505. /*
  506. * 判断是否支持video标签
  507. */
  508. if(isUndefined(video.canPlayType)){
  509. CT.error={code:5,message:language['error']['supportVideoError']};
  510. eventTarget('error',CT.error);//注册监听error
  511. showError();
  512. return player;
  513. }
  514. /*
  515. * 注册视频播放器内部监听,监听到事件后注册给CT使用
  516. */
  517. addAllListener();
  518. /*
  519. * 如果需要在视频播放器加载成功后调用相关函数,此时则开始调用
  520. */
  521. if(!isUndefined(vars['loaded'])){
  522. if(valType(vars['loaded'])=='function'){
  523. try{
  524. vars['loaded'](player);
  525. }
  526. catch(event){}
  527. }
  528. else if(valType(vars['loaded'])=='string'){
  529. try{
  530. eval(vars['loaded']+ '(player)');
  531. }
  532. catch(event){}
  533. }
  534. }
  535. /*
  536. * 播放视频
  537. */
  538. if(!existenceObj){
  539. changeVideo(vars['video']);
  540. }
  541. else{
  542. changeVideo(video.attr('src'));
  543. }
  544. /*
  545. * 返回 播放器
  546. */
  547. return player;
  548. },
  549. /*
  550. * changeVideo
  551. * 功能:初始化视频地址或修改视频地址
  552. */
  553. changeVideo=function (vstr){
  554. var i=0;
  555. if(video.attr('src') || video.htm()){
  556. player.pause();
  557. }
  558. if(video.attr('src') && !existenceObj){
  559. video.attr('src','');
  560. video.removeAttr('src');
  561. }
  562. if(!isUndefined(video.textTracks) && video.textTracks.length>0){
  563. for(i=video.find('track').length-1;i>-1;i--){
  564. video.find('track').eq(i).remove();
  565. }
  566. }
  567. if(!existenceObj){
  568. video.htm('');
  569. }
  570. if(!isUndefined(vars['ad'])){
  571. ad=vars['ad'];
  572. }
  573. var source='';
  574. if(valType(vstr)=='string'){
  575. if(vstr.substr(0,8)=='website:' || vstr.substr(0,4)=='url:'){
  576. var ajaxUrl='';
  577. if(vstr.substr(0,8)=='website:'){
  578. ajaxUrl=vstr.substring(8);
  579. }
  580. if(vstr.substr(0,4)=='url:'){
  581. ajaxUrl=vstr.substring(4);
  582. }
  583. ajax({url:ajaxUrl,success:function(data){
  584. if(data!=null){
  585. vars = standardization(varsTemp, data);
  586. changeVideo(vars['video']);
  587. }
  588. else{
  589. CT.error={code:8,message:language['error']['ajax']};
  590. eventTarget('error',CT.error);//注册监听error
  591. showError();
  592. }
  593. }});
  594. return;
  595. }
  596. else{
  597. if(vars['plug'] && !canPlay(vstr)){
  598. plugPlayer(vstr);
  599. }
  600. else{
  601. if(!existenceObj){
  602. video.attr('src',vstr);
  603. }
  604. }
  605. loadTrack();
  606. }
  607. }
  608. else if(valType(vstr)=='array'){
  609. for(i=0;i<vstr.length;i++){
  610. if(valType(vstr[i])=='array'){
  611. if(vars['plug'] && !canPlay(vstr[i][0])){
  612. plugPlayer(vstr[i][0]);
  613. }
  614. else{
  615. var type=' type="'+ vstr[i][1]+'"';
  616. if(vstr[i].length>1){
  617. source += '<source src="' + decodeURIComponent(vstr[i][0]) + '"' +type + '>';
  618. }
  619. }
  620. }
  621. }
  622. if(source){
  623. video.htm(source);
  624. }
  625. loadTrack();
  626. }
  627. else if(valType(vstr)=='object'){
  628. if(vars['plug']){
  629. plugPlayer(vstr);
  630. }
  631. else{
  632. CT.error={code:10,message:language['error']['emptied']};
  633. eventTarget('error',CT.error);//注册监听error
  634. showError();
  635. }
  636. loadTrack();
  637. }
  638. if(!isUndefined(video.find('source')) && video.find('source').length>0){
  639. video.find('source').eq(video.find('source').length-1).addListener('error',videoHandler.error);
  640. }
  641. checkBar();
  642. loadLogo();
  643. if(isChangeDef){
  644. checkDefinition();
  645. }
  646. /*
  647. * 对cookie进行相关分析
  648. */
  649. if(vars['cookie']){
  650. if(valType(vars['cookie'])=='array' && vars['cookie'].length>=2){
  651. if(vars['cookie'][0] && valType(vars['cookie'][0])=='string'){
  652. cookieName=vars['cookie'][0];
  653. }
  654. if(vars['cookie'][1] && valType(vars['cookie'][1])=='number'){
  655. cookieTime=vars['cookie'][1];
  656. }
  657. }
  658. if(valType(vars['cookie'])=='object' && !isUndefined(vars['cookie']['name'])){
  659. cookieName=vars['cookie']['name'];
  660. if(!isUndefined(vars['cookie']['hour']) && valType(vars['cookie']['hour'])=='number'){
  661. cookieTime=vars['cookie']['hour'];
  662. }
  663. }
  664. if(valType(vars['cookie'])=='string'){
  665. cookieName=vars['cookie'];
  666. }
  667. if(cookieName){
  668. cookieName=cookieName.replace(/[ ]*,[ ]*|[ ]+/g, '').replace(/[ ]*;[ ]*|[ ]+/g, '');
  669. }
  670. }
  671. if(!isUndefined(vars['seek']) && !seekTime){
  672. if(valType(vars['seek'])=='number' && vars['seek']>0){
  673. seekTime=vars['seek'];
  674. }
  675. if(valType(vars['seek'])=='string' && vars['seek']=='cookie' && cookieName){
  676. var cke=player.cookie(cookieName);
  677. if(cke){
  678. seekTime=cke['time'];
  679. }
  680. }
  681. }
  682. },
  683. /*
  684. * plugPlayer
  685. * 功能:使用插件进行播放
  686. */
  687. plugPlayer=function (url){
  688. switch(vars['plug']){
  689. case 'hls.js':
  690. hlsPlayer(url);
  691. break;
  692. case 'flv.js':
  693. flvPlayer(url);
  694. break;
  695. case 'mpegts.js':
  696. mpegtsPlayer(url);
  697. break;
  698. case 'dash.js':
  699. dashPlayer(url);
  700. break;
  701. default:
  702. if(valType(vars['plug'])=='function'){
  703. vars['plug'](video,url);
  704. }
  705. else{
  706. CT.error={code:10,message:language['error']['emptied']};
  707. eventTarget('error',CT.error);//注册监听error
  708. showError();
  709. }
  710. break;
  711. }
  712. },
  713. /*
  714. * hlsPlayer
  715. * 功能:使用hls.js插件进行播放
  716. */
  717. hlsPlayer=function (url){
  718. var path=getPath('hls.js')+'hls.min.js';
  719. loadJs(path,function(){
  720. if (!isUndefined(Hls) && Hls.isSupported()) {
  721. hls = new Hls();
  722. hls.loadSource(url);
  723. hls.attachMedia(video);
  724. hls.on(Hls.Events.ERROR, function(event, data){
  725. var code=9;
  726. var message=language['error']['loadingFailed'];
  727. var fatal=data.fatal;
  728. if(!isUndefined(data.response)){
  729. if(!isUndefined(data.response.code)){
  730. code=data.response.code;
  731. }
  732. if(!isUndefined(data.response.text) && data.response.text){
  733. message=data.response.text;
  734. }
  735. else{
  736. if(!isUndefined(event)){
  737. message=event;
  738. }
  739. }
  740. }
  741. CT.error={code:code,message:message};
  742. eventTarget('error',CT.error);//注册监听error
  743. if(fatal){
  744. showError();
  745. }
  746. });
  747. }
  748. else if(canPlay(url)){
  749. video.attr('src',url);
  750. }
  751. });
  752. },
  753. /*
  754. * flvPlayer
  755. * 功能:使用flv.js插件进行播放
  756. */
  757. flvPlayer=function (url){
  758. var path=getPath('flv.js')+'flv.min.js';
  759. loadJs(path,function(){
  760. if (typeof(flvjs)!='undefined' && !isUndefined(flvjs) && flvjs.isSupported()) {
  761. var config={
  762. type: 'flv',
  763. url: url
  764. };
  765. if(valType(url)=='object'){
  766. config=url;
  767. }
  768. if(vars['live']){
  769. config['isLive']=true;
  770. }
  771. if(pugPlayer){
  772. pugPlayer.pause();
  773. pugPlayer.unload();
  774. pugPlayer.detachMediaElement();
  775. pugPlayer.destroy();
  776. pugPlayer=null;
  777. }
  778. pugPlayer = flvjs.createPlayer(config);
  779. pugPlayer.attachMediaElement(video);
  780. pugPlayer.load();
  781. pugPlayer.on(flvjs.Events.METADATA_ARRIVED, function(res){
  782. videoHandler.loadedMetaData();
  783. });
  784. pugPlayer.on(flvjs.Events.ERROR, function(errorType, errorDetail, errorInfo){
  785. CT.error={code:errorInfo['code'],message:errorInfo['msg']};
  786. eventTarget('error',CT.error);//注册监听error
  787. showError();
  788. });
  789. }
  790. });
  791. },
  792. /*
  793. * mpegtsPlayer
  794. * 功能:使用mpegts.js插件进行播放
  795. */
  796. mpegtsPlayer=function (url){
  797. var path=getPath('mpegts.js')+'mpegts.js';
  798. loadJs(path,function(){
  799. if (typeof(mpegts)!='undefined' && !isUndefined(mpegts) && mpegts.getFeatureList().mseLivePlayback) {
  800. var config={
  801. type: 'mse',
  802. url: url
  803. };
  804. if(valType(url)=='object'){
  805. config=url;
  806. }
  807. if(vars['live']){
  808. config['isLive']=true;
  809. }
  810. if(pugPlayer){
  811. pugPlayer.pause();
  812. pugPlayer.unload();
  813. pugPlayer.detachMediaElement();
  814. pugPlayer.destroy();
  815. pugPlayer=null;
  816. }
  817. pugPlayer = mpegts.createPlayer(config);
  818. pugPlayer.attachMediaElement(video);
  819. pugPlayer.load();
  820. pugPlayer.on(mpegts.Events.METADATA_ARRIVED, function(res){
  821. videoHandler.loadedMetaData();
  822. });
  823. pugPlayer.on(mpegts.Events.ERROR, function(errorType, errorDetail, errorInfo){
  824. CT.error={code:errorInfo['code'],message:errorInfo['msg']};
  825. eventTarget('error',CT.error);//注册监听error
  826. showError();
  827. });
  828. }
  829. });
  830. },
  831. /*
  832. * canPlay
  833. * 功能:判断是否能支持相关视频格式
  834. */
  835. canPlay=function(vStr,num){
  836. var vTypeArr=[
  837. {vidType:'video/ogg',codType:'theora, vorbis'},
  838. {vidType:'video/mp4',codType:'avc1.4D401E, mp4a.40.2'},
  839. {vidType:'video/mp4',codType:'avc1'},
  840. {vidType:'video/mp4',codType:'hevc'},
  841. {vidType:'video/webm',codType:'vp8.0, vorbis'},
  842. {vidType:'video/webm',codType:'vp9'},
  843. {vidType:'',codType:'application/x-mpegURL'},
  844. {vidType:'',codType:'application/vnd.apple.mpegurl'}
  845. ];
  846. var vType={
  847. ogg:vTypeArr[0],
  848. mp4:[vTypeArr[1],vTypeArr[2],vTypeArr[3]],
  849. webm:[vTypeArr[4],vTypeArr[5]],
  850. m3u8:[vTypeArr[6],vTypeArr[7]]
  851. };
  852. var arr=[];
  853. var k='';
  854. var supportType=function(obj){
  855. var vType=obj['vidType'];
  856. var str='';
  857. if(vType){
  858. str=vType+'; '+ 'codecs="' + obj['codType'] + '"';
  859. }
  860. else{
  861. str=obj['codType'];
  862. }
  863. var sup = video.canPlayType(str);
  864. if(sup == '') {
  865. sup = 'no';
  866. }
  867. return sup;
  868. };
  869. var getExtension=function(filepath) {
  870. return filepath.replace(/.+\./, '');
  871. };
  872. if(isUndefined(num)){
  873. if(valType(vStr)=='string'){
  874. if(vars['type']){
  875. for(k in vTypeArr){
  876. if(vTypeArr[k]['vidType']==vars['type']){
  877. arr.push(vTypeArr[k]);
  878. }
  879. }
  880. }
  881. else{
  882. if(getExtension(vStr) && getExtension(vStr) in vType){
  883. var temp=vType[getExtension(vStr)];
  884. if(valType(temp)=='array'){
  885. for(var i=0;i<temp.length;i++){
  886. arr.push(temp[i]);
  887. }
  888. }
  889. else{
  890. arr.push(temp);
  891. }
  892. }
  893. }
  894. }
  895. }
  896. else{
  897. arr.push(vTypeArr[num]);
  898. }
  899. var is=false;
  900. if(arr.length>0){
  901. for(var i=0;i<arr.length;i++){
  902. if(supportType(arr[i])!='no'){
  903. is=true;
  904. }
  905. }
  906. }
  907. if(!is && !vars['plug']){
  908. CT.error={code:6,message:language['error']['videoTypeError']};
  909. eventTarget('error',CT.error);//注册监听error
  910. showError();
  911. }
  912. return is;
  913. },
  914. /*
  915. * loadFace
  916. * 功能:加载界面
  917. */
  918. loadFace=function(){
  919. //loading容器
  920. C['loading']=createlDiv('ck-loading');
  921. CM.append(C['loading']);
  922. //默认控制栏容器
  923. C['bar']=createlDiv('ck-bar');
  924. CM.append(C['bar']);
  925. //右侧控制栏容器
  926. C['rightBar']=createlDiv('ck-right-bar ck-right-bar-hide');
  927. CM.append(C['rightBar']);
  928. //顶部容器
  929. C['topBar']=createlDiv('ck-top-bar ck-top-bar-hide');
  930. CM.append(C['topBar']);
  931. //进度栏
  932. C['bar']['pbox']=createlDiv('ck-bar-progress');
  933. C['bar']['pbox']['bg']=createlDiv('ck-bar-progress-bg');
  934. C['bar']['pbox']['load']=createlDiv('ck-bar-progress-load');
  935. C['bar']['pbox']['bg'].append(C['bar']['pbox']['load']);
  936. C['bar']['pbox']['play']=createlDiv('ck-bar-progress-play');
  937. C['bar']['pbox']['bg'].append(C['bar']['pbox']['play']);
  938. C['bar']['pbox']['mouseLine']=createlDiv('ck-bar-progress-mouseline');
  939. C['bar']['pbox']['bg'].append(C['bar']['pbox']['mouseLine']);
  940. C['bar']['pbox']['slider']=createlDiv('ck-bar-progress-slider');
  941. C['bar']['pbox'].append(C['bar']['pbox']['bg']).append(C['bar']['pbox']['slider']);
  942. C['bar'].append(C['bar']['pbox']);
  943. C['bar'].mouseout(barMouseOut).mouseover(barMouseOver);
  944. if(valType(vars['live'])=='number'){
  945. C['bar']['pbox']['play'].css({'width':'100%'});
  946. C['bar']['pbox']['slider'].css({'left':(100-C['bar']['pbox']['slider'].getWidth()*100/C['bar']['pbox']['bg'].getWidth())+'%'});
  947. }
  948. //播放暂停按钮组
  949. C['bar']['playAndPause']=createlDiv('ck-bar-playandpause');
  950. C['bar'].append(C['bar']['playAndPause']);
  951. C['bar']['playAndPause']['play']=createlButton('ck-bar-btn ck-btn-play');
  952. C['bar']['playAndPause']['play'].click(player.play);
  953. C['bar']['playAndPause']['play'].mouseover(function(){tip(this,language['play']);});
  954. C['bar']['playAndPause'].append(C['bar']['playAndPause']['play']);
  955. C['bar']['playAndPause']['pause']=createlButton('ck-bar-btn ck-btn-pause');
  956. C['bar']['playAndPause']['pause'].click(player.pause);
  957. C['bar']['playAndPause']['pause'].mouseover(function(){tip(this,language['pause']);});
  958. C['bar']['playAndPause'].append(C['bar']['playAndPause']['pause']);
  959. C['bar']['playAndPause']['pause'].hide();
  960. C['bar']['playAndPause']['refresh']=createlButton('ck-bar-btn ck-btn-refresh');
  961. C['bar']['playAndPause']['refresh'].click(player.play);
  962. C['bar']['playAndPause']['refresh'].mouseover(function(){tip(this,language['refresh']);});
  963. C['bar']['playAndPause'].append(C['bar']['playAndPause']['refresh']);
  964. //下一集按钮
  965. C['bar']['nextEpisode']=createlDiv('ck-bar-btn ck-bar-next');
  966. C['bar'].append(C['bar']['nextEpisode']);
  967. C['bar']['nextEpisode'].click(nextClick).mouseover(showNextEpisode).mouseout(function(){
  968. if(!isUndefined(C['next'])){
  969. player.closeLayer(C['next']);
  970. }
  971. });
  972. if(isUndefined(vars['next'])){
  973. C['bar']['nextEpisode'].hide();
  974. }
  975. //时间显示框
  976. var timeDefault=formatSeconds(player.time())+'/'+formatSeconds(duration);
  977. if(vars['live']){
  978. timeDefault=language['live'];
  979. }
  980. C['time']=createlDiv('ck-bar-time',timeDefault);
  981. C['bar'].append(C['time']);
  982. //返回直播按钮
  983. C['bar']['backLive']=createlButton('ck-btn-backlive',language['backLive']);
  984. C['bar'].append(C['bar']['backLive']);
  985. C['bar']['backLive'].mouseover(function(){tip(this,language['backLive']);}).click(function(){
  986. eventTarget('backLive');
  987. });
  988. C['bar']['backLive'].hide();
  989. //全屏按钮组
  990. C['bar']['fullAndExit']=createlDiv('ck-bar-fullandexit');
  991. C['bar'].append(C['bar']['fullAndExit']);
  992. C['bar']['fullAndExit']['full']=createlButton('ck-bar-btn ck-btn-full');
  993. C['bar']['fullAndExit']['full'].click(player.fullOrExit);
  994. C['bar']['fullAndExit']['full'].mouseover(function(){tip(this,language['full']);});
  995. C['bar']['fullAndExit'].append(C['bar']['fullAndExit']['full']);
  996. C['bar']['fullAndExit']['exitFull']=createlButton('ck-bar-btn ck-btn-exitfull');
  997. C['bar']['fullAndExit']['exitFull'].click(player.fullOrExit);
  998. C['bar']['fullAndExit']['exitFull'].mouseover(function(){tip(this,language['exitFull']);});
  999. C['bar']['fullAndExit'].append(C['bar']['fullAndExit']['exitFull']);
  1000. //网页全屏按钮
  1001. C['bar']['webFullAndExit']=createlDiv('ck-bar-webfullandexit');
  1002. C['bar'].append(C['bar']['webFullAndExit']);
  1003. C['bar']['webFullAndExit']['webFull']=createlButton('ck-bar-btn ck-btn-webfull');
  1004. C['bar']['webFullAndExit']['webFull'].click(player.webFull);
  1005. C['bar']['webFullAndExit']['webFull'].mouseover(function(){tip(this,language['webFull']);});
  1006. C['bar']['webFullAndExit'].append(C['bar']['webFullAndExit']['webFull']);
  1007. C['bar']['webFullAndExit']['exitWebFull']=createlButton('ck-bar-btn ck-btn-exitwebfull');
  1008. C['bar']['webFullAndExit']['exitWebFull'].click(player.exitWebFull);
  1009. C['bar']['webFullAndExit']['exitWebFull'].mouseover(function(){tip(this,language['exitWebFull']);});
  1010. C['bar']['webFullAndExit'].append(C['bar']['webFullAndExit']['exitWebFull']);
  1011. if(!vars['webFull']){
  1012. C['bar']['webFullAndExit'].hide();
  1013. }
  1014. //剧场模式按钮组
  1015. C['bar']['theatreAndExit']=createlDiv('ck-bar-theatreandexit');
  1016. C['bar'].append(C['bar']['theatreAndExit']);
  1017. C['bar']['theatreAndExit']['theatre']=createlButton('ck-bar-btn ck-btn-theatre');
  1018. C['bar']['theatreAndExit']['theatre'].click(player.theatre);
  1019. C['bar']['theatreAndExit']['theatre'].mouseover(function(){tip(this,language['theatre']);});
  1020. C['bar']['theatreAndExit'].append(C['bar']['theatreAndExit']['theatre']);
  1021. C['bar']['theatreAndExit']['exitTheatre']=createlButton('ck-bar-btn ck-btn-exittheatre');
  1022. C['bar']['theatreAndExit']['exitTheatre'].click(player.exitTheatre);
  1023. C['bar']['theatreAndExit']['exitTheatre'].mouseover(function(){tip(this,language['exitTheatre']);});
  1024. C['bar']['theatreAndExit'].append(C['bar']['theatreAndExit']['exitTheatre']);
  1025. if(!vars['theatre']){
  1026. C['bar']['theatreAndExit'].hide();
  1027. }
  1028. //音量容器
  1029. C['bar']['vbox']=createlDiv('ck-bar-volumebox');
  1030. C['bar'].append(C['bar']['vbox']);
  1031. C['bar']['vbox']['muted']=createlButton('ck-bar-btn ck-btn-muted');
  1032. C['bar']['vbox']['muted'].click(player.muted);
  1033. C['bar']['vbox'].append(C['bar']['vbox']['muted']);
  1034. C['bar']['vbox']['exitMuted']=createlButton('ck-bar-btn ck-btn-exitmuted');
  1035. C['bar']['vbox']['exitMuted'].click(player.exitMuted);
  1036. C['bar']['vbox'].append(C['bar']['vbox']['exitMuted']);
  1037. C['bar']['vbox']['volume']=createlDiv('ck-bar-volume');
  1038. C['bar']['vbox'].append(C['bar']['vbox']['volume']);
  1039. C['bar']['vbox']['volume']['box']=createlDiv('ck-bar-volumex');
  1040. C['bar']['vbox']['volume'].append(C['bar']['vbox']['volume']['box']);
  1041. C['bar']['vbox']['volume']['txt']=createlDiv('ck-bar-volume-txt','0');
  1042. C['bar']['vbox']['volume']['box'].append(C['bar']['vbox']['volume']['txt']);
  1043. C['bar']['vbox']['volume']['bg']=createlDiv('ck-bar-volume-bg');
  1044. C['bar']['vbox']['volume']['box'].append(C['bar']['vbox']['volume']['bg']);
  1045. C['bar']['vbox']['volume']['pp']=createlDiv('ck-bar-volume-pp');
  1046. C['bar']['vbox']['volume']['bg'].append(C['bar']['vbox']['volume']['pp']);
  1047. C['bar']['vbox']['volume']['slider']=createlDiv('ck-bar-volume-slider');
  1048. C['bar']['vbox']['volume']['box'].append(C['bar']['vbox']['volume']['slider']);
  1049. C['bar']['vbox']['mouseDown']=false;
  1050. C['bar']['vbox']['volume'].show();
  1051. changeVolumeSlider(vars['volume']);
  1052. volumeDragY();//注册音量调节滑块动作
  1053. C['bar']['vbox']['volume'].attr('style','');
  1054. C['bar']['vbox'].mouseover(function(){changeVolumeSlider(video.muted?0:video.volume);});
  1055. //播速容器
  1056. C['bar']['playbackrate']=createlDiv('ck-bar-playbackrate-box');
  1057. C['bar'].append(C['bar']['playbackrate']);
  1058. C['bar']['playbackrate']['button']=createlDiv('ck-bar-playbackrate',language['playbackrate']);
  1059. C['bar']['playbackrate'].append(C['bar']['playbackrate']['button']);
  1060. C['bar']['playbackrate']['bgbox']=createlDiv('ck-bar-playbackrate-bg-box ck-list-bg-box');
  1061. C['bar']['playbackrate'].append(C['bar']['playbackrate']['bgbox']);
  1062. checkPlaybackrate();
  1063. //字幕容器
  1064. C['bar']['track']=createlDiv('ck-bar-track-box');
  1065. C['bar'].append(C['bar']['track']);
  1066. C['bar']['track']['button']=createlDiv('ck-bar-track',language['track']);
  1067. C['bar']['track'].append(C['bar']['track']['button']);
  1068. C['bar']['track']['bgbox']=createlDiv('ck-bar-track-bg-box ck-list-bg-box');
  1069. C['bar']['track'].append(C['bar']['track']['bgbox']);
  1070. C['bar']['track'].hide();
  1071. //清晰度容器
  1072. C['bar']['definition']=createlDiv('ck-bar-definition-box');
  1073. C['bar'].append(C['bar']['definition']);
  1074. C['bar']['definition']['button']=createlDiv('ck-bar-definition',language['definition']);
  1075. C['bar']['definition'].append(C['bar']['definition']['button']);
  1076. C['bar']['definition']['bgbox']=createlDiv('ck-bar-definition-bg-box ck-list-bg-box');
  1077. C['bar']['definition'].append(C['bar']['definition']['bgbox']);
  1078. C['bar']['definition'].hide();
  1079. //截图按钮
  1080. C['rightBar']['screenshot']=createlButton('ck-bar-btn ck-btn-screenshot');
  1081. C['rightBar'].append(C['rightBar']['screenshot']);
  1082. C['rightBar']['screenshot'].mouseover(function(){tip(this,language['screenshot'],null,'left');});
  1083. C['rightBar']['screenshot'].click(player.screenshot);
  1084. //小窗口按钮组
  1085. C['rightBar']['smallwindows']=createlDiv('ck-right-bar-smallwindows');
  1086. C['rightBar'].append(C['rightBar']['smallwindows']);
  1087. C['rightBar']['smallwindows']['open']=createlButton('ck-bar-btn ck-btn-smallwindows-open');
  1088. C['rightBar']['smallwindows']['open'].click(function(){tip(this,language['smallwindowsClose'],null,'left');player.smallWindows(false);});
  1089. C['rightBar']['smallwindows']['open'].mouseover(function(){tip(this,language['smallwindowsOpen'],null,'left');});
  1090. C['rightBar']['smallwindows'].append(C['rightBar']['smallwindows']['open']);
  1091. C['rightBar']['smallwindows']['close']=createlButton('ck-bar-btn ck-btn-smallwindows-close');
  1092. C['rightBar']['smallwindows']['close'].click(function(){tip(this,language['smallwindowsOpen'],null,'left');player.smallWindows(true)});
  1093. C['rightBar']['smallwindows']['close'].mouseover(function(){tip(this,language['smallwindowsClose'],null,'left');});
  1094. C['rightBar']['smallwindows'].append(C['rightBar']['smallwindows']['close']);
  1095. //循环按钮组
  1096. C['rightBar']['loop']=createlDiv('ck-right-bar-loop');
  1097. C['rightBar'].append(C['rightBar']['loop']);
  1098. C['rightBar']['loop']['open']=createlButton('ck-bar-btn ck-btn-loop-open');
  1099. C['rightBar']['loop']['open'].click(function(){tip(this,language['loopClose'],null,'left');player.loop(false);});
  1100. C['rightBar']['loop']['open'].mouseover(function(){tip(this,language['loopOpen'],null,'left');});
  1101. C['rightBar']['loop'].append(C['rightBar']['loop']['open']);
  1102. C['rightBar']['loop']['close']=createlButton('ck-bar-btn ck-btn-loop-close');
  1103. C['rightBar']['loop']['close'].click(function(){tip(this,language['loopOpen'],null,'left');player.loop(true);});
  1104. C['rightBar']['loop']['close'].mouseover(function(){tip(this,language['loopClose'],null,'left');});
  1105. C['rightBar']['loop'].append(C['rightBar']['loop']['close']);
  1106. C['rightBar'].mouseout(rightBarMouseOut).mouseover(rightBarMouseOver);
  1107. //截图显示容器
  1108. C['screenshot']=createlDiv('ck-screenshot');
  1109. CM.append(C['screenshot']);
  1110. C['screenshot']['img']=createlDiv('ck-screenshot-img');
  1111. C['screenshot'].append(C['screenshot']['img']);
  1112. C['screenshot']['bar']=createlDiv('ck-screenshot-bar');
  1113. C['screenshot'].append(C['screenshot']['bar']);
  1114. C['screenshot']['bar']['down']=createlA(language['down'],'','ck-screenshot-btn ck-screenshot-down');
  1115. C['screenshot']['bar'].append(C['screenshot']['bar']['down']);
  1116. C['screenshot']['bar']['close']=createlButton('ck-screenshot-btn ck-screenshot-close',language['close']);
  1117. C['screenshot']['bar']['close'].click(player.closeScreenshot);
  1118. C['screenshot']['bar'].append(C['screenshot']['bar']['close']);
  1119. //顶部内容
  1120. C['topBar']['zoomEle']=createlDiv('ck-top-bar-zoom');
  1121. C['topBar']['zoomEle']['zoom50']=createlDiv('ck-top-bar-zoom-container');
  1122. C['topBar']['zoomEle'].append(C['topBar']['zoomEle']['zoom50']);
  1123. C['topBar']['zoomEle']['zoom50']['left']=createlDiv('ck-top-bar-zoom-left');
  1124. C['topBar']['zoomEle']['zoom50'].append(C['topBar']['zoomEle']['zoom50']['left']);
  1125. C['topBar']['zoomEle']['zoom50']['left']['button']=createlDiv('ck-top-bar-zoom-button-50');
  1126. C['topBar']['zoomEle']['zoom50']['left'].append(C['topBar']['zoomEle']['zoom50']['left']['button']);
  1127. C['topBar']['zoomEle']['zoom50']['right']=createlDiv('ck-top-bar-zoom-right',language['p50']);
  1128. C['topBar']['zoomEle']['zoom50'].append(C['topBar']['zoomEle']['zoom50']['right']);
  1129. C['topBar']['zoomEle']['zoom50'].click(function(){player.zoom(50);});
  1130. C['topBar']['zoomEle']['zoom75']=createlDiv('ck-top-bar-zoom-container');
  1131. C['topBar']['zoomEle'].append(C['topBar']['zoomEle']['zoom75']);
  1132. C['topBar']['zoomEle']['zoom75']['left']=createlDiv('ck-top-bar-zoom-left');
  1133. C['topBar']['zoomEle']['zoom75'].append(C['topBar']['zoomEle']['zoom75']['left']);
  1134. C['topBar']['zoomEle']['zoom75']['left']['button']=createlDiv('ck-top-bar-zoom-button-75');
  1135. C['topBar']['zoomEle']['zoom75']['left'].append(C['topBar']['zoomEle']['zoom75']['left']['button']);
  1136. C['topBar']['zoomEle']['zoom75']['right']=createlDiv('ck-top-bar-zoom-right',language['p75']);
  1137. C['topBar']['zoomEle']['zoom75'].append(C['topBar']['zoomEle']['zoom75']['right']);
  1138. C['topBar']['zoomEle']['zoom75'].click(function(){player.zoom(75);});
  1139. C['topBar']['zoomEle']['zoom100']=createlDiv('ck-top-bar-zoom-container');
  1140. C['topBar']['zoomEle'].append(C['topBar']['zoomEle']['zoom100']);
  1141. C['topBar']['zoomEle']['zoom100']['left']=createlDiv('ck-top-bar-zoom-left');
  1142. C['topBar']['zoomEle']['zoom100'].append(C['topBar']['zoomEle']['zoom100']['left']);
  1143. C['topBar']['zoomEle']['zoom100']['left']['button']=createlDiv('ck-top-bar-zoom-button-100');
  1144. C['topBar']['zoomEle']['zoom100']['left'].append(C['topBar']['zoomEle']['zoom100']['left']['button']);
  1145. C['topBar']['zoomEle']['zoom100']['right']=createlDiv('ck-top-bar-zoom-right',language['p100']);
  1146. C['topBar']['zoomEle']['zoom100'].append(C['topBar']['zoomEle']['zoom100']['right']);
  1147. C['topBar']['zoomEle']['zoom100'].click(function(){player.zoom(100);});
  1148. C['topBar'].append(C['topBar']['zoomEle']);
  1149. C['topBar']['titleEle']=createlDiv('ck-top-bar-title',vars['title']);
  1150. C['topBar'].append(C['topBar']['titleEle']);
  1151. C['topBar']['timeEle']=createlDiv('ck-top-bar-time');
  1152. C['topBar'].append(C['topBar']['timeEle']);
  1153. //中间播放按钮
  1154. C['centerPlay']=createlDiv('ck-center-play');
  1155. C['centerPlay'].click(player.play);
  1156. CM.append(C['centerPlay']);
  1157. //buff
  1158. C['buffer']=createlDiv('ck-buffer');
  1159. CM.append(C['buffer']);
  1160. //消息提示框
  1161. C['message']=createlDiv('ck-message');
  1162. CM.append(C['message']);
  1163. //消息Tip框
  1164. C['tip']=createlDiv('ck-tip');
  1165. CM.append(C['tip']);
  1166. C['tip']['content']=createlDiv('ck-content ck-content-float-auto');
  1167. C['tip'].append(C['tip']['content']);
  1168. C['tip']['triangle']=createlDiv('ck-triangle ck-triangle-auto');
  1169. C['tip'].append(C['tip']['triangle']);
  1170. tip(video,'ckplayer');//初始化显示,为了获取高度
  1171. C['tip'].minHeight=C['tip'].getHeight();
  1172. tip();
  1173. //贴片广告层
  1174. C['ad']=createlDiv('ck-yytf');
  1175. CM.append(C['ad']);
  1176. C['ad']['link']=createlDiv('ck-yytf-front-link');
  1177. C['ad'].append(C['ad']['link']);
  1178. C['ad']['link'].click(frontVideoClickHandler);
  1179. C['ad']['picture']=createlDiv('ck-yytf-front-picture');
  1180. C['ad'].append(C['ad']['picture']);
  1181. C['ad']['top']=createlDiv('ck-yytf-top');
  1182. C['ad'].append(C['ad']['top']);
  1183. C['ad']['top']['countDown']=createlDiv('ck-yytf-countdown');
  1184. C['ad']['top'].append(C['ad']['top']['countDown']);
  1185. C['ad']['top']['closeTime']=createlDiv('ck-yytf-closetime');
  1186. C['ad']['top'].append(C['ad']['top']['closeTime']);
  1187. C['ad']['top']['closeAd']=createlDiv('ck-yytf-closead',language['closeAd']);
  1188. C['ad']['top'].append(C['ad']['top']['closeAd']);
  1189. C['ad']['top']['closeAd'].click(closeFrontAd);
  1190. C['ad']['bottom']=createlDiv('ck-yytf-bottom');
  1191. C['ad'].append(C['ad']['bottom']);
  1192. C['ad']['bottom']['fullAndExit']=createlDiv('ck-yytf-fullandexit');
  1193. C['ad']['bottom'].append(C['ad']['bottom']['fullAndExit']);
  1194. C['ad']['bottom']['fullAndExit']['full']=createlButton('ck-yytf-btn ck-yytf-fullandexit-full');
  1195. C['ad']['bottom']['fullAndExit']['full'].click(player.full);
  1196. C['ad']['bottom']['fullAndExit'].append(C['ad']['bottom']['fullAndExit']['full']);
  1197. C['ad']['bottom']['fullAndExit']['exitFull']=createlButton('ck-yytf-btn ck-yytf-fullandexit-exitfull');
  1198. C['ad']['bottom']['fullAndExit'].append(C['ad']['bottom']['fullAndExit']['exitFull']);
  1199. C['ad']['bottom']['fullAndExit']['exitFull'].click(player.exitFull);
  1200. C['ad']['bottom']['mutedAndExit']=createlDiv('ck-yytf-mutedandexit');
  1201. C['ad']['bottom'].append(C['ad']['bottom']['mutedAndExit']);
  1202. C['ad']['bottom']['mutedAndExit']['muted']=createlButton('ck-yytf-btn ck-yytf-mutedandexit-muted');
  1203. C['ad']['bottom']['mutedAndExit'].append(C['ad']['bottom']['mutedAndExit']['muted']);
  1204. C['ad']['bottom']['mutedAndExit']['muted'].click(player.muted);
  1205. C['ad']['bottom']['mutedAndExit']['exitMuted']=createlButton('ck-yytf-btn ck-yytf-mutedandexit-exitmuted');
  1206. C['ad']['bottom']['mutedAndExit'].append(C['ad']['bottom']['mutedAndExit']['exitMuted']);
  1207. C['ad']['bottom']['mutedAndExit']['exitMuted'].click(player.exitMuted);
  1208. C['ad']['bottom']['details']=createlDiv('ck-yytf-details',language['details']);
  1209. C['ad']['bottom'].append(C['ad']['bottom']['details']);
  1210. C['ad'].hide();
  1211. //暂停广告层
  1212. C['adPause']=createlDiv('ck-pause-yytf');
  1213. CM.append(C['adPause']);
  1214. //关于视频
  1215. C['about']=createlDiv('ck-about');
  1216. CM.append(C['about']);
  1217. C['about']['bar']=createlDiv('ck-about-bar');
  1218. C['about'].append(C['about']['bar']);
  1219. C['about']['bar']['copy']=createlButton('ck-bar-btn ck-btn-about-copy');
  1220. C['about']['bar'].append(C['about']['bar']['copy']);
  1221. C['about']['bar']['copy'].click(aboutCopy);
  1222. C['about']['bar']['copy'].mouseover(function(){tip(this,language['copy'],null,'left');});
  1223. C['about']['bar']['close']=createlButton('ck-bar-btn ck-btn-about-close');
  1224. C['about']['bar']['close'].click(aboutHide);
  1225. C['about']['bar']['close'].mouseover(function(){tip(this,language['close'],null,'left');});
  1226. C['about']['bar'].append(C['about']['bar']['close']);
  1227. C['tempTime']=createlDiv('ck-tempTime');
  1228. CM.append(C['tempTime']);
  1229. C['bar']['playAndPause']['refresh'].hide();
  1230. if(vars['controls']){
  1231. player.bar(false);
  1232. player.rightBar(false);
  1233. C['loading'].hide();
  1234. C['centerPlay'].hide();
  1235. }
  1236. else{
  1237. loadLogo();//加载logo
  1238. loadAbout();//构建关于视频相关内容
  1239. loadMenu();//构建右键
  1240. }
  1241. if(app=='iphone'){
  1242. C['loading'].hide();
  1243. }
  1244. changeTopTime();//修改顶部时间
  1245. CK.mouseout(function(){
  1246. if(!paused){
  1247. hideBar();
  1248. }
  1249. }).mouseover(function(){
  1250. if(!C['bar'].hasClass('ck-bar-out')){
  1251. C['bar'].removeClass('ck-bar-out');
  1252. CM.removeClass('ck-nocursor');
  1253. }
  1254. if(C['rightBar'].css('display')=='block'){
  1255. C['rightBar'].removeClass('ck-right-bar-hide');
  1256. }
  1257. if(C['topBar'].css('display')=='block'){
  1258. C['topBar'].removeClass('ck-top-bar-hide');
  1259. }
  1260. }).mousemove(function(){
  1261. if(C['bar'].hasClass('ck-bar-out')){
  1262. C['bar'].removeClass('ck-bar-out');
  1263. eventTarget('mouseActive',true);
  1264. CM.removeClass('ck-nocursor');
  1265. hideBar();
  1266. }
  1267. if(C['rightBar'].css('display')=='block'){
  1268. C['rightBar'].removeClass('ck-right-bar-hide');
  1269. }
  1270. if(C['topBar'].css('display')=='block'){
  1271. C['topBar'].removeClass('ck-top-bar-hide');
  1272. }
  1273. });
  1274. },
  1275. /*
  1276. * addAllListener
  1277. * 功能:注册播放器的全部监听
  1278. */
  1279. addAllListener=function(){
  1280. video.addListener('stalled',videoHandler.stalled);//在浏览器不论何种原因未能取回媒介数据时运行的脚本
  1281. video.addListener('suspend',videoHandler.suspend);//在媒介数据完全加载之前不论何种原因终止取回媒介数据时运行的脚本
  1282. video.addListener('loadeddata',videoHandler.loadedData);//监听视频数据已加载
  1283. video.addListener('loadstart',videoHandler.loadStart);//在文件开始加载且未实际加载任何数据前运行的脚本
  1284. video.addListener('loadedmetadata',videoHandler.loadedMetaData);//监听视频元数据
  1285. video.addListener('canplay',videoHandler.canPlay);//当文件就绪可以开始播放时运行的脚本(缓冲已足够开始时)
  1286. video.addListener('timeupdate',videoHandler.timeUpDate);//监听视频播放时间
  1287. video.addListener('seeking',videoHandler.seeking);//监听视频跳转中
  1288. video.addListener('seeked',videoHandler.seeked);//监听视频跳转
  1289. video.addListener('waiting',videoHandler.waiting);//监听视频缓冲
  1290. video.addListener('play',videoHandler.play);//监听视频播放事件
  1291. video.addListener('pause',videoHandler.pause);//监听视频暂停事件
  1292. video.addListener('volumechange',videoHandler.volumeChange);//监听音量改变
  1293. video.addListener('ended',videoHandler.ended);//监听播放结束
  1294. video.addListener('error',videoHandler.error);//监听发生故障并且文件突然不可用时运行的脚本(比如连接意外断开时)
  1295. if(!isUndefined(video.emptied)){
  1296. video.addListener('emptied',videoHandler.emptied);//监听播放结束
  1297. }
  1298. //CV.singleClick(player.playOrPause);//监听视频单击
  1299. CV.singleClick(function(){
  1300. if(!isDrag){
  1301. player.playOrPause();
  1302. }
  1303. else{
  1304. isDrag=false;
  1305. }
  1306. });
  1307. CM.doubleClick(player.fullOrExit);//监听视频双击
  1308. $(document).addListener('keydown',videoHandler.keydown);//监听键盘按键
  1309. addListener(window, 'resize', videoHandler.resize);//监听窗口尺寸变化
  1310. if(!isUndefined(vars['smallWindows'])){
  1311. if(valType(vars['smallWindows'])=='boolean' && vars['smallWindows']){
  1312. addListener(window, 'scroll', windowScroll);//监听窗口滚动
  1313. }
  1314. }
  1315. CT.mouseWheel(videoHandler.mouseWheel);
  1316. },
  1317. /*
  1318. * eventTarget
  1319. * 功能:注册事件,将事件注册给CT对象供外部监听
  1320. */
  1321. eventTarget=function(name,obj){
  1322. try{
  1323. if(EventTarget!=null){
  1324. if(isUndefined(obj)){
  1325. obj=null;
  1326. }
  1327. newEvent.dispatchEvent(name,obj);
  1328. }
  1329. else{
  1330. EventTarget = function() {
  1331. this.listeners = {};
  1332. };
  1333. EventTarget.prototype.listeners = null;
  1334. EventTarget.prototype.addEventListener = function(type, callback) {
  1335. if(!(type in this.listeners)) {
  1336. this.listeners[type] = [];
  1337. }
  1338. this.listeners[type].push(callback);
  1339. eventTargetList=this.listeners;
  1340. };
  1341. EventTarget.prototype.removeEventListener = function(type, callback) {
  1342. if(!(type in this.listeners)) {
  1343. return;
  1344. }
  1345. var stack = this.listeners[type];
  1346. for(var i = 0, l = stack.length; i < l; i++) {
  1347. if(stack[i] === callback) {
  1348. stack.splice(i, 1);
  1349. return this.removeEventListener(type, callback);
  1350. }
  1351. }
  1352. eventTargetList=stack;
  1353. };
  1354. EventTarget.prototype.dispatchEvent = function(type,obj) {
  1355. if(!(type in this.listeners)) {
  1356. return;
  1357. }
  1358. var stack = this.listeners[type];
  1359. for(var i = 0, l = stack.length; i < l; i++) {
  1360. stack[i].call(this, obj);
  1361. }
  1362. };
  1363. newEvent = new EventTarget();
  1364. }
  1365. }
  1366. catch(event){console.error(event)}
  1367. },
  1368. /*
  1369. * changeCookie
  1370. * 功能:使用cookie记录时间
  1371. */
  1372. changeCookie=function(time){
  1373. var arr=[];
  1374. var cStr=cookie(ckplayerCookie);
  1375. var i=0,y=0;
  1376. var cTime=Math.floor(Date.now()*0.001);
  1377. time=Math.floor(time*100);
  1378. time=time*0.01;
  1379. if(!cookieTime){
  1380. cookieTime=365*24;
  1381. }
  1382. if(!cStr){
  1383. arr.push([cookieName,time,cTime+cookieTime*3600]);
  1384. }
  1385. else{
  1386. arr=stringToArray(cStr);
  1387. var have=false;
  1388. var tempArr=[[cookieName,time,cTime+cookieTime*3600]];
  1389. for(i=0;i<arr.length;i++){
  1390. if(arr[i][2]>cTime && arr[i][0]!=cookieName && y<19){
  1391. tempArr.push(arr[i]);
  1392. y++;
  1393. }
  1394. }
  1395. arr=tempArr;
  1396. }
  1397. if(arr.length>0){
  1398. cookie(ckplayerCookie,'delete',vars['domain'],vars['cookiePath']);
  1399. cookie(ckplayerCookie,arrayToString(arr),vars['domain'],vars['cookiePath']);
  1400. }
  1401. cookieArray=arr;
  1402. },
  1403. /*
  1404. * loadTrack
  1405. * 功能:加载track
  1406. */
  1407. loadTrack=function(){
  1408. if(isUndefined(video.textTracks)){
  1409. return;
  1410. }
  1411. var i=0;
  1412. if(!isUndefined(vars['track']) && valType(vars['track'])=='array' && !video.find('track')){
  1413. var track='';
  1414. var arr=vars['track'];
  1415. C['bar']['track'].show();
  1416. for(i=0;i<arr.length;i++){
  1417. var def='';
  1418. if(!def && !isUndefined(arr[i]['default']) && arr[i]['default']){
  1419. def=' default';
  1420. }
  1421. track+='<track src="'+arr[i]['src']+'" srclang="'+arr[i]['srclang']+'" kind="'+arr[i]['kind']+'" label="'+arr[i]['label']+'"'+def+'>';
  1422. }
  1423. if(video){
  1424. var html=video.htm()+track;
  1425. video.htm(html);
  1426. }
  1427. if(video.find('track') && !loadedTrack){
  1428. loadedTrack=true;
  1429. checkTrack();
  1430. }
  1431. }
  1432. },
  1433. /*
  1434. * loadedMetaData
  1435. * 功能:获取元数据后执行的函数
  1436. */
  1437. loadedMetaData=function(){
  1438. eventTarget('loadedMetaData',{
  1439. width:CK.getWidth(),
  1440. height:CK.getHeight(),
  1441. videoWidth:CT.videoWidth,
  1442. videoHeight:CT.videoHeight,
  1443. duration:duration,
  1444. volume:CT.volume
  1445. });
  1446. eventTarget('duration',duration);
  1447. if('error' in C){
  1448. C['error'].hide();
  1449. }
  1450. replaceInformation('videoWidth',CT.videoWidth);
  1451. replaceInformation('videoHeight',CT.videoHeight);
  1452. replaceInformation('volume',parseInt(CT.volume*100));
  1453. replaceInformation('duration',parseInt(duration));
  1454. documentHidden(function(state){
  1455. if(vars['documentFocusPause']){
  1456. if(state=='show'){
  1457. if(!focusPause && paused){
  1458. player.play();
  1459. }
  1460. }
  1461. else{
  1462. focusPause=paused;
  1463. player.pause();
  1464. }
  1465. }
  1466. });
  1467. };
  1468. /*
  1469. * videoHandler
  1470. * 功能:视频播放对象video注册内部监听调用函数
  1471. */
  1472. var videoHandler={
  1473. loadStart:function(){
  1474. if(!vars['controls'] && app!='iphone'){
  1475. C['loading'].show();
  1476. }
  1477. C['centerPlay'].hide();
  1478. eventTarget('loadstart');
  1479. },
  1480. canPlay:function(){
  1481. C['loading'].hide();
  1482. eventTarget('canplay');
  1483. },
  1484. loadedData:function(){
  1485. eventTarget('loadeddata');
  1486. },
  1487. loadedMetaData:function(){
  1488. duration=this.duration;
  1489. if(!isUndefined(this.duration) && vars['duration']){
  1490. duration=vars['duration'];
  1491. }
  1492. if(!vars['live']){
  1493. C['time'].htm(formatSeconds(this.currentTime)+'/'+formatSeconds(duration));
  1494. C['tempTime'].htm(formatSeconds(this.currentTime)+'/'+formatSeconds(duration));
  1495. }
  1496. C['loading'].hide();
  1497. if(vars['poster']){
  1498. video.attr('poster',vars['poster']);
  1499. }
  1500. if(!vars['autoplay'] && !vars['controls']){
  1501. C['centerPlay'].show();
  1502. C['buffer'].hide();
  1503. }
  1504. CT.duration=duration;
  1505. CT.videoWidth=this.videoWidth;
  1506. CT.videoHeight=this.videoHeight;
  1507. CT.volume=this.volume;
  1508. if(CT.videoWidth || CT.videoHeight || duration){
  1509. loadedMetaData();
  1510. }
  1511. var len = 0;
  1512. if(!isUndefined(this.buffered)){
  1513. len=this.buffered.length;
  1514. }
  1515. if(len>0){
  1516. changeLoad();
  1517. }
  1518. if(!vars['live']){
  1519. changePreview(vars['preview']);//修改预览图片
  1520. }
  1521. else{
  1522. changePreview();//修改预览图片
  1523. }
  1524. if(!isUndefined(vars['prompt']) && valType(vars['prompt'])=='array' && !vars['live']){
  1525. changePrompt();
  1526. }
  1527. else{
  1528. deletePrompt();
  1529. }
  1530. if(isChangeDef){
  1531. checkDefinition();
  1532. isChangeDef=false;
  1533. }
  1534. pSliderMouseDown=false;
  1535. loadedmetadataNum++;
  1536. if(!isUndefined(ad) && !isUndefined(ad['frontPlay']) && ad['frontPlay'] && loadedmetadataNum>1){//如果是贴片广告播放中,则进行播放和计算
  1537. player.play();
  1538. calculationAdFrontTime(duration);//计算贴片广告的时间
  1539. }
  1540. if(!isUndefined(ad) && !isUndefined(ad['frontPlay']) && !ad['frontPlay']){//如果广告播放结束则播放正片
  1541. player.volume(vars['volume']);
  1542. player.play();
  1543. }
  1544. if(!vars['autoplay'] && loadMeta){
  1545. loadMeta=false;
  1546. player.pause();
  1547. setTimeout(player.pause,300);
  1548. }
  1549. },
  1550. timeUpDate:function(){//监听播放时间
  1551. if(!waited){
  1552. waited=true;
  1553. C['buffer'].hide();
  1554. eventTarget('buffer','end');
  1555. }
  1556. var len = this.buffered.length;
  1557. if(len>0){
  1558. changeLoad();
  1559. }
  1560. if(!duration && this.duration){
  1561. duration=this.duration;
  1562. CT.duration=duration;
  1563. CT.videoWidth=this.videoWidth;
  1564. CT.videoHeight=this.videoHeight;
  1565. if(CT.videoWidth || CT.videoHeight || duration){
  1566. loadedMetaData();
  1567. }
  1568. }
  1569. oldTime=playTime;
  1570. playTime=this.currentTime;
  1571. if(maxSeeTime<oldTime){
  1572. maxSeeTime=oldTime;
  1573. }
  1574. changeProgress(playTime);
  1575. eventTarget('time',playTime);
  1576. if(!vars['live']){
  1577. C['time'].htm(formatSeconds(playTime)+'/'+formatSeconds(duration));
  1578. C['tempTime'].htm(formatSeconds(playTime)+'/'+formatSeconds(duration));
  1579. }
  1580. if(!isUndefined(ad) && !isUndefined(ad['frontPlay']) && ad['frontPlay'] && loadedmetadataNum>1){//如果是贴片广告播放中,则进行播放
  1581. calculationAdFrontTime(duration-playTime);//计算贴片广告的时间
  1582. }
  1583. if(!isUndefined(C['error']) && C['error'].css('display')=='block'){
  1584. C['error'].hide();
  1585. }
  1586. if(cookieName){
  1587. changeCookie(playTime);
  1588. }
  1589. replaceInformation('audioDecodedByteCount',this.webkitAudioDecodedByteCount || this.audioDecodedByteCount || 0);
  1590. replaceInformation('videoDecodedByteCount',this.webkitVideoDecodedByteCount || this.videoDecodedByteCount || 0);
  1591. },
  1592. ended:function(){//监听播放结束
  1593. if(!isUndefined(ad) && !isUndefined(ad['frontPlay']) && ad['frontPlay']){//如果是贴片广告播放中,则用广告结束函数对此进行判断
  1594. adFrontEnded();
  1595. }
  1596. else{
  1597. C['bar']['playAndPause']['pause'].hide();
  1598. C['bar']['playAndPause']['play'].hide();
  1599. C['bar']['playAndPause']['refresh'].show();
  1600. eventTarget('ended');
  1601. showEnded();
  1602. message();
  1603. }
  1604. },
  1605. error:function(event){
  1606. if(!isUndefined(event.type)){
  1607. var errorInfo=this.error;
  1608. var errorBak=function(){
  1609. var code=12;
  1610. var msg=language['error']['loadingFailed'];
  1611. if(!isUndefined(errorInfo)){
  1612. if(!isUndefined(errorInfo.code)){
  1613. code=errorInfo.code;
  1614. }
  1615. if(!isUndefined(errorInfo.message)){
  1616. msg=errorInfo.message;
  1617. }
  1618. CT.error={code:code,message:msg};
  1619. showError();
  1620. }
  1621. else{
  1622. CT.error={code:code,message:msg};
  1623. if(event.target.attr('src')){
  1624. showError();
  1625. }
  1626. }
  1627. eventTarget('error',CT.error);//注册监听error
  1628. };
  1629. if(event.type=='error'){
  1630. try{
  1631. if(video.currentSrc){
  1632. ajax({url:video.currentSrc,error:function(info){
  1633. if(info && valType(info)=='object' && 'code' in info && info['code']){
  1634. CT.error=info;
  1635. eventTarget('error',CT.error);//注册监听error
  1636. showError();
  1637. }
  1638. else{
  1639. errorBak();
  1640. }
  1641. },success:function(data){
  1642. if(!data){
  1643. errorBak();
  1644. }
  1645. }});
  1646. }
  1647. else{
  1648. errorBak();
  1649. }
  1650. }
  1651. catch(event){
  1652. errorBak();
  1653. }
  1654. }
  1655. }
  1656. },
  1657. stalled:function(){
  1658. eventTarget('stalled');//注册监听error
  1659. CT.error={code:13,message:'load:stalled'};
  1660. eventTarget('error',CT.error);//注册监听error
  1661. },
  1662. suspend:function(){
  1663. eventTarget('suspend');//注册监听error
  1664. },
  1665. emptied:function(){
  1666. eventTarget('emptied');//注册监听error
  1667. CT.error={code:7,message:language['error']['emptied']};
  1668. eventTarget('error',CT.error);//注册监听error
  1669. },
  1670. seeked:function(){
  1671. if(paused){
  1672. player.play();
  1673. }
  1674. pSliderMouseDown=false;
  1675. eventTarget('seek',{time:this.currentTime,state:'seeked'});
  1676. eventTarget('seeked');
  1677. },
  1678. seeking:function(){
  1679. if(paused){
  1680. player.play();
  1681. }
  1682. var seekingTime=this.currentTime;
  1683. if(firstSeekTime==-1){
  1684. firstSeekTime=seekingTime;//记录第一次拖动的时间
  1685. }
  1686. switch(vars['timeScheduleAdjust']){
  1687. case 0://禁止拖动
  1688. if(oldTime!=seekingTime){
  1689. waitingMessage=false;
  1690. player.seek(oldTime);
  1691. message(language['timeScheduleAdjust']['prohibit']);
  1692. return;
  1693. }
  1694. break;
  1695. case 2://只能前进(向右拖动
  1696. if(seekingTime<oldTime){
  1697. waitingMessage=false;
  1698. player.seek(oldTime);
  1699. message(language['timeScheduleAdjust']['prohibitBackOff']);
  1700. return;
  1701. }
  1702. break;
  1703. case 3://是只能后退
  1704. if(seekingTime>oldTime){
  1705. waitingMessage=false;
  1706. player.seek(oldTime);
  1707. message(language['timeScheduleAdjust']['prohibitForward']);
  1708. return;
  1709. }
  1710. break;
  1711. case 4://只能前进但能回到第一次拖动时的位置
  1712. if(seekingTime<firstSeekTime){
  1713. waitingMessage=false;
  1714. player.seek(firstSeekTime);
  1715. message(language['timeScheduleAdjust']['prohibitLookBack']);
  1716. return;
  1717. }
  1718. break;
  1719. case 5://看过的地方可以随意拖动
  1720. if(seekingTime>maxSeeTime){
  1721. waitingMessage=false;
  1722. player.seek(maxSeeTime);
  1723. message(language['timeScheduleAdjust']['prohibitForwardNotViewed']);
  1724. return;
  1725. }
  1726. break;
  1727. }
  1728. eventTarget('seek',{time:seekingTime,state:'seeking'});
  1729. eventTarget('seeking');
  1730. if(!vars['live']){
  1731. C['time'].htm(formatSeconds(seekingTime)+'/'+formatSeconds(duration));
  1732. C['tempTime'].htm(formatSeconds(seekingTime)+'/'+formatSeconds(duration));
  1733. }
  1734. },
  1735. waiting:function(){
  1736. waited=false;
  1737. eventTarget('buffer','start');//注册监听视频缓冲
  1738. C['centerPlay'].hide();
  1739. if(!vars['controls']){
  1740. C['buffer'].show();
  1741. }
  1742. if(!waitingMessage){
  1743. waitingMessage=true;
  1744. }
  1745. else{
  1746. message(language['waiting']);
  1747. }
  1748. },
  1749. play:function(){
  1750. paused=false;
  1751. C['bar']['playAndPause']['play'].hide();
  1752. C['bar']['playAndPause']['pause'].show();
  1753. C['bar']['playAndPause']['refresh'].hide();
  1754. C['centerPlay'].hide();
  1755. if(playType=='button'){
  1756. C['bar']['pbox'].removeClass('ck-bar-progress-out');
  1757. }
  1758. else{
  1759. C['bar']['pbox'].addClass('ck-bar-progress-out');
  1760. }
  1761. if(recoveryVolume){
  1762. recoveryVolume=false;
  1763. player.exitMuted();
  1764. }
  1765. hideBar();
  1766. closePauseAd();//关闭暂停广告
  1767. playType='';
  1768. if(!isUndefined(C['ended'])){
  1769. player.closeLayer(C['ended']);
  1770. }
  1771. if('error' in C){
  1772. C['error'].hide();
  1773. }
  1774. eventTarget('play');
  1775. if(!isUndefined(ad)){//如果存在广告
  1776. if(!isUndefined(ad['front'])){//如果存在贴片广告
  1777. if(isUndefined(ad['frontPlay'])){//如果贴片广告还未播放
  1778. ad['frontPlayI']=0;
  1779. ad['frontPlay']=true;//开始播放贴片广告
  1780. player.pause();//暂停视频
  1781. adFrontPlay();
  1782. return;
  1783. }
  1784. }
  1785. }
  1786. if(seekTime && (isUndefined(vars['live']) || (!isUndefined(vars['live']) && valType(vars['live'])=='boolean' && !vars['live'])) && seekTime<parseInt(duration*100)*0.01){//如果默认需要跳转,则进行seek
  1787. player.seek(seekTime);
  1788. seekTime=0;
  1789. }
  1790. },
  1791. pause:function(){
  1792. paused=true;
  1793. if(isUndefined(ad) || isUndefined(ad['frontPlay']) || (!isUndefined(ad['frontPlay']) && !ad['frontPlay'])){//如果是贴片广告播放中,则进行播放和计算
  1794. if(!isUndefined(ad) && !isUndefined(ad['pause'])){
  1795. if(isUndefined(ad['pausePlayI'])){//如果贴片广告还未播放
  1796. ad['pausePlayI']=0;
  1797. }
  1798. adPausePlay();//播放暂停广告
  1799. }
  1800. else{
  1801. if(!vars['controls']){
  1802. C['centerPlay'].show();
  1803. C['buffer'].hide();
  1804. }
  1805. }
  1806. }
  1807. else{
  1808. if(!vars['controls']){
  1809. C['centerPlay'].show();
  1810. C['buffer'].hide();
  1811. }
  1812. }
  1813. C['bar']['playAndPause']['pause'].hide();
  1814. C['bar']['playAndPause']['play'].show();
  1815. C['bar']['playAndPause']['refresh'].hide();
  1816. C['bar']['pbox'].removeClass('ck-bar-progress-out');
  1817. checkProgressSlider();
  1818. eventTarget('pause');
  1819. C['bar'].removeClass('ck-bar-out');
  1820. CM.removeClass('ck-nocursor');
  1821. },
  1822. volumeChange:function(){
  1823. if(this.volume==0 && !mutedState){
  1824. this.muted=true;
  1825. }
  1826. if(this.volume>0 && mutedState){
  1827. this.muted=false;
  1828. }
  1829. if(mutedState!=this.muted){
  1830. mutedState=this.muted;
  1831. changeMuted(this.muted);
  1832. CT.muted=this.muted;
  1833. eventTarget('muted',CT.muted);//注册静音事件
  1834. }
  1835. CT.volume=this.volume;
  1836. eventTarget('volume',this.volume);//注册音量事件
  1837. if(!isUndefined(C['bar']['vbox'])){
  1838. var vol=parseInt(this.volume*100);
  1839. C['bar']['vbox']['volume']['txt'].htm(vol);
  1840. if(!C['bar']['vbox']['mouseDown']){
  1841. changeVolumeSlider(this.muted?0:this.volume);
  1842. }
  1843. if(!this.muted){//如果非静音状态
  1844. message(language['volume']+vol+'%');
  1845. }
  1846. }
  1847. replaceInformation('volume',parseInt(this.volume*100));
  1848. },
  1849. resize:function(){
  1850. var fullState = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement;
  1851. if(fullState) {
  1852. C['bar']['fullAndExit']['exitFull'].show();
  1853. C['bar']['fullAndExit']['full'].hide();
  1854. C['ad']['bottom']['fullAndExit']['exitFull'].show();
  1855. C['ad']['bottom']['fullAndExit']['full'].hide();
  1856. if(!CM.hasClass('ck-main-full')){
  1857. CM.addClass('ck-main-full');
  1858. }
  1859. message(language['full']);
  1860. C['bar']['webFullAndExit'].hide();
  1861. C['bar']['theatreAndExit'].hide();
  1862. if(!isUndefined(C['menu'])){
  1863. CM.append(C['menu']);
  1864. }
  1865. }
  1866. else {
  1867. fullState=false;
  1868. C['bar']['fullAndExit']['full'].show();
  1869. C['bar']['fullAndExit']['exitFull'].hide();
  1870. C['ad']['bottom']['fullAndExit']['full'].show();
  1871. C['ad']['bottom']['fullAndExit']['exitFull'].hide();
  1872. if(CM.hasClass('ck-main-full')){
  1873. CM.removeClass('ck-main-full');
  1874. }
  1875. if(!isUndefined(vars['webFull']) && vars['webFull']){
  1876. C['bar']['webFullAndExit'].show();
  1877. }
  1878. if(!isUndefined(vars['theatre']) && !CT.webFull){
  1879. C['bar']['theatreAndExit'].show();
  1880. }
  1881. if(!isUndefined(C['menu'])){
  1882. $('body').append(C['menu']);
  1883. }
  1884. if(CV.css('width')!=CM.css('width')){
  1885. player.zoom(100);
  1886. }
  1887. }
  1888. if(CT.full!=fullState){
  1889. CT.full=fullState;
  1890. eventTarget('full',fullState);//注册播放事件
  1891. }
  1892. checkVideoRotate();
  1893. changeProgress(player.time());
  1894. },
  1895. keydown:function(event){
  1896. event=window.event || event;
  1897. var keycode = event.keyCode || event.which;
  1898. var v=player.volume();
  1899. var pre=function(){
  1900. if(event.preventDefault){
  1901. event.preventDefault();
  1902. }
  1903. else{
  1904. event.returnValue = false;
  1905. }
  1906. };
  1907. switch(keycode) {
  1908. case 32:
  1909. pre();
  1910. player.playOrPause();
  1911. break;
  1912. case 37:
  1913. player.fastBack();
  1914. break;
  1915. case 39:
  1916. player.fastNext();
  1917. break;
  1918. case 38:
  1919. if(valType(vars['keyVolume'])=='number' && (vars['keyVolume']==1 || (vars['keyVolume']==2 && CT.full))){
  1920. pre();
  1921. player.volume(v+.1<1?v+=.1:1);
  1922. }
  1923. break;
  1924. case 40:
  1925. if(valType(vars['keyVolume'])=='number' && (vars['keyVolume']==1 || (vars['keyVolume']==2 && CT.full))){
  1926. pre();
  1927. player.volume(v-.1>0?v-=.1:0);
  1928. }
  1929. break;
  1930. default:
  1931. break;
  1932. }
  1933. },
  1934. mouseWheel:function(event){
  1935. if(valType(vars['mouseWheelVolume'])=='number' && (vars['mouseWheelVolume']==1 || (vars['mouseWheelVolume']==2 && CT.full))){
  1936. event=window.event || event;
  1937. var v=player.volume();
  1938. if(event.preventDefault){
  1939. event.preventDefault();
  1940. }
  1941. else{
  1942. event.returnValue = false;
  1943. }
  1944. if(event.wheelDelta) {
  1945. if(event.wheelDelta > 0) {
  1946. player.volume(v+.1<1?v+=.1:1);
  1947. }
  1948. if(event.wheelDelta < 0) {
  1949. player.volume(v-.1>0?v-=.1:0);
  1950. }
  1951. } else if(event.detail) {
  1952. if(event.detail > 0) {
  1953. player.volume(v-.1>0?v-=.1:0);
  1954. }
  1955. if(event.detail < 0) {
  1956. player.volume(v+.1<1?v+=.1:1);
  1957. }
  1958. }
  1959. }
  1960. }
  1961. };
  1962. /*
  1963. * adFrontPlay
  1964. * 功能:播放贴片广告
  1965. */
  1966. var adFrontPlay=function(){
  1967. if(ad['frontPlayI']==0){//如果是播放第一个广告,则显示相关组件
  1968. allBarHide(false);
  1969. C['ad'].show();
  1970. ad['front']['video']=false;//初始化,不包含视频广告
  1971. //判断是否需要启用固定时间后关闭广告按钮
  1972. if(!isUndefined(ad['front']['closeTime'])){
  1973. if(ad['front']['closeTime']>0){
  1974. C['ad']['top']['closeTime'].show();
  1975. adFrontCloseTime();
  1976. }
  1977. else{
  1978. C['ad']['top']['closeAd'].show();
  1979. }
  1980. }
  1981. }
  1982. if(!isUndefined(ad['front']['node']) && ad['front']['node']!=null){
  1983. CM.append(ad['front']['node']);
  1984. player.closeLayer(ad['front']['node']);
  1985. ad['front']['node']=null;
  1986. }
  1987. C['ad']['picture'].htm('');
  1988. C['ad']['picture'].hide();
  1989. C['ad']['link'].hide();
  1990. if(!isUndefined(ad['front']['list'][ad['frontPlayI']])){
  1991. var adv=ad['front']['list'][ad['frontPlayI']];
  1992. frontAdPlay=true;//贴片广告播放状态
  1993. eventTarget('frontAd',adv);
  1994. if(adv['type']=='picture'){
  1995. adPicturePlay(adv);
  1996. }
  1997. else if(adv['type']=='node'){
  1998. adNode(adv);
  1999. }
  2000. else{
  2001. C['ad']['link'].attr('data-link',adv['link']);
  2002. adVideoPlay(adv['file']);
  2003. }
  2004. if(!isUndefined(adv['link'])){
  2005. C['ad']['bottom']['details'].show();
  2006. C['ad']['bottom']['details'].htm('<a href="'+adv['link']+'" target="blank">'+language['details']+'</a>');
  2007. }
  2008. else{
  2009. C['ad']['bottom']['details'].hide();
  2010. }
  2011. }
  2012. },
  2013. /*
  2014. * adFrontCloseTime
  2015. * 功能:播放贴片广告时按指定时间后显示关闭广告按钮
  2016. */
  2017. adFrontCloseTime=function(){
  2018. if(!isUndefined(ad['front']['closeSetTime'])){
  2019. clearTimeout(ad['front']['closeSetTime']);
  2020. ad['front']['closeSetTime']=null;
  2021. }
  2022. C['ad']['top']['closeTime'].htmReplace('{seconds}',ad['front']['closeTime'],language['closeTime']);
  2023. ad['front']['closeTime']--;
  2024. if(ad['front']['closeTime']>0){
  2025. ad['front']['closeSetTime']=setTimeout(adFrontCloseTime,1000);
  2026. }
  2027. else{
  2028. C['ad']['top']['closeAd'].show();
  2029. C['ad']['top']['closeTime'].hide();
  2030. }
  2031. },
  2032. /*
  2033. * calculationAdFrontTime
  2034. * 功能:计算贴片广告倒计时时间以及广告是视频时用于倒计时
  2035. */
  2036. calculationAdFrontTime=function(t){
  2037. if(!isUndefined(t)){
  2038. ad['front']['list'][ad['frontPlayI']]['time']=t;
  2039. }
  2040. ad['front']['countDown']=0;
  2041. for(var i=ad['frontPlayI'];i<ad['front']['list'].length;i++){
  2042. ad['front']['countDown']+=parseInt(ad['front']['list'][i]['time']);
  2043. }
  2044. C['ad']['top']['countDown'].htm(ad['front']['countDown']+language['second']);
  2045. },
  2046. /*
  2047. * clearAdFrontSetTime
  2048. * 功能:关闭贴片广告倒计时的计时器
  2049. */
  2050. clearAdFrontSetTime=function(){
  2051. if(adFrontSetTime){
  2052. clearTimeout(adFrontSetTime);
  2053. adFrontSetTime=null;
  2054. }
  2055. },
  2056. /*
  2057. * adFrontCountDown
  2058. * 功能:贴片广告倒计时
  2059. */
  2060. adFrontCountDown=function(){
  2061. clearAdFrontSetTime();
  2062. var adv=ad['front']['list'][ad['frontPlayI']];
  2063. if(adv['time']>0){
  2064. adv['time']--;
  2065. ad['front']['countDown']--;
  2066. C['ad']['top']['countDown'].htm(ad['front']['countDown']+language['second']);
  2067. adFrontSetTime=setTimeout(adFrontCountDown,1000);
  2068. }
  2069. else{
  2070. adFrontEnded();
  2071. }
  2072. },
  2073. /*
  2074. * adFrontEnded
  2075. * 功能:贴片广告单个播放完成后进行判断是否需要播放下一个广告还是播放正片
  2076. */
  2077. adFrontEnded=function(){
  2078. if(ad['frontPlayI']<ad['front']['list'].length-1){
  2079. ad['frontPlayI']++;
  2080. adFrontPlay();
  2081. }
  2082. else{//贴片广告播放完成
  2083. if(!isUndefined(ad['front']['node']) && ad['front']['node']!=null){
  2084. CM.append(ad['front']['node']);
  2085. player.closeLayer(ad['front']['node']);
  2086. ad['front']['node']=null;
  2087. }
  2088. C['ad']['picture'].htm('');
  2089. C['ad']['picture'].hide();
  2090. ad['frontPlay']=false;
  2091. C['ad'].hide();
  2092. allBarShow();
  2093. seekTime=vars['seek'];
  2094. if(ad['front']['video']){//如果包含视频广告
  2095. changeVideo(vars['video']);
  2096. }
  2097. else{
  2098. player.play();
  2099. }
  2100. eventTarget('frontAdEnded',true);
  2101. frontAdPlay=false;//贴片广告播放状态
  2102. }
  2103. },
  2104. /*
  2105. * adVideoPlay
  2106. * 功能:贴片广告播放视频
  2107. */
  2108. adVideoPlay=function(vstr){
  2109. if(isUndefined(vstr)) return;
  2110. C['ad']['picture'].hide();
  2111. seekTime=0;
  2112. if(video.attr('src') || video.htm()){
  2113. player.pause();
  2114. }
  2115. if(video.attr('src')){
  2116. video.attr('src','');
  2117. video.removeAttr('src');
  2118. }
  2119. video.htm('');
  2120. if(vars['plug'] && !canPlay(vstr)){
  2121. switch(vars['plug']){
  2122. case 'hls.js':
  2123. hlsPlayer(vstr);
  2124. break;
  2125. case 'flv.js':
  2126. flvPlayer(vstr);
  2127. break;
  2128. case 'mpegts.js':
  2129. mpegtsPlayer(vstr);
  2130. break;
  2131. default:
  2132. CT.error={code:10,message:language['error']['emptied']};
  2133. eventTarget('error',CT.error);//注册监听error
  2134. showError();
  2135. break;
  2136. }
  2137. }
  2138. else{
  2139. video.attr('src',vstr);
  2140. }
  2141. ad['front']['video']=true;//设置包含视频广告
  2142. C['ad']['link'].show();
  2143. C['ad']['bottom']['mutedAndExit'].show();
  2144. },
  2145. /*
  2146. * adPicturePlay
  2147. * 功能:贴片广告播放图片
  2148. */
  2149. adPicturePlay=function(adv){
  2150. if(isUndefined(adv['file'])) return;
  2151. var img = null;
  2152. var imgloadNum=0;
  2153. var imgLoadHandler=function(){
  2154. C['ad']['picture'].show();
  2155. C['ad']['picture'].htm('');
  2156. img = createlImg(adv['file']);
  2157. C['ad']['picture'].append(img);
  2158. img.addListener('load',function(){
  2159. var w=this.getWidth(),h=this.getHeight();
  2160. if(w>0 || h>0){
  2161. if(adv['link']){
  2162. var a=createlA('',adv['link']);
  2163. a.append(this);
  2164. C['ad']['picture'].append(a);
  2165. }
  2166. else{
  2167. C['ad']['picture'].append(this)
  2168. }
  2169. img.unbind();
  2170. img.click(function(){
  2171. eventTarget('frontAdClick',adv);
  2172. });
  2173. }
  2174. else{
  2175. if(imgloadNum<10){
  2176. imgloadNum++;
  2177. imgLoadHandler();
  2178. }
  2179. }
  2180. });
  2181. };
  2182. imgLoadHandler();
  2183. calculationAdFrontTime();//计算时间
  2184. adFrontCountDown();//开启倒计时
  2185. C['ad']['bottom']['mutedAndExit'].hide();
  2186. },
  2187. /*
  2188. * adNode
  2189. * 功能:贴片广告播放外部节点
  2190. */
  2191. adNode=function(adv){
  2192. if(isUndefined(adv['content'])) return;
  2193. ad['front']['node']=player.layer(adv);
  2194. ad['front']['node'].css({'z-index':1});
  2195. C['ad'].append(ad['front']['node']);
  2196. ad['front']['node'].unbind();
  2197. ad['front']['node'].click(function(){
  2198. eventTarget('frontAdClick',adv);
  2199. });
  2200. calculationAdFrontTime();//计算时间
  2201. adFrontCountDown();//开启倒计时
  2202. C['ad']['bottom']['mutedAndExit'].hide();
  2203. },
  2204. /*
  2205. * frontVideoClickHandler
  2206. * 功能:视频广告上方层单击事件
  2207. */
  2208. frontVideoClickHandler=function(){
  2209. var url=C['ad']['link'].attr('data-link');
  2210. window.open(url,'_blank');
  2211. },
  2212. /*
  2213. * closeFrontAd
  2214. * 功能:关闭贴片广告
  2215. */
  2216. closeFrontAd=function(){
  2217. if(!isUndefined(ad) && !isUndefined(ad['front']) && !isUndefined(ad['front']['closeButtonClick'])){
  2218. if(valType(ad['front']['closeButtonClick'])=='function'){
  2219. try{
  2220. ad['front']['closeButtonClick']();
  2221. }
  2222. catch(event){console.error(event);}
  2223. }
  2224. else if(valType(ad['front']['closeButtonClick'])=='string'){
  2225. try{
  2226. eval(ad['front']['closeButtonClick']+ '()');
  2227. }
  2228. catch(event){console.error(event);}
  2229. }
  2230. }
  2231. else{
  2232. player.closeFrontAd();
  2233. }
  2234. },
  2235. /*
  2236. * adPausePlay
  2237. * 功能:播放暂停广告
  2238. */
  2239. adPausePlay=function(){
  2240. closePauseAd();
  2241. if(!isUndefined(ad) && !isUndefined(ad['pause']) && !isUndefined(ad['pause']['list']) && ad['pause']['list'].length-1>=ad['pausePlayI']){
  2242. var adv=ad['pause']['list'][ad['pausePlayI']];
  2243. if(!isUndefined(ad['pause']['close']) && ad['pause']['close']){
  2244. ad['pauseClose']=createlButton('ck-pause-close');
  2245. ad['pauseClose'].click(function(){
  2246. C['centerPlay'].show();
  2247. C['buffer'].hide();
  2248. closePauseAd();
  2249. });
  2250. }
  2251. if(!isUndefined(adv['file'])){//图片
  2252. var img = null;
  2253. var imgloadNum=0;
  2254. var imgLoadHandler=function(){
  2255. img = createlImg(adv['file']);
  2256. C['adPause'].show();
  2257. C['adPause'].htm('');
  2258. C['adPause'].append(img);
  2259. img.addListener('load',function(){
  2260. var w=this.getWidth(),h=this.getHeight();
  2261. if(w>0 || h>0){
  2262. C['adPause'].htm('');
  2263. if(adv['link']){
  2264. var a=createlA('',adv['link']);
  2265. a.append(this);
  2266. C['adPause'].append(a);
  2267. }
  2268. else{
  2269. C['adPause'].append(this)
  2270. }
  2271. C['adPause'].css({
  2272. 'width':w+'px',
  2273. 'height':h+'px'
  2274. });
  2275. if(ad['pauseClose']){
  2276. C['adPause'].append(ad['pauseClose']);
  2277. }
  2278. img.click(function(){
  2279. eventTarget('pauseAdClick',adv);
  2280. });
  2281. }
  2282. else{
  2283. if(imgloadNum<10){
  2284. imgloadNum++;
  2285. imgLoadHandler();
  2286. }
  2287. }
  2288. });
  2289. };
  2290. imgLoadHandler();
  2291. }
  2292. else if(!isUndefined(adv['content'])){
  2293. ad['pause']['node']=player.layer(adv);
  2294. if(ad['pauseClose']){
  2295. ad['pause']['node'].append(ad['pauseClose']);
  2296. }
  2297. ad['pause']['node'].click(function(){
  2298. eventTarget('pauseAdClick',adv);
  2299. });
  2300. }
  2301. eventTarget('pauseAd',adv);
  2302. if(!isUndefined(adv['time']) && adv['time']>0){
  2303. adPauseSetTime=setTimeout(function(){
  2304. ad['pausePlayI']++;
  2305. if(ad['pausePlayI']>ad['pause']['list'].length-1){
  2306. ad['pausePlayI']=0;
  2307. }
  2308. adPausePlay();
  2309. },adv['time']*1000)
  2310. }
  2311. }
  2312. },
  2313. /*
  2314. * closePauseAd
  2315. * 功能:关闭暂停广告
  2316. */
  2317. closePauseAd=function(){
  2318. if(adPauseSetTime){
  2319. clearTimeout(adPauseSetTime);
  2320. adPauseSetTime=null;
  2321. }
  2322. C['adPause'].hide();
  2323. if(!isUndefined(ad) && !isUndefined(ad['pauseClose']) && ad['pauseClose']!=null){
  2324. ad['pauseClose'].remove();
  2325. ad['pauseClose']=null;
  2326. }
  2327. if(!isUndefined(ad) && !isUndefined(ad['pause']) && !isUndefined(ad['pause']['node']) && ad['pause']['node']){
  2328. ad['pause']['node'].unbind();
  2329. player.closeLayer(ad['pause']['node']);
  2330. eventTarget('pauseAdClose');
  2331. }
  2332. };
  2333. /*
  2334. * player
  2335. * 功能:开放接口,向外部提供播放器的交互功能列表,包含获取,执行,监听这三种功能
  2336. */
  2337. var player={
  2338. /*
  2339. * width
  2340. * 功能:获取或设置播放器宽度
  2341. * 这是一个动态的值,会随着全屏切换或播放器本身尺寸变化而变化
  2342. * @value,支持数字,字符,当存在@value时则设置播放器宽度,@value为空时则获取播放器宽度
  2343. */
  2344. width:function(value){
  2345. if(!isUndefined(value)){
  2346. if(valType(value)=='number'){
  2347. value+='px';
  2348. }
  2349. CT.css({'width':value});
  2350. checkVideoRotate();
  2351. }
  2352. return CK.getWidth();
  2353. },
  2354. /*
  2355. * height
  2356. * 功能:获取或设置播放器显示高度
  2357. * 这是一个动态的值,会随着全屏切换或播放器本身尺寸变化而变化
  2358. * @value,支持数字,字符,当存在@value时则设置播放器高度,@value为空时则获取播放器高度
  2359. */
  2360. height:function(value){
  2361. if(!isUndefined(value)){
  2362. if(valType(value)=='number'){
  2363. value+='px';
  2364. }
  2365. CT.css({'height':value});
  2366. checkVideoRotate();
  2367. }
  2368. return CK.getHeight();
  2369. },
  2370. /*
  2371. * videoWidth
  2372. * 功能:获取视频本身的宽度,这是一个固定值
  2373. */
  2374. videoWidth:function(){
  2375. if(video){
  2376. return video.videoWidth;
  2377. }
  2378. return null;
  2379. },
  2380. /*
  2381. * videoHeight
  2382. * 功能:获取视频本身的高度,这是一个固定值
  2383. */
  2384. videoHeight:function(){
  2385. if(video){
  2386. return video.videoHeight;
  2387. }
  2388. return null;
  2389. },
  2390. /*
  2391. * height
  2392. * 功能:获取或设置播放器显示高度
  2393. * 这是一个动态的值,会随着全屏切换或播放器本身尺寸变化而变化
  2394. * @value,支持数字,字符,当存在@value时则设置播放器高度,@value为空时则获取播放器高度
  2395. */
  2396. zoom:function(fn){
  2397. if(!isUndefined(fn)){
  2398. if(valType(fn)=='function'){
  2399. newEvent.addEventListener('zoom',fn);
  2400. }
  2401. if(valType(fn)=='number'){
  2402. var arr=[C['topBar']['zoomEle']['zoom50'],C['topBar']['zoomEle']['zoom75'],C['topBar']['zoomEle']['zoom100']];
  2403. for(var i=0;i<arr.length;i++){
  2404. arr[i].removeClass('ck-top-bar-zoom-container-focus')
  2405. }
  2406. switch(fn){
  2407. case 50:
  2408. arr[0].addClass('ck-top-bar-zoom-container-focus');
  2409. break;
  2410. case 75:
  2411. arr[1].addClass('ck-top-bar-zoom-container-focus');
  2412. break;
  2413. case 100:
  2414. arr[2].addClass('ck-top-bar-zoom-container-focus');
  2415. break;
  2416. }
  2417. if(fn==50 || fn==75 || fn==100){
  2418. nowZoom=fn;
  2419. checkVideoRotate();//调整视频尺寸
  2420. eventTarget('zoom',fn);
  2421. }
  2422. }
  2423. }
  2424. return player;
  2425. },
  2426. /*
  2427. * rotate
  2428. * 提供给播放器外部使用
  2429. * 进行旋转
  2430. * @obj为新的播放配置对象
  2431. */
  2432. rotate:function(fn){
  2433. if(!isUndefined(fn)){
  2434. if(valType(fn)=='function'){
  2435. newEvent.addEventListener('rotate',fn);
  2436. }
  2437. if(valType(fn)=='number'){
  2438. var arr=[0,90,180,270];
  2439. var rot=0;
  2440. if(arr.length>fn && fn>0){
  2441. rot=arr[fn];
  2442. }
  2443. else{
  2444. if(arr.indexOf(fn)>-1){
  2445. rot=fn;
  2446. }
  2447. }
  2448. if(rot!=nowRotate){
  2449. eventTarget('rotate',rot);
  2450. nowRotate=rot;
  2451. checkVideoRotate();//调整视频尺寸
  2452. }
  2453. }
  2454. }
  2455. },
  2456. /*
  2457. * vars
  2458. * 提供给播放器外部使用
  2459. * 修改vars,动态切换视频地址
  2460. * @obj为新的播放配置对象
  2461. */
  2462. vars:function(obj,val){
  2463. if(isUndefined(obj)){
  2464. return;
  2465. }
  2466. if(valType(obj)=='string' && !isUndefined(val)){
  2467. var temp={};
  2468. temp[obj]=val;
  2469. obj=temp;
  2470. }
  2471. var isChange=false;
  2472. for(var k in obj){
  2473. if(k in vars && obj[k]!=vars[k]){
  2474. isChange=true;
  2475. break;
  2476. }
  2477. }
  2478. if(isChange){
  2479. vars = standardization(vars, obj);
  2480. }
  2481. if(!isUndefined(obj['video'])){
  2482. isChangeDef=true;
  2483. changeVideo(vars['video']);
  2484. }
  2485. if(!isUndefined(obj['title'])){
  2486. C['topBar']['titleEle'].htm(obj['title']);
  2487. }
  2488. },
  2489. /*
  2490. * 提供给播放器外部使用
  2491. * 功能:监听视频准备加载
  2492. */
  2493. loadstart:function(fn){
  2494. if(!isUndefined(fn) && valType(fn)=='function'){
  2495. newEvent.addEventListener('loadstart',fn);
  2496. }
  2497. },
  2498. /*
  2499. * 提供给播放器外部使用
  2500. * 功能:监听视频加载
  2501. */
  2502. loadeddata:function(fn){
  2503. if(!isUndefined(fn) && valType(fn)=='function'){
  2504. newEvent.addEventListener('loadeddata',fn);
  2505. }
  2506. },
  2507. /*
  2508. * 提供给播放器外部使用
  2509. * 功能:监听视频元数据加载成功
  2510. */
  2511. loadedMetaData:function(fn){
  2512. if(!isUndefined(fn) && valType(fn)=='function'){
  2513. newEvent.addEventListener('loadedMetaData',fn);
  2514. }
  2515. },
  2516. /*
  2517. * 提供给播放器外部使用
  2518. * 功能:监听视频可以播放
  2519. */
  2520. canplay:function(fn){
  2521. if(!isUndefined(fn) && valType(fn)=='function'){
  2522. newEvent.addEventListener('canplay',fn);
  2523. }
  2524. },
  2525. /*
  2526. * 提供给播放器外部使用
  2527. * 功能:执行播放操作/监听播放
  2528. * @fn为函数时则监听视频播放,@fn为空时,则控制视频播放
  2529. */
  2530. play:function(fn){
  2531. if(valType(fn)=='object'){
  2532. if(fn['target']==C['bar']['playAndPause']['play'] || fn['target']==C['bar']['playAndPause']['refresh']){
  2533. playType='button';
  2534. }
  2535. }
  2536. if(!isUndefined(fn) && valType(fn)=='function'){
  2537. newEvent.addEventListener('play',fn);
  2538. }
  2539. else{
  2540. if(loadedmetadataNum>0 && video){
  2541. try{video.play();}catch(event){console.error(event)}
  2542. }
  2543. }
  2544. return player;
  2545. },
  2546. /*
  2547. * puase
  2548. * 功能:执行暂停操作/监听暂停
  2549. * @fn为函数时则监听视频暂停,@fn为空时,则控制视频暂停
  2550. */
  2551. pause:function(fn){
  2552. if(!isUndefined(fn) && valType(fn)=='function'){
  2553. newEvent.addEventListener('pause',fn);
  2554. }
  2555. else{
  2556. if(loadedmetadataNum>0 && video){
  2557. try{video.pause();}catch(event){console.error(event)}
  2558. }
  2559. }
  2560. return player;
  2561. },
  2562. /*
  2563. * playOrPause
  2564. * 功能:在播放和暂停动作之间进行切换
  2565. */
  2566. playOrPause:function(){
  2567. if(paused){
  2568. player.play();
  2569. }
  2570. else{
  2571. player.pause();
  2572. }
  2573. return player;
  2574. },
  2575. /*
  2576. * volume
  2577. * 功能:调节和监听以及获取音量
  2578. * @fn为函数时,则进行音量变化的监听,@fn为数字时,则进行音量调节,@fn为空时,则获取当前音量
  2579. */
  2580. volume:function(fn){
  2581. if(!isUndefined(fn)){
  2582. if(valType(fn)=='function'){
  2583. newEvent.addEventListener('volume', fn);
  2584. }
  2585. else if(valType(fn)=='number' && video){
  2586. if(fn<0)fn=0;
  2587. if(fn>1)fn=1;
  2588. if(video.muted){
  2589. video.volume=fn*.5;
  2590. }
  2591. video.volume=fn;
  2592. }
  2593. }
  2594. else if(video){
  2595. return video.volume;
  2596. }
  2597. return player;
  2598. },
  2599. /*
  2600. * muted
  2601. * 功能:执行静音操作/监听静音
  2602. * @fn为函数时则监听视频静音,@fn为空时,则控制视频静音
  2603. */
  2604. muted:function(fn){
  2605. if(!isUndefined(fn) && valType(fn)=='function'){
  2606. newEvent.addEventListener('muted', fn);
  2607. }
  2608. else if(video){
  2609. video.muted=true;
  2610. }
  2611. return player;
  2612. },
  2613. /*
  2614. * exitMuted
  2615. * 功能:执行取消静音操作
  2616. */
  2617. exitMuted:function(){
  2618. if(video){
  2619. video.muted=false;
  2620. if(video.volume==0){
  2621. player.volume(vars['volume']>0?vars['volume']:.8);
  2622. }
  2623. }
  2624. return player;
  2625. },
  2626. /*
  2627. * time
  2628. * 功能:获取当前播放时间/监听播放时间
  2629. * @fn为函数时监听当前播放时间,为空时获取当前播放时间
  2630. */
  2631. time:function(fn){
  2632. if(!isUndefined(fn) && valType(fn)=='function'){
  2633. newEvent.addEventListener('time',fn);
  2634. }
  2635. else if(video){
  2636. return video.currentTime || 0;
  2637. }
  2638. },
  2639. /*
  2640. * seek
  2641. * 功能:监听跳转/执行跳转操作
  2642. * @fn为函数时则监听视频跳转动作,@fn为数字时执行跳转操作
  2643. */
  2644. seek:function(fn){
  2645. if(!isUndefined(fn)){
  2646. if(valType(fn)=='function'){
  2647. newEvent.addEventListener('seek',fn);
  2648. }
  2649. if(valType(fn)=='number' && video){
  2650. switch(vars['timeScheduleAdjust']){
  2651. case 0://禁止拖动
  2652. message(language['timeScheduleAdjust']['prohibit']);
  2653. return;
  2654. break;
  2655. case 1://可以拖动
  2656. break;
  2657. case 2://只能前进(向右拖动
  2658. if(fn<oldTime){
  2659. message(language['timeScheduleAdjust']['prohibitBackOff']);
  2660. return;
  2661. }
  2662. break;
  2663. case 3://是只能后退
  2664. if(fn>oldTime){
  2665. message(language['timeScheduleAdjust']['prohibitForward']);
  2666. return;
  2667. }
  2668. break;
  2669. case 4://只能前进但能回到第一次拖动时的位置
  2670. if(fn<firstSeekTime){
  2671. waitingMessage=false;
  2672. video.currentTime=firstSeekTime;
  2673. message(language['timeScheduleAdjust']['prohibitLookBack']);
  2674. return;
  2675. }
  2676. break;
  2677. case 5://看过的地方可以随意拖动
  2678. if(fn>maxSeeTime){
  2679. waitingMessage=false;
  2680. video.currentTime=maxSeeTime;
  2681. message(language['timeScheduleAdjust']['prohibitForwardNotViewed']);
  2682. return;
  2683. }
  2684. break;
  2685. }
  2686. pSliderMouseDown=false;
  2687. video.currentTime=fn;
  2688. }
  2689. }
  2690. return player;
  2691. },
  2692. /*
  2693. * buffer
  2694. * 功能:监听视频缓冲
  2695. * @fn为监听执行的函数
  2696. */
  2697. buffer:function(fn){
  2698. if(!isUndefined(fn) && valType(fn)=='function'){
  2699. newEvent.addEventListener('buffer',fn);
  2700. }
  2701. return player;
  2702. },
  2703. /*
  2704. * ended
  2705. * 功能:监听视频播放结束
  2706. * @fn为监听执行的函数
  2707. */
  2708. ended:function(fn){
  2709. if(!isUndefined(fn) && valType(fn)=='function'){
  2710. newEvent.addEventListener('ended',fn);
  2711. }
  2712. return player;
  2713. },
  2714. /*
  2715. * 提供给播放器外部使用
  2716. * 功能:监听点击下一集按钮的动作
  2717. */
  2718. next:function(fn){
  2719. if(!isUndefined(fn) && valType(fn)=='function'){
  2720. newEvent.addEventListener('next',fn);
  2721. }
  2722. return player;
  2723. },
  2724. /*
  2725. * error
  2726. * 功能,监听播放器在加载视频过程和播放视频过程中出现的错误
  2727. * @fn为监听执行的函数
  2728. */
  2729. error:function(fn){
  2730. if(!isUndefined(fn) && valType(fn)=='function'){
  2731. newEvent.addEventListener('error',fn);
  2732. }
  2733. return player;
  2734. },
  2735. /*
  2736. * emptied
  2737. * 功能,监听播放器播放的视频文件发生故障并且文件突然不可用时
  2738. * @fn为监听执行的函数
  2739. */
  2740. emptied:function(fn){
  2741. if(!isUndefined(fn) && valType(fn)=='function'){
  2742. newEvent.addEventListener('emptied',fn);
  2743. }
  2744. return player;
  2745. },
  2746. /*
  2747. * duration
  2748. * 功能:获取视频总时间/监听视频总时间
  2749. * @fn为函数时执行监听视频总时间,为空时获取视频总时间
  2750. */
  2751. duration:function(fn){
  2752. if(!isUndefined(fn) && valType(fn)=='function'){
  2753. newEvent.addEventListener('duration',fn);
  2754. }
  2755. else{
  2756. return duration || 0;
  2757. }
  2758. },
  2759. /*
  2760. * playbackRate
  2761. * 功能:监听或返回视频播放速度
  2762. * @fn为函数时执行监听视频播放速度,为数字时切换播放速度,为空时获取视频播放速度
  2763. */
  2764. playbackRate:function(fn){
  2765. if(!isUndefined(fn)){
  2766. if(valType(fn)=='function'){
  2767. newEvent.addEventListener('playbackRate',fn);
  2768. }
  2769. else if(valType(fn)=='number' && video){
  2770. video.playbackRate=fn;
  2771. CT.playbackRate=fn;
  2772. eventTarget('playbackRate',fn);
  2773. changePlaybackrateVal(fn);
  2774. }
  2775. }
  2776. else{
  2777. return video.playbackRate;
  2778. }
  2779. },
  2780. /*
  2781. * track
  2782. * 功能:监听或返回视频的字幕
  2783. * @fn为函数时执行监听视频字幕,为数字时切换字幕,为空时获取字幕
  2784. */
  2785. track:function(fn){
  2786. if(!isUndefined(fn)){
  2787. if(valType(fn)=='function'){
  2788. newEvent.addEventListener('track',fn);
  2789. }
  2790. else if(valType(fn)=='number' && video){
  2791. var track=null;
  2792. if(!isUndefined(video.textTracks)){
  2793. track=video.textTracks;
  2794. }
  2795. if(track && valType(track)=='texttracklist'){
  2796. var arr=vars['track'];
  2797. for(var i=track.length-1;i>-1;i--){
  2798. video.find('track').eq(i).remove();
  2799. }
  2800. for(var i=0;i<arr.length;i++){
  2801. var def='';
  2802. arr[i]['default']=false;
  2803. if(i==fn){
  2804. def=' default';
  2805. arr[i]['default']=true;
  2806. }
  2807. track+='<track src="'+arr[i]['src']+'" srclang="'+arr[i]['srclang']+'" kind="'+arr[i]['kind']+'" label="'+arr[i]['label']+'"'+def+'>';
  2808. }
  2809. if(video){
  2810. var html=video.htm()+track;
  2811. video.htm(html);
  2812. }
  2813. changeTrackVal(fn);
  2814. }
  2815. }
  2816. }
  2817. else{
  2818. return CT.track;
  2819. }
  2820. },
  2821. /*
  2822. * fastBack
  2823. * 功能:快退
  2824. * @num为数字时快退指定秒数,为空时快退20秒
  2825. */
  2826. fastBack:function(num){
  2827. if(duration==0) return;
  2828. if(isUndefined(num) || valType(num)!='number'){
  2829. num=20;
  2830. }
  2831. var time=player.time();
  2832. if(time-num>0){
  2833. time-=num;
  2834. }
  2835. else{
  2836. time=0;
  2837. }
  2838. player.seek(time);
  2839. return player;
  2840. },
  2841. /*
  2842. * fastNext
  2843. * 功能:快进
  2844. * @num为数字时快进指定秒数,为空时快进20秒
  2845. */
  2846. fastNext:function(num){
  2847. if(duration==0) return;
  2848. if(isUndefined(num) || valType(num)!='number'){
  2849. num=20;
  2850. }
  2851. var time=player.time();
  2852. if(time+num<duration){
  2853. time+=num;
  2854. }
  2855. else{
  2856. time=duration;
  2857. }
  2858. player.seek(time);
  2859. return player;
  2860. },
  2861. /*
  2862. * definition
  2863. * 功能:监听清晰度切换/操作清晰度切换
  2864. * @fn为一个函数时监听清晰度切换,为数字时执行清晰度切换,数字为清晰度的编号,从0开始
  2865. */
  2866. definition:function(fn){
  2867. if(!isUndefined(fn)){
  2868. if(valType(fn)=='function'){
  2869. newEvent.addEventListener('definition',fn);
  2870. }
  2871. if(valType(fn)=='number'){
  2872. changeDefinition(fn);
  2873. }
  2874. }
  2875. return player;
  2876. },
  2877. /*
  2878. * fps
  2879. * 功能:监听Fps
  2880. * @fn为一个函数时监听fps,为空时获取fps
  2881. */
  2882. fps:function(fn){
  2883. if(!isUndefined(fn) && valType(fn)=='function'){
  2884. newEvent.addEventListener('fps',fn);
  2885. }
  2886. return CT.fps;
  2887. },
  2888. /*
  2889. * playback
  2890. * 功能:监听回放操作/返回需要回放的时间点
  2891. */
  2892. playback:function(fn){
  2893. if(!isUndefined(fn)){
  2894. if(valType(fn)=='function'){
  2895. newEvent.addEventListener('playback',fn);
  2896. }
  2897. }
  2898. else{
  2899. return playbackTime;
  2900. }
  2901. return player;
  2902. },
  2903. /*
  2904. * backLive
  2905. * 功能:显示/隐藏回到直播的按钮
  2906. */
  2907. backLive:function(fn){
  2908. if(!isUndefined(fn)){
  2909. if(valType(fn)=='function'){
  2910. newEvent.addEventListener('backLive',fn);
  2911. }
  2912. if(valType(fn)=='boolean'){
  2913. if(bool){
  2914. C['bar']['backLive'].show();
  2915. }
  2916. else{
  2917. C['bar']['backLive'].hide();
  2918. }
  2919. }
  2920. }
  2921. return player;
  2922. },
  2923. /*
  2924. * full
  2925. * 功能:监听全屏功能/执行全屏操作
  2926. * @fn为函数时监听用户执行全屏操作,为空时执行全屏操作
  2927. */
  2928. full:function(fn){
  2929. if(!isUndefined(fn) && valType(fn)=='function'){
  2930. newEvent.addEventListener('full',fn);
  2931. }
  2932. else{
  2933. if(smallWindowsState){
  2934. return;
  2935. }
  2936. if(CT.theatre){
  2937. player.exitTheatre();
  2938. }
  2939. if(CT.webFull){
  2940. player.exitWebFull();
  2941. }
  2942. var requestMethod = CK.requestFullScreen || //W3C
  2943. CK.webkitRequestFullScreen || //Chrome等
  2944. CK.mozRequestFullScreen || //FireFox
  2945. CK.oRequestFullscreen ||
  2946. CK.msRequestFullscreen; //IE11
  2947. if (!isUndefined(requestMethod)) {
  2948. requestMethod.call(CK);
  2949. }
  2950. else if (!isUndefined(window.ActiveXObject)) { //for Internet Explorer
  2951. var wscript = new ActiveXObject('WScript.Shell');
  2952. if (wscript !== null) {
  2953. wscript.SendKeys('{F11}');
  2954. }
  2955. }
  2956. else if(!isUndefined(video.webkitEnterFullscreen) || !isUndefined(video.webkitEnterFullScreen)){
  2957. var fullScreen=video.webkitEnterFullscreen || video.webkitEnterFullScreen;
  2958. fullScreen.call(video);
  2959. }
  2960. player.zoom(100);
  2961. }
  2962. return player;
  2963. },
  2964. /*
  2965. * exitFull
  2966. * 功能: 退出全屏
  2967. */
  2968. exitFull:function(){
  2969. var exitFullFun = document.exitFullscreen || //W3C
  2970. document.mozCancelFullScreen || //FireFox
  2971. document.webkitExitFullscreen || //Chrome等
  2972. document.oCancelFullScreen || //Chrome等
  2973. document.msExitFullscreen; //IE11
  2974. if (!isUndefined(exitFullFun)) {
  2975. exitFullFun.call(document);
  2976. }
  2977. else if (!isUndefined(window.ActiveXObject)) { //for Internet Explorer
  2978. var wscript = new ActiveXObject('WScript.Shell');
  2979. if (wscript !== null) {
  2980. wscript.SendKeys('{F11}');
  2981. }
  2982. }
  2983. return player;
  2984. },
  2985. /*
  2986. * fullOrExit
  2987. * 功能:在全屏和退出全屏之间进行切换
  2988. */
  2989. fullOrExit:function(){
  2990. var fullState = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement;
  2991. if(fullState){
  2992. player.exitFull();
  2993. }
  2994. else{
  2995. player.full();
  2996. }
  2997. return player;
  2998. },
  2999. /*
  3000. * webFull
  3001. * 功能:监听网页全屏/执行网页全屏
  3002. * @fn为函数时监听网页全屏,为空时执行网页全屏
  3003. */
  3004. webFull:function(fn){
  3005. if(!isUndefined(fn) && valType(fn)=='function'){
  3006. newEvent.addEventListener('webfull',fn);
  3007. }
  3008. else{
  3009. exitSmallWindows();
  3010. if(!isUndefined(vars['theatre'])){
  3011. C['bar']['theatreAndExit'].hide();
  3012. }
  3013. CK.css({
  3014. 'position':'fixed',
  3015. 'top':0,
  3016. 'left':0,
  3017. 'height':'100%',
  3018. 'z-index':getMaxZIndex()+1
  3019. });
  3020. C['bar']['webFullAndExit']['webFull'].hide();
  3021. C['bar']['webFullAndExit']['exitWebFull'].show();
  3022. CT.webFull=true;
  3023. eventTarget('webfull',true);
  3024. checkVideoRotate();
  3025. }
  3026. return player;
  3027. },
  3028. /*
  3029. * exitWebFull
  3030. * 功能:退出网页全屏
  3031. */
  3032. exitWebFull:function(){
  3033. CK.css({
  3034. 'position':'relative'
  3035. });
  3036. C['bar']['webFullAndExit']['webFull'].show();
  3037. C['bar']['webFullAndExit']['exitWebFull'].hide();
  3038. if(!isUndefined(vars['theatre'])){
  3039. C['bar']['theatreAndExit'].show();
  3040. C['bar']['theatreAndExit']['theatre'].show();
  3041. C['bar']['theatreAndExit']['exitTheatre'].hide();
  3042. }
  3043. CK.attr('style','');
  3044. CT.webFull=false;
  3045. eventTarget('webfull',false);
  3046. checkVideoRotate();
  3047. return player;
  3048. },
  3049. /*
  3050. * theatre
  3051. * 功能:监听剧场模式/执行剧场模式
  3052. * @fn为函数时执行监听剧场模式,为空时执行剧场模式操作
  3053. */
  3054. theatre:function(fn){
  3055. if(!isUndefined(fn) && valType(fn)=='function'){
  3056. newEvent.addEventListener('theatre',fn);
  3057. }
  3058. else{
  3059. if(valType(vars['theatre'])=='array' && vars['theatre'].length==2){
  3060. var fun=vars['theatre'][0];
  3061. if(valType(fun)=='function'){
  3062. fun();
  3063. }
  3064. if(valType(fun)=='string'){
  3065. eval(fun+ '()');
  3066. }
  3067. }
  3068. else{
  3069. exitSmallWindows();
  3070. CK.css({
  3071. 'position':'absolute',
  3072. 'top':CT.offset()['top'],
  3073. 'left':0,
  3074. 'height':CT.getHeight()+'px',
  3075. 'z-index':getMaxZIndex()+1
  3076. });
  3077. C['bar']['theatreAndExit']['theatre'].hide();
  3078. C['bar']['theatreAndExit']['exitTheatre'].show();
  3079. }
  3080. CT.theatre=true;
  3081. eventTarget('theatre',true);
  3082. checkVideoRotate();
  3083. }
  3084. return player;
  3085. },
  3086. /*
  3087. * exitTheatre
  3088. * 功能:退出剧场模式
  3089. */
  3090. exitTheatre:function(){
  3091. if(valType(vars['theatre'])=='array' && vars['theatre'].length==2){
  3092. var fun=vars['theatre'][1];
  3093. if(valType(fun)=='function'){
  3094. fun();
  3095. }
  3096. if(valType(fun)=='string'){
  3097. eval(fun+ '()');
  3098. }
  3099. }
  3100. else{
  3101. CK.css({
  3102. 'position':'relative'
  3103. });
  3104. C['bar']['theatreAndExit']['theatre'].show();
  3105. C['bar']['theatreAndExit']['exitTheatre'].hide();
  3106. CK.attr('style','');
  3107. CT.theatre=false;
  3108. }
  3109. eventTarget('theatre',false);
  3110. checkVideoRotate();
  3111. return player;
  3112. },
  3113. /*
  3114. * smallWindows
  3115. * 功能:监听小窗口模式开启关闭/执行开启关闭小窗口模式
  3116. */
  3117. smallWindows:function(fn){
  3118. if(!isUndefined(fn)){
  3119. if(valType(fn)=='function'){
  3120. newEvent.addEventListener('smallWindows',fn);
  3121. }
  3122. if(valType(fn)=='boolean'){
  3123. if(fn){
  3124. C['rightBar']['smallwindows']['open'].show();
  3125. C['rightBar']['smallwindows']['close'].hide();
  3126. CT.smallWindows=true;
  3127. }
  3128. else{
  3129. C['rightBar']['smallwindows']['open'].hide();
  3130. C['rightBar']['smallwindows']['close'].show();
  3131. CT.smallWindows=false;
  3132. }
  3133. eventTarget('smallWindows',CT.smallWindows);
  3134. checkVideoRotate();
  3135. }
  3136. }
  3137. return CT.smallWindows;
  3138. },
  3139. /*
  3140. * loop
  3141. * 功能:监听循环/执行开启关闭循环功能
  3142. * @fn为函数时是监听循环,@fn为boolean类型时,为true开启循环,为false关闭循环,@fn为空时获取当前循环状态
  3143. */
  3144. loop:function(fn){
  3145. if(!isUndefined(fn)){
  3146. if(valType(fn)=='function'){
  3147. newEvent.addEventListener('loop',fn);
  3148. }
  3149. if(valType(fn)=='boolean' && video){
  3150. if(fn){
  3151. C['rightBar']['loop']['open'].show();
  3152. C['rightBar']['loop']['close'].hide();
  3153. CT.loop=true;
  3154. video.attr('loop','loop');
  3155. eventTarget('loop',true);
  3156. }
  3157. else{
  3158. C['rightBar']['loop']['open'].hide();
  3159. C['rightBar']['loop']['close'].show();
  3160. CT.loop=false;
  3161. video.attr('loop',false);
  3162. video.removeAttr('loop');
  3163. eventTarget('loop',false);
  3164. }
  3165. }
  3166. }
  3167. return CT.loop;
  3168. },
  3169. /*
  3170. * screenshot
  3171. * 功能:截图
  3172. * @fn为函数时监听截图功能,@fn为空时进行截图
  3173. */
  3174. screenshot:function(fn){
  3175. if(!isUndefined(fn) && valType(fn)=='function'){
  3176. newEvent.addEventListener('screenshot',fn);
  3177. }
  3178. else{
  3179. if(!isUndefined(vars['screenshot']) && vars['screenshot'] && video){
  3180. try {
  3181. message(language['screenshotStart'],true);
  3182. var newCanvas = $(document.createElement('canvas'));
  3183. newCanvas.width = video.videoWidth;
  3184. newCanvas.height = video.videoHeight;
  3185. newCanvas.getContext('2d').drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
  3186. var base64 = newCanvas.toDataURL('image/png');
  3187. eventTarget('screenshot',base64);
  3188. if(screenshotImg){
  3189. screenshotImg.remove();
  3190. screenshotImg=null;
  3191. }
  3192. screenshotImg=createlImg(base64);
  3193. screenshotImg.addListener('load',function(){
  3194. C['screenshot']['img'].append(screenshotImg);
  3195. C['screenshot'].show().css({'width':this.getWidth()+'px'});
  3196. });
  3197. var newBlob=dataURLtoBlob(base64);
  3198. var url = URL.createObjectURL(newBlob);
  3199. var downName='video';
  3200. if(vars['title']){
  3201. downName=vars['title'];
  3202. }
  3203. C['screenshot']['bar']['down'].attr('href',url).attr('download',downName);
  3204. return base64;
  3205. }catch(error) {
  3206. message(language['error']['screenshot'],true);
  3207. }
  3208. }
  3209. else{
  3210. message(language['screenshotClose'],true);
  3211. }
  3212. }
  3213. return player;
  3214. },
  3215. /*
  3216. * closeScreenshot
  3217. * 功能:关闭截图显示容器
  3218. */
  3219. closeScreenshot:function(bool){
  3220. if(!isUndefined(bool) && valType(bool)=='boolean' && !bool){
  3221. C['screenshot'].show();
  3222. }
  3223. else{
  3224. C['screenshot'].hide();
  3225. }
  3226. return player;
  3227. },
  3228. /*
  3229. * layer
  3230. * 功能:在播放器中添加一个层
  3231. */
  3232. layer:function(obj,bar){
  3233. if(isUndefined(obj)){
  3234. return null;
  3235. }
  3236. var cBar=false;
  3237. if(!isUndefined(bar)){
  3238. cBar=bar;
  3239. }
  3240. var ele=null;
  3241. if(valType(obj)=='object'){
  3242. if('class' in obj && 'content' in obj){
  3243. ele=createlDiv(obj['class']);
  3244. ele.htm(obj['content']);
  3245. }
  3246. else if('content' in obj){
  3247. obj=obj['content'];
  3248. }
  3249. }
  3250. if(valType(obj)=='string'){
  3251. if(obj.substr(0,1)=='.' || obj.substr(0,1)=='#'){
  3252. ele=getElement(obj);
  3253. }
  3254. else{
  3255. ele=createlDiv('ck-layer');
  3256. ele.htm(obj);
  3257. }
  3258. }
  3259. if(ele){
  3260. var zIndex=ele.css('z-index');
  3261. if(zIndex=='auto'){
  3262. zIndex=101;
  3263. }
  3264. if(zIndex<101) zIndex=101;
  3265. if(zIndex>200) zIndex=200;
  3266. if(isUndefined(ele.cssDisplay)){
  3267. ele.cssPosition=ele.css('position');
  3268. ele.cssDisplay=ele.css('display');
  3269. }
  3270. ele.css({
  3271. 'position': 'absolute',
  3272. 'z-index':zIndex
  3273. });
  3274. if(!cBar){
  3275. CM.append(ele);
  3276. }
  3277. else{
  3278. C['bar'].append(ele);
  3279. }
  3280. ele.CK=CK;
  3281. ele.show();
  3282. }
  3283. return ele;
  3284. },
  3285. /*
  3286. * closeLayer
  3287. * 功能:关闭一个层
  3288. */
  3289. closeLayer:function(ele){
  3290. if(valType(ele)=='string'){
  3291. var temp=$(ele);
  3292. if(!isUndefined(temp)){
  3293. if(temp.length>0){
  3294. ele=temp.eq(0);
  3295. }
  3296. }
  3297. }
  3298. if(!isUndefined(ele) && valType(ele)=='htmlobject'){
  3299. if(!isUndefined(ele.captureParentNode)){
  3300. var eleP=ele.captureParentNode;
  3301. if (ele.nextElement) {
  3302. try {
  3303. eleP.insertBefore(ele, ele.nextElement);
  3304. }
  3305. catch (event) {
  3306. eleP.append(ele);
  3307. }
  3308. }
  3309. else if (ele.prevElement) {
  3310. try {
  3311. eleP.insertAfter(ele, ele.prevElement);
  3312. }
  3313. catch (event) {
  3314. eleP.append(ele);
  3315. }
  3316. }
  3317. else {
  3318. eleP.append(ele);
  3319. }
  3320. ele.css({'display':ele.cssDisplay});
  3321. }
  3322. else{
  3323. ele.remove();
  3324. }
  3325. if(!isUndefined(ele.cssDisplay)){
  3326. ele.css({
  3327. 'display':ele.cssDisplay,
  3328. 'position':ele.cssPosition
  3329. });
  3330. }
  3331. }
  3332. return player;
  3333. },
  3334. /*
  3335. * message
  3336. * 在播放器内部显示一条提示信息
  3337. */
  3338. message:function(str){
  3339. message(str);
  3340. return player;
  3341. },
  3342. /*
  3343. * closeFrontAd
  3344. * 功能:关闭贴片广告
  3345. */
  3346. closeFrontAd:function(){
  3347. if(frontAdPlay && !isUndefined(ad) && !isUndefined(ad['front']) && !isUndefined(ad['front']['list'])){
  3348. ad['frontPlayI']=ad['front']['list'].length-1;
  3349. adFrontEnded();
  3350. clearAdFrontSetTime();
  3351. }
  3352. return player;
  3353. },
  3354. /*
  3355. * addListener
  3356. * 功能:监听功能
  3357. */
  3358. addListener:function(name,fn){
  3359. newEvent.addEventListener(name,fn);
  3360. },
  3361. /*
  3362. * removeListener
  3363. * 功能:监听功能
  3364. */
  3365. removeListener:function(name,fn){
  3366. newEvent.removeEventListener(name,fn);
  3367. },
  3368. /*
  3369. * bar
  3370. * 功能:显示/关闭底部控制栏
  3371. */
  3372. bar:function(bool){
  3373. barShow=bool;
  3374. if(bool){
  3375. C['bar'].show();
  3376. }
  3377. else{
  3378. C['bar'].hide();
  3379. }
  3380. },
  3381. /*
  3382. * rightBar
  3383. * 功能:显示/关闭右边控制栏
  3384. */
  3385. rightBar:function(bool){
  3386. rightBarShow=bool;
  3387. if(bool){
  3388. C['rightBar'].show();
  3389. }
  3390. else{
  3391. C['rightBar'].hide();
  3392. }
  3393. },
  3394. /*
  3395. * mouseActive
  3396. * 功能,监听鼠标是否经过播放器
  3397. */
  3398. mouseActive:function(fn){
  3399. if(!isUndefined(fn) && valType(fn)=='function'){
  3400. newEvent.addEventListener('mouseActive',fn);
  3401. }
  3402. return this;
  3403. },
  3404. /*
  3405. * cookie
  3406. * 功能,读取cookie
  3407. */
  3408. cookie:function(name){
  3409. if(name=='delete'){
  3410. cookie(ckplayerCookie,'delete',vars['domain']);
  3411. return null;
  3412. }
  3413. if(!isUndefined(name) && name){
  3414. name=name.replace(/[ ]*,[ ]*|[ ]+/g, '').replace(/[ ]*;[ ]*|[ ]+/g, '');
  3415. }
  3416. var cStr=cookie(ckplayerCookie);
  3417. if(cStr){
  3418. var arr=stringToArray(cStr);
  3419. var tempArr=[];
  3420. var cTime=parseInt(Date.now()*0.001);
  3421. for(i=0;i<arr.length;i++){
  3422. if(parseInt(arr[i][2])>cTime){
  3423. tempArr.push(arr[i]);
  3424. }
  3425. }
  3426. arr=tempArr;
  3427. if(arr.length>0){
  3428. cookie(ckplayerCookie,'delete',vars['domain'],vars['cookiePath']);
  3429. cookie(ckplayerCookie,arrayToString(arr),vars['domain'],vars['cookiePath']);
  3430. for(var i=0;i<arr.length;i++){
  3431. arr[i]={
  3432. name:arr[i][0],
  3433. time:arr[i][1],
  3434. expirationTime:date('Y-m-d H:i:s',arr[i][2]),
  3435. expirationTimeStamp:arr[i][2]
  3436. };
  3437. if(!isUndefined(name) && name==arr[i]['name']){
  3438. return arr[i];
  3439. }
  3440. }
  3441. return arr;
  3442. }
  3443. else{
  3444. cookie(ckplayerCookie,'delete',vars['domain'],vars['cookiePath']);
  3445. }
  3446. }
  3447. return null;
  3448. },
  3449. /*
  3450. * visibilityState
  3451. * 功能:监听当前文档是否处于焦点状态
  3452. */
  3453. visibilityState:function(fn){
  3454. if(!isUndefined(fn) && valType(fn)=='function'){
  3455. if(!isUndefined(document.visibilityState)){
  3456. fn(document.visibilityState === 'visible'?'show':'hidden');
  3457. }
  3458. newEvent.addEventListener('visibilityState',fn);
  3459. }
  3460. return this;
  3461. },
  3462. /*
  3463. * remove
  3464. * 功能:卸载播放器
  3465. */
  3466. remove:function(){
  3467. var eventTemp={};
  3468. if(eventTargetList!=null){
  3469. for(var k in eventTargetList){
  3470. eventTemp[k]=eventTargetList[k];
  3471. }
  3472. for(var k in eventTemp){
  3473. var temp=eventTemp[k];
  3474. if(temp){
  3475. for(var i=0;i<temp.length;i++){
  3476. var eve=temp[i];
  3477. newEvent.removeEventListener(k,eve);
  3478. }
  3479. }
  3480. }
  3481. }
  3482. if(frontAdPlay){
  3483. this.closeFrontAd();
  3484. }
  3485. if(pugPlayer){
  3486. pugPlayer.pause();
  3487. pugPlayer.unload();
  3488. pugPlayer.detachMediaElement();
  3489. pugPlayer.destroy();
  3490. pugPlayer=null;
  3491. }
  3492. if(hls){
  3493. hls.stopLoad();
  3494. hls.detachMedia();
  3495. }
  3496. loadedmetadataNum=0;
  3497. loadedTrack=false;
  3498. isChangeDef=true;
  3499. if(video){
  3500. video.unbind();
  3501. video.remove();
  3502. video=null;
  3503. }
  3504. if(!isUndefined(C['menu'])){
  3505. C['menu'].remove();
  3506. }
  3507. if(CT){
  3508. CT.unbind();
  3509. CT.htm('');
  3510. }
  3511. return null;
  3512. }
  3513. };
  3514. /*
  3515. * checkBar
  3516. * 功能:完全获取vars值后判断控制栏上的按钮是否需要显示
  3517. * 完全获取vars是指视频加载成功后
  3518. */
  3519. var checkBar=function(){
  3520. //初始化判断
  3521. if(vars['autoplay']){
  3522. C['bar']['playAndPause']['play'].hide();
  3523. C['bar']['playAndPause']['pause'].show();
  3524. }
  3525. else{
  3526. C['bar']['playAndPause']['play'].show();
  3527. C['bar']['playAndPause']['pause'].hide();
  3528. }
  3529. if(mutedState){
  3530. C['bar']['vbox']['muted'].hide();
  3531. }
  3532. else{
  3533. C['bar']['vbox']['exitMuted'].hide();
  3534. }
  3535. if(!isUndefined(vars['next'])){
  3536. C['bar']['nextEpisode'].show();
  3537. }
  3538. else{
  3539. C['bar']['nextEpisode'].hide();
  3540. }
  3541. if(!isUndefined(vars['webFull']) && vars['webFull'] && !CT.full){
  3542. C['bar']['webFullAndExit'].show();
  3543. }
  3544. else{
  3545. C['bar']['webFullAndExit'].hide();
  3546. }
  3547. if(!isUndefined(vars['theatre']) && !CT.full && !CT.webFull){
  3548. C['bar']['theatreAndExit'].show();
  3549. }
  3550. else{
  3551. C['bar']['theatreAndExit'].hide();
  3552. }
  3553. if(!isUndefined(vars['rightBar']) && vars['rightBar']){
  3554. C['rightBar'].show();
  3555. }
  3556. else{
  3557. C['rightBar'].hide();
  3558. }
  3559. if(!vars['live'] || valType(vars['live'])=='number'){
  3560. pSliderMouseDown=false;
  3561. progressDragX();//注册进度滑块动作
  3562. }
  3563. if(vars['live'] || valType(vars['live'])=='number'){
  3564. C['time'].htm(language['live']);
  3565. C['tempTime'].htm(language['live']);
  3566. }
  3567. if(valType(vars['smallWindows'])=='boolean' && !vars['smallWindows']){
  3568. CT.smallWindows=false;
  3569. C['rightBar']['smallwindows']['open'].hide();
  3570. C['rightBar']['smallwindows']['close'].show();
  3571. }
  3572. if(CT.loop){
  3573. C['rightBar']['loop']['open'].show();
  3574. C['rightBar']['loop']['close'].hide();
  3575. }
  3576. else{
  3577. C['rightBar']['loop']['open'].hide();
  3578. C['rightBar']['loop']['close'].show();
  3579. }
  3580. if(!isUndefined(vars['backLive']) && vars['backLive']){
  3581. C['bar']['backLive'].show();
  3582. }
  3583. if(vars['volume']==0){
  3584. player.muted();
  3585. }
  3586. },
  3587. /*
  3588. * loadLogo
  3589. * 功能:加载logo
  3590. */
  3591. loadLogo=function(){
  3592. if(!isUndefined(vars['logo']) && isUndefined(C['logo'])){
  3593. C['logo']=createlDiv('ck-logo');
  3594. createlImg(vars['logo']).addListener('load',function(){
  3595. CM.append(C['logo']);
  3596. C['logo'].append(this);
  3597. }).addListener('error',function(){C['logo'].remove()});
  3598. }
  3599. },
  3600. /*
  3601. * loadAbout
  3602. * 功能:加载loadAbout
  3603. */
  3604. loadAbout=function(){
  3605. if(!isUndefined(vars['information']) && !isUndefined(C['about']) && valType(vars['information'])=='object'){
  3606. var obj=vars['information'];
  3607. var k='';
  3608. var ul=$(document.createElement('ul'));
  3609. var temp='';
  3610. for(k in obj){
  3611. var title=createlDiv('div').attr('class','ck-about-title');
  3612. var content=createlDiv('div').attr('class','ck-about-content');
  3613. var li=$(document.createElement('li'));
  3614. title.htm(k);
  3615. content.htm(obj[k]);
  3616. li.append(title);
  3617. li.append(content);
  3618. ul.append(li);
  3619. temp+=k+':'+obj[k]+'\n';
  3620. }
  3621. C['about'].append(ul);
  3622. C['about']['textareaText']=temp;
  3623. C['about']['textareaEle']=$(document.createElement('textarea'));
  3624. CM.append(C['about']['textareaEle']);
  3625. C['about']['textareaEle'].hide()
  3626. }
  3627. },
  3628. /*
  3629. * loadMenu
  3630. * 功能:加载右键
  3631. */
  3632. loadMenu=function(){
  3633. if(!isUndefined(vars['menu']) && vars['menu']){
  3634. rightMenu=vars['menu'];
  3635. }
  3636. C['menu']=createlDiv('ckplayer-ckplayer-menu');
  3637. for(var i=0;i<rightMenu.length;i++){
  3638. var m=rightMenu[i];
  3639. var li=createlDiv('ck-li');
  3640. if(!isUndefined(m['underline'])){
  3641. li.addClass('ck-underline');
  3642. }
  3643. if(!isUndefined(m['link']) && !isUndefined(m['title'])){
  3644. li.append(createlA(m['title'],m['link']));
  3645. C['menu'].append(li);
  3646. }
  3647. else if(!isUndefined(m['javascript']) && !isUndefined(m['title'])){
  3648. li.append(createlJsLink(m['title'],m['javascript']));
  3649. C['menu'].append(li);
  3650. }
  3651. else if(!isUndefined(m['click']) && !isUndefined(m['title'])){
  3652. var a=createlJsLink(m['title']);
  3653. a.attr('data-click',m['click'].toString());
  3654. a.click(function(){
  3655. eval($(this).attr('data-click')+'()');
  3656. C['menu'].hide();
  3657. });
  3658. li.append(a);
  3659. C['menu'].append(li);
  3660. }
  3661. else if(!isUndefined(m['title'])){
  3662. li.htm(m['title']);
  3663. C['menu'].append(li);
  3664. }
  3665. }
  3666. $('body').append(C['menu']);
  3667. CM.oncontextmenu = function(eve) {
  3668. var e = eve || window.event;
  3669. var client = getClient(e);
  3670. if (e.button == 2) {
  3671. e.returnvalue = false;
  3672. var x = client['x'] - 2;
  3673. var y = client['y'] - 2;
  3674. C['menu'].show();
  3675. C['menu'].css({
  3676. left: x + 'px',
  3677. top: y + 'px'
  3678. });
  3679. return false;
  3680. }
  3681. return true;
  3682. };
  3683. var menuSetTimeOut=null;
  3684. var clearTime=function(){
  3685. if(menuSetTimeOut){
  3686. clearTimeout(menuSetTimeOut);
  3687. menuSetTimeOut=null;
  3688. }
  3689. };
  3690. var menuMouseOut=function(){
  3691. clearTime();
  3692. menuSetTimeOut=setTimeout(function(){
  3693. C['menu'].hide();
  3694. },200);
  3695. };
  3696. C['menu'].mouseout(menuMouseOut);
  3697. C['menu'].mouseover(clearTime);
  3698. },
  3699. /*
  3700. * aboutShow
  3701. * 功能:显示关于视频
  3702. */
  3703. aboutShow=function(){
  3704. C['about'].show();
  3705. C['menu'].hide();
  3706. },
  3707. /*
  3708. * aboutHide
  3709. * 功能:显示关于视频
  3710. */
  3711. aboutHide=function(){
  3712. C['about'].hide();
  3713. },
  3714. /*
  3715. * aboutCopy
  3716. * 功能:拷贝关于视频内容
  3717. */
  3718. aboutCopy=function(){
  3719. C['about']['textareaEle'].show();
  3720. C['about']['textareaEle'].select();
  3721. document.execCommand('Copy'); // 执行浏览器复制命令
  3722. C['about']['textareaEle'].hide();
  3723. message(language['copySucceeded'],true);
  3724. },
  3725. /*
  3726. * getBarHeight
  3727. * 功能:获取控制栏的高
  3728. */
  3729. getBarHeight=function(){
  3730. var h=C['bar'].getHeight();
  3731. if(parseFloat(C['bar']['pbox'].css('top'))<0){
  3732. h-=parseInt(C['bar']['pbox'].css('top'));
  3733. }
  3734. return h;
  3735. },
  3736. /*
  3737. * hideBar
  3738. * 功能:隐藏控制栏,只在播放状态下有效
  3739. */
  3740. hideBar=function(){
  3741. if(mouseSetTime){
  3742. clearTimeout(mouseSetTime);
  3743. mouseSetTime=null;
  3744. }
  3745. mouseSetTime=setTimeout(function(){
  3746. if(!paused){
  3747. C['bar'].addClass('ck-bar-out');
  3748. eventTarget('mouseActive',false);
  3749. if(CT.full){
  3750. CM.addClass('ck-nocursor');
  3751. }
  3752. if(C['rightBar'].css('display')=='block'){
  3753. C['rightBar'].addClass('ck-right-bar-hide');
  3754. }
  3755. if(C['topBar'].css('display')=='block'){
  3756. C['topBar'].addClass('ck-top-bar-hide');
  3757. }
  3758. }
  3759. mouseSetTime=null;
  3760. },vars['barHideTime']);
  3761. },
  3762. /*
  3763. * barMouseOut
  3764. * 功能:鼠标离开控制栏修改播放进度框样式
  3765. */
  3766. barMouseOut=function(){
  3767. if(!paused){
  3768. C['bar']['pbox'].addClass('ck-bar-progress-out');
  3769. hideBar();
  3770. }
  3771. },
  3772. /*
  3773. * barMouseOver
  3774. * 功能:鼠标经过控制栏修改播放进度框样式
  3775. */
  3776. barMouseOver=function(){
  3777. if(!paused){
  3778. C['bar']['pbox'].removeClass('ck-bar-progress-out');
  3779. if(mouseSetTime){
  3780. clearTimeout(mouseSetTime);
  3781. mouseSetTime=null;
  3782. }
  3783. }
  3784. },
  3785. /*
  3786. * rightBarMouseOut
  3787. * 功能:鼠标离开右侧控制栏修改播放进度框样式
  3788. */
  3789. rightBarMouseOut=function(){
  3790. if(!paused){
  3791. hideBar();
  3792. }
  3793. },
  3794. /*
  3795. * rightBarMouseOver
  3796. * 功能:鼠标经过右侧控制栏修改播放进度框样式
  3797. */
  3798. rightBarMouseOver=function(){
  3799. if(!paused){
  3800. if(mouseSetTime){
  3801. clearTimeout(mouseSetTime);
  3802. mouseSetTime=null;
  3803. }
  3804. }
  3805. },
  3806. /*
  3807. * checkPlaybackrate
  3808. * 功能:初始化或重置倍速组件内容
  3809. */
  3810. checkPlaybackrate=function(){
  3811. var playbackrate=vars['playbackrateList'];
  3812. var pbr=vars['playbackrate'];
  3813. C['bar']['playbackrate']['bg']=createlDiv('ck-list-bg');
  3814. C['bar']['playbackrate']['bgbox'].append(C['bar']['playbackrate']['bg']);
  3815. C['bar']['playbackrate']['bg']['p']=[];
  3816. for(var i=playbackrate.length-1;i>-1;i--){
  3817. var pTemp=createlButton('ck-list-p',playbackrate[i]+language['playbackrateSuffix']);
  3818. pTemp.attr('data-i',i).attr('data-val',playbackrate[i]);
  3819. C['bar']['playbackrate']['bg']['p'].push(pTemp);
  3820. C['bar']['playbackrate']['bg'].append(pTemp);
  3821. pTemp.click(playbackrateClick);
  3822. }
  3823. C['bar']['playbackrate'].hide();
  3824. if(!isUndefined(vars['playbackrateOpen']) && vars['playbackrateOpen']){
  3825. C['bar']['playbackrate'].show();
  3826. C['bar']['playbackrate']['bgbox'].show();
  3827. var w=C['bar']['playbackrate']['bg'].getWidth(),h=C['bar']['playbackrate']['bg'].getHeight();
  3828. var bw=C['bar']['playbackrate']['button'].getWidth();
  3829. C['bar']['playbackrate']['bg'].css({'width':w+10+'px'});
  3830. w=C['bar']['playbackrate']['bg'].getWidth();
  3831. if(getBarHeight()>C['bar'].getHeight()){
  3832. h+=(getBarHeight()-C['bar'].getHeight());
  3833. }
  3834. C['bar']['playbackrate']['bgbox'].attr('style','');
  3835. C['bar']['playbackrate']['bgbox'].css({
  3836. 'width':w+'px',
  3837. 'height':(h+2)+'px',
  3838. 'left':-(w-bw)*0.5+'px'
  3839. });
  3840. C['bar']['playbackrate']['button'].mouseover(function(){
  3841. w=C['bar']['playbackrate']['bg'].getWidth();
  3842. bw=C['bar']['playbackrate']['button'].getWidth();
  3843. C['bar']['playbackrate']['bgbox'].css({
  3844. 'left':-(w-bw)*0.5+'px'
  3845. });
  3846. });
  3847. changePlaybackrateVal(pbr);
  3848. }
  3849. },
  3850. /*
  3851. * playbackrateClick
  3852. * 功能:选择播速
  3853. */
  3854. playbackrateClick=function(e){
  3855. C['bar']['playbackrate']['bgbox'].hide();
  3856. setTimeout(function(){C['bar']['playbackrate']['bgbox'].removeCss('display');},300);
  3857. message(language['switchTo']+$(this).htm());
  3858. player.playbackRate(parseFloat($(this).attr('data-val')));
  3859. },
  3860. /*
  3861. * changePlaybackrateVal
  3862. * 功能:根据速度检查播速
  3863. */
  3864. changePlaybackrateVal=function(num){
  3865. C['bar']['playbackrate']['bg'].find('button').each(function(index,ele){
  3866. var val=parseFloat(ele.attr('data-val'));
  3867. ele.removeClass('ck-list-p-focus');
  3868. if(num==val){
  3869. ele.addClass('ck-list-p-focus');
  3870. if(num!=1){
  3871. C['bar']['playbackrate']['button'].htm(ele.htm());
  3872. }
  3873. else{
  3874. C['bar']['playbackrate']['button'].htm(language['playbackrate']);
  3875. }
  3876. }
  3877. else{
  3878. ele.removeClass('ck-list-p-focus');
  3879. }
  3880. });
  3881. },
  3882. /*
  3883. * checkTrack
  3884. * 功能:初始化或重置字幕组件内容
  3885. */
  3886. checkTrack=function(){
  3887. var track=vars['track'];
  3888. var pbr=-1;
  3889. C['bar']['track']['bgbox'].htm('');
  3890. C['bar']['track']['bg']=createlDiv('ck-list-bg');
  3891. C['bar']['track']['bgbox'].append(C['bar']['track']['bg']);
  3892. C['bar']['track']['bg']['p']=[];
  3893. var pTemp=null;
  3894. for(var i=track.length-1;i>-1;i--){
  3895. pTemp=createlButton('ck-list-p',track[i]['label']);
  3896. pTemp.attr('data-i',i).attr('data-title',track[i]['label']);
  3897. C['bar']['track']['bg']['p'].push(pTemp);
  3898. C['bar']['track']['bg'].append(pTemp);
  3899. if(!isUndefined(track[i]['default']) && track[i]['default']){
  3900. pbr=i;
  3901. }
  3902. pTemp.click(trackClick);
  3903. }
  3904. //
  3905. pTemp=createlButton('ck-list-p',language['noTrack']);
  3906. pTemp.attr('data-i',-1).attr('data-title',language['noTrack']);
  3907. C['bar']['track']['bg']['p'].push(pTemp);
  3908. C['bar']['track']['bg'].append(pTemp);
  3909. pTemp.click(trackClick);
  3910. //
  3911. C['bar']['track'].hide();
  3912. C['bar']['track'].show();
  3913. C['bar']['track']['bgbox'].show();
  3914. var w=C['bar']['track']['bg'].getWidth(),h=C['bar']['track']['bg'].getHeight();
  3915. var bw=C['bar']['track']['button'].getWidth();
  3916. C['bar']['track']['bg'].css({'width':w+10+'px'});
  3917. w=C['bar']['track']['bg'].getWidth();
  3918. if(getBarHeight()>C['bar'].getHeight()){
  3919. h+=(getBarHeight()-C['bar'].getHeight());
  3920. }
  3921. C['bar']['track']['bgbox'].attr('style','');
  3922. C['bar']['track']['bgbox'].css({
  3923. 'width':w+'px',
  3924. 'height':(h+2)+'px',
  3925. 'left':-(w-bw)*0.5+'px'
  3926. });
  3927. C['bar']['track']['button'].mouseover(function(){
  3928. w=C['bar']['track']['bg'].getWidth();
  3929. bw=C['bar']['track']['button'].getWidth();
  3930. C['bar']['track']['bgbox'].css({
  3931. 'left':-(w-bw)*0.5+'px'
  3932. });
  3933. });
  3934. changeTrackVal(pbr);
  3935. },
  3936. /*
  3937. * trackClick
  3938. * 功能:选择字幕
  3939. */
  3940. trackClick=function(e){
  3941. C['bar']['track']['bgbox'].hide();
  3942. setTimeout(function(){C['bar']['track']['bgbox'].removeCss('display');},300);
  3943. message(language['switchTo']+$(this).attr('data-title'));
  3944. player.track(parseFloat($(this).attr('data-i')));
  3945. },
  3946. /*
  3947. * changeTrackVal
  3948. * 功能:根据字幕检查
  3949. */
  3950. changeTrackVal=function(num){
  3951. C['bar']['track']['bg'].find('button').each(function(index,ele){
  3952. var i=parseInt(ele.attr('data-i'));
  3953. if(num==i){
  3954. C['bar']['track']['button'].htm(ele.attr('data-title'));
  3955. if(i>-1){
  3956. CT.track=vars['track'][i];
  3957. eventTarget('track',vars['track'][i]);
  3958. }
  3959. else{
  3960. CT.track=null;
  3961. eventTarget('track',null);
  3962. }
  3963. ele.addClass('ck-list-p-focus');
  3964. }
  3965. else{
  3966. ele.removeClass('ck-list-p-focus');
  3967. }
  3968. });
  3969. },
  3970. /*
  3971. * checkDefinition
  3972. * 功能:初始化或重置清晰度组件内容
  3973. */
  3974. checkDefinition=function(){
  3975. var pi=-1;
  3976. var videoUrl=video['currentSrc'];
  3977. if(!isUndefined(C['bar']['definition']['bg'])){
  3978. C['bar']['definition']['bgbox'].htm('');
  3979. C['bar']['definition']['bgbox'].attr('style','');
  3980. C['bar']['definition']['button'].htm(language['definition']);
  3981. }
  3982. if(valType(vars['video'])=='array'){
  3983. var arr=vars['video'];
  3984. C['bar']['definition']['bg']=createlDiv('ck-list-bg');
  3985. C['bar']['definition']['bgbox'].append(C['bar']['definition']['bg']);
  3986. C['bar']['definition']['bg']['p']=[];
  3987. for(var i=arr.length-1;i>-1;i--){
  3988. var pTemp=createlButton('ck-list-p',arr[i][2]);
  3989. pTemp.attr('data-i',i).attr('data-video',arr[i][0]).attr('data-type',arr[i][1]).attr('data-title',arr[i][2]);
  3990. C['bar']['definition']['bg']['p'].push(pTemp);
  3991. C['bar']['definition']['bg'].append(pTemp);
  3992. if(videoUrl && videoUrl.indexOf(arr[i][0])>-1){
  3993. pi=i;
  3994. }
  3995. pTemp.click(definitionClick);
  3996. }
  3997. C['bar']['definition'].show();
  3998. C['bar']['definition']['bgbox'].show();
  3999. var w=C['bar']['definition']['bg'].getWidth(),h=C['bar']['definition']['bg'].getHeight();
  4000. var bw=C['bar']['definition']['button'].getWidth();
  4001. C['bar']['definition']['bg'].css({'width':w+10+'px'});
  4002. w=C['bar']['definition']['bg'].getWidth();
  4003. if(getBarHeight()>C['bar'].getHeight()){
  4004. h+=(getBarHeight()-C['bar'].getHeight());
  4005. }
  4006. C['bar']['definition']['bgbox'].attr('style','');
  4007. C['bar']['definition']['bgbox'].css({
  4008. 'width':w+'px',
  4009. 'height':(h+2)+'px',
  4010. 'left':-(w-bw)*0.5+'px'
  4011. });
  4012. C['bar']['definition']['button'].mouseover(function(){
  4013. w=C['bar']['definition']['bg'].getWidth();
  4014. bw=C['bar']['definition']['button'].getWidth();
  4015. C['bar']['definition']['bgbox'].css({
  4016. 'left':-(w-bw)*0.5+'px'
  4017. });
  4018. });
  4019. }
  4020. if(pi>-1){
  4021. C['bar']['definition']['bg'].find('button').each(function(index,ele){
  4022. var i=parseInt(ele.attr('data-i'));
  4023. if(pi==i){
  4024. ele.addClass('ck-list-p-focus');
  4025. }
  4026. else{
  4027. ele.removeClass('ck-list-p-focus');
  4028. }
  4029. });
  4030. }
  4031. },
  4032. /*
  4033. * definitionClick
  4034. * 功能:选择清晰度
  4035. */
  4036. definitionClick=function(e){
  4037. C['bar']['definition']['bgbox'].hide();
  4038. setTimeout(function(){
  4039. C['bar']['definition']['bgbox'].removeCss('display');
  4040. },300);
  4041. changeDefinition(parseInt($(this).attr('data-i')));
  4042. },
  4043. /*
  4044. * changeDefinition
  4045. * 功能:检查清晰度
  4046. */
  4047. changeDefinition=function(num){
  4048. C['bar']['definition']['bg'].find('button').each(function(index,ele){
  4049. var i=parseInt(ele.attr('data-i'));
  4050. if(num==i){
  4051. if(!isUndefined(video.textTracks) && video.textTracks.length>0){
  4052. for(var y=video.find('track').length-1;y>-1;y--){
  4053. video.find('track').eq(y).remove();
  4054. }
  4055. }
  4056. seekTime=player.time();
  4057. video.attr('autoplay','autoplay');
  4058. changeVideo(ele.attr('data-video'));
  4059. message(language['switchTo']+ele.htm());
  4060. C['bar']['definition']['button'].htm(ele.htm());
  4061. ele.addClass('ck-list-p-focus');
  4062. eventTarget('definition',{id:i,video:ele.attr('data-video'),title:ele.attr('data-title')});
  4063. }
  4064. else{
  4065. ele.removeClass('ck-list-p-focus');
  4066. }
  4067. });
  4068. },
  4069. /*
  4070. * deletePrompt
  4071. * 功能:删除关键点
  4072. */
  4073. deletePrompt=function(){
  4074. var i=0;
  4075. if(!isUndefined(C['prompt']) && valType(C['prompt'])=='array'){
  4076. for(i=C['prompt'].length;i>-1;i--){
  4077. if(!isUndefined(C['prompt'][i])){
  4078. C['prompt'][i].remove();
  4079. }
  4080. }
  4081. C['prompt']=null;
  4082. }
  4083. C['prompt']=[];
  4084. },
  4085. /*
  4086. * changePrompt
  4087. * 功能:构建关键点
  4088. */
  4089. changePrompt=function(){
  4090. deletePrompt();
  4091. for(var i=0;i<vars['prompt'].length;i++){
  4092. var obj=vars['prompt'][i];
  4093. if(!isUndefined(obj) && 'words' in obj && 'time' in obj && !isUndefined(obj['time']) && !isUndefined(obj['words']) && valType(obj['time'])=='number'){
  4094. var ele=createlDiv('ck-bar-progress-prompt');
  4095. ele.attr('data-words',obj['words']).attr('data-time',obj['time']);
  4096. C['bar']['pbox']['bg'].append(ele);
  4097. var bf=(ele.getWidth()*0.5/C['bar']['pbox']['bg'].getWidth())*50;
  4098. var left=obj['time']/duration*100-bf;
  4099. if(left<0) left=0;
  4100. if(left>100) left=100;
  4101. ele.css({'left':left+'%'});
  4102. ele.mouseover(function(){
  4103. if(this.attr('data-words')){
  4104. showPromptWords(this);
  4105. }
  4106. });
  4107. ele.mouseout(function(){
  4108. if(this.attr('data-words')){
  4109. showPromptWords();
  4110. }
  4111. });
  4112. C['prompt'].push(ele);
  4113. }
  4114. }
  4115. },
  4116. /*
  4117. * showPromptWords
  4118. * 功能:显示关键点提示
  4119. */
  4120. showPromptWords=function(ele){
  4121. if(isUndefined(C['promptWords'])){
  4122. C['promptWords']=createlDiv('ck-prompt-words');
  4123. CM.append(C['promptWords']);
  4124. C['promptWords']['content']=createlDiv('ck-prompt-content');
  4125. C['promptWords'].append(C['promptWords']['content']);
  4126. }
  4127. if(isUndefined(ele)){
  4128. C['promptWords']['content'].htm('');
  4129. C['promptWords'].hide();
  4130. return;
  4131. }
  4132. C['promptWords']['content'].htm(ele.attr('data-words'));
  4133. C['promptWords'].show();
  4134. var pW=C['promptWords'].getWidth(),pH=C['promptWords'].getHeight();
  4135. var bg=C['bar']['pbox']['bg'];
  4136. var time=parseFloat(ele.attr('data-time'));
  4137. var top=CK.getHeight()-getBarHeight();
  4138. var left=ele.offset()['left']-CK.offset()['left']+ele.getWidth()*.5-pW*.5;
  4139. if(!isUndefined(C['preview'])){
  4140. top=CK.getHeight()-parseFloat((getBarHeight()+C['preview']['smallHight']+parseInt(C['preview'].css('margin-bottom'))));
  4141. }
  4142. else{
  4143. top=CK.getHeight()-parseFloat((getBarHeight()+C['tip']['minHeight']+parseInt(C['tip'].css('margin-bottom'))));
  4144. top-=(getBarHeight()-C['bar'].getHeight());
  4145. }
  4146. top-=parseFloat(C['promptWords'].css('margin-bottom'));
  4147. top-=pH;
  4148. left-=parseFloat(C['promptWords'].css('margin-right'));
  4149. if(left<0)left=0;
  4150. if(left>CK.getWidth()-pW)left=CK.getWidth()-pW;
  4151. C['promptWords'].css({
  4152. 'top':top+'px',
  4153. 'left':left+'px'
  4154. });
  4155. },
  4156. /*
  4157. * changePreview
  4158. * 功能:加载或重置预览图片
  4159. */
  4160. changePreview=function(preview){
  4161. if(!isUndefined(C['preview'])){
  4162. C['preview'].remove();
  4163. C['preview']=null;
  4164. }
  4165. if(!isUndefined(preview)){
  4166. C['preview']=createlDiv('ck-preview');
  4167. CM.append(C['preview']);
  4168. if(isUndefined(vars['preview']['type'])){
  4169. vars['preview']['type']=0;
  4170. }
  4171. if(vars['preview']['type']==1){
  4172. C['preview']['bg']=createlDiv('ck-preview-bg');
  4173. C['preview'].append(C['preview']['bg']);
  4174. }
  4175. var files=[];
  4176. var loadImg=function(bigW,bigH,smallW,smallH){
  4177. if(vars['preview']['type']==1){
  4178. C['preview']['bg']['img']=[];
  4179. for(var i=0;i<files.length;i++){
  4180. for(var y=0;y<bigH/smallH;y++){
  4181. var img=createlDiv('ck-preview-img');
  4182. img.attr('data-img',files[i]).attr('data-i',y);
  4183. img.css({
  4184. 'width':bigW+'px',
  4185. 'height':smallH+'px',
  4186. 'background-position':'left '+(-(y*smallH))+'px'
  4187. });
  4188. C['preview']['bg'].append(img);
  4189. C['preview']['bg']['img'].push(img);
  4190. }
  4191. }
  4192. C['preview']['bg'].css({
  4193. 'width':bigW*(bigH/smallH)*(files.length+1)+'px',
  4194. 'height':smallH+'px'
  4195. });
  4196. }
  4197. C['preview']['bigWidth']=bigW;
  4198. C['preview']['bigHight']=bigH;
  4199. C['preview']['smallWidth']=smallW;
  4200. C['preview']['smallHight']=smallH;
  4201. if(vars['preview']['type']==1){
  4202. C['preview']['frame']=createlDiv('ck-preview-frame');
  4203. C['preview'].append(C['preview']['frame']);
  4204. C['preview']['frame'].css({
  4205. 'width':smallW+'px',
  4206. 'height':(smallH-parseFloat(C['preview']['frame'].css('border-width'))*2)+'px',
  4207. });
  4208. }
  4209. };
  4210. if(valType(vars['preview'])=='object'){
  4211. if(valType(vars['preview']['file'])=='array'){
  4212. files=vars['preview']['file'];
  4213. var thumbnail=[10,10];
  4214. if(valType(vars['preview']['thumbnail'])=='array' && vars['preview']['thumbnail'].length>1){
  4215. if(valType(vars['preview']['thumbnail'][0])=='number'){
  4216. thumbnail[0]=vars['preview']['thumbnail'][0];
  4217. }
  4218. if(valType(vars['preview']['thumbnail'][1])=='number'){
  4219. thumbnail[1]=vars['preview']['thumbnail'][1];
  4220. }
  4221. vars['preview']['thumbnail']=thumbnail;
  4222. }
  4223. if(files[0]){
  4224. var img = createlImg(files[0],'ck-preview-load-img').addListener('load',function(){
  4225. loadImg(this.getWidth(),this.getHeight(),this.getWidth()/thumbnail[0],this.getHeight()/thumbnail[1]);
  4226. this.remove();
  4227. });
  4228. CM.append(img);
  4229. }
  4230. }
  4231. else{
  4232. C['preview'].removeChild();
  4233. C['preview']=null;
  4234. }
  4235. }
  4236. else{
  4237. C['preview'].removeChild();
  4238. C['preview']=null;
  4239. }
  4240. }
  4241. },
  4242. /*
  4243. * showPreview
  4244. * 功能:显示预览图
  4245. */
  4246. showPreview=function(time){
  4247. if(hidePreviewSetTime){
  4248. clearTimeout(hidePreviewSetTime);
  4249. hidePreviewSetTime=null;
  4250. }
  4251. if(time<0){
  4252. if(!isUndefined(C['preview'])){
  4253. hidePreviewSetTime=setTimeout(function(){
  4254. C['preview'].hide();
  4255. hidePreviewSetTime=null;
  4256. },200);
  4257. return;
  4258. }
  4259. }
  4260. if(!isUndefined(C['preview']) && !isUndefined(vars['preview']['thumbnail']) && duration>0){
  4261. if(isUndefined(vars['preview']['type'])){
  4262. vars['preview']['type']=0;
  4263. }
  4264. var scale=2,thumbnail=vars['preview']['thumbnail'];
  4265. if(!isUndefined(vars['preview']['scale'])){
  4266. scale=vars['preview']['scale'];
  4267. }
  4268. var divI=0,imgI=0;
  4269. var left=0,frameLeft=0;
  4270. var pW=0;
  4271. var smallW=C['preview']['smallWidth'],smallH=C['preview']['smallHight'];
  4272. var bgXw=time*C['bar']['pbox']['bg'].getWidth()/duration+(C['bar']['pbox']['bg'].offset()['left']-CK.offset()['left']);
  4273. if(C['preview'].css('display')=='none'){
  4274. C['preview'].show();
  4275. }
  4276. C['preview'].css({
  4277. 'height':smallH+'px',
  4278. });
  4279. if(vars['preview']['type']==1){
  4280. divI=parseInt(time/(scale*thumbnail[0]));
  4281. imgI=parseInt(time/scale);
  4282. var minI=divI-5,maxI=divI+5;
  4283. if(minI<0) minI=0;
  4284. if(maxI>C['preview']['bg']['img'].length-1){
  4285. maxI=C['preview']['bg']['img'].length-1;
  4286. }
  4287. for(var i=minI;i<maxI;i++){
  4288. if(C['preview']['bg']['img'][i].attr('data-img')){
  4289. var bgPosition=C['preview']['bg']['img'][i].css('background-position');
  4290. C['preview']['bg']['img'][i].css({'background':'url('+C['preview']['bg']['img'][i].attr('data-img')+') no-repeat'});
  4291. C['preview']['bg']['img'][i].attr('data-img','');
  4292. C['preview']['bg']['img'][i].css('background-position',bgPosition);
  4293. }
  4294. }
  4295. pW=C['preview']['frame'].getWidth();
  4296. frameLeft=bgXw-pW*.5;
  4297. left=-(imgI*smallW+smallW*.5)+bgXw;
  4298. if(frameLeft<0){
  4299. frameLeft=0;
  4300. bgXw=(pW-smallW)*0.5;
  4301. left=-(imgI*smallW)+bgXw;
  4302. }
  4303. if(frameLeft>C['preview'].getWidth()-C['preview']['frame'].getWidth()){
  4304. var xz=frameLeft-(C['preview'].getWidth()-C['preview']['frame'].getWidth());
  4305. frameLeft=C['preview'].getWidth()-C['preview']['frame'].getWidth();
  4306. left-=xz;
  4307. }
  4308. C['preview']['bg'].css({'left':left+'px'});
  4309. C['preview']['frame'].css({'left':frameLeft+'px'});
  4310. }
  4311. else{
  4312. var temp=(time/scale)/(thumbnail[0]*thumbnail[1]);
  4313. imgI=parseInt(temp);//计算显示的图片编号
  4314. var smallI=parseInt((temp-imgI)*100);
  4315. var rows=parseInt(smallI/thumbnail[0]);
  4316. var column=smallI%thumbnail[0];
  4317. var files=vars['preview']['file'];
  4318. left=bgXw-smallW*.5;
  4319. if(left<0){
  4320. left=0;
  4321. }
  4322. if(left>CK.getWidth()-smallW){
  4323. left=CK.getWidth()-smallW;
  4324. }
  4325. C['preview'].css({
  4326. 'width':C['preview']['smallWidth']+'px',
  4327. 'background':'url('+files[imgI]+') no-repeat',
  4328. 'background-position':'-'+column*smallW+'px -'+rows*smallH+'px',
  4329. 'left':left+'px'
  4330. });
  4331. }
  4332. }
  4333. },
  4334. /*
  4335. * showError
  4336. * 功能:显示错误信息
  4337. */
  4338. showError=function(){
  4339. C['loading'].hide();
  4340. if(vars['controls'] || !vars['errorShow']){
  4341. return;
  4342. }
  4343. if(isUndefined(C['error'])){
  4344. C['error']=createlDiv('ck-error');
  4345. CM.append(C['error']);
  4346. }
  4347. var msg=CT.error['message'];
  4348. if(!msg) msg=language['error']['noMessage'];
  4349. var html=msg+'(code:'+CT.error['code']+')';
  4350. C['error'].htm(html);
  4351. C['error'].show();
  4352. },
  4353. /*
  4354. * showWindowsError
  4355. * 功能:显示错误信息
  4356. */
  4357. showWindowsError=function(error){
  4358. var ele=createlDiv('ckplayer-error',error);
  4359. $('body').append(ele);
  4360. },
  4361. /*
  4362. * showNextEpisode
  4363. * 功能:鼠标经过下一集按钮的动作
  4364. */
  4365. showNextEpisode=function(){
  4366. if(isUndefined(vars['next'])) return;
  4367. if(valType(vars['next'])=='object'){
  4368. if('content' in vars['next']){
  4369. C['next']=player.layer(vars['next']);
  4370. return;
  4371. }
  4372. if('title' in vars['next']){
  4373. tip(C['bar']['nextEpisode'],vars['next']['title']);
  4374. return;
  4375. }
  4376. }
  4377. tip(C['bar']['nextEpisode'],language['next']);
  4378. },
  4379. /*
  4380. * nextClick
  4381. * 功能:点击下一集按钮的动作
  4382. */
  4383. nextClick=function(){
  4384. if(valType(vars['next'])=='object'){
  4385. if('click' in vars['next']){
  4386. if(valType(vars['next']['click'])=='function'){
  4387. vars['next']['click']();
  4388. }
  4389. else if(valType(vars['next']['click'])=='string'){
  4390. eval(vars['next']['click']+'()');
  4391. }
  4392. }
  4393. if('link' in vars['next']){
  4394. window.location.href=vars['next']['link'];
  4395. }
  4396. eventTarget('next');
  4397. }
  4398. },
  4399. /*
  4400. * showEnded
  4401. * 功能:播放结束后的显示内容
  4402. */
  4403. showEnded=function() {
  4404. if(!CT.loop && !isUndefined(vars['ended'])){
  4405. closePauseAd();
  4406. C['ended']=player.layer(vars['ended']);
  4407. if(C['ended']){
  4408. C['centerPlay'].hide();
  4409. }
  4410. return;
  4411. }
  4412. },
  4413. /*
  4414. * windowScroll
  4415. * 功能:监听页面滚动
  4416. */
  4417. windowScroll=function() {
  4418. if(!CT.smallWindows) return;
  4419. if(CT.webFull || CT.theatre || CT.full){
  4420. exitSmallWindows();
  4421. return;
  4422. }
  4423. var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
  4424. if(scrollTop>CT.offset()['top']+CT.getHeight()){
  4425. if(!CK.hasClass('ckplayer-ckplayer-smallwindow')){
  4426. CK.addClass('ckplayer-ckplayer-smallwindow');
  4427. eventTarget('smallWindows',true);
  4428. smallWindowsState=true;
  4429. if(vars['smallWindowsDrag']){
  4430. drag(true);
  4431. }
  4432. allBarHide();
  4433. checkVideoRotate();
  4434. }
  4435. }
  4436. else{
  4437. exitSmallWindows();
  4438. }
  4439. },
  4440. /*
  4441. * exitSmallWindows
  4442. * 退出小窗口模式
  4443. */
  4444. exitSmallWindows=function(){
  4445. if(CK.hasClass('ckplayer-ckplayer-smallwindow')){
  4446. CK.removeClass('ckplayer-ckplayer-smallwindow');
  4447. if(vars['smallWindowsDrag']){
  4448. drag();
  4449. }
  4450. eventTarget('smallWindows',false);
  4451. smallWindowsState=false;
  4452. allBarShow();
  4453. checkVideoRotate();
  4454. }
  4455. },
  4456. /*
  4457. * drag
  4458. * 功能,使节点可拖动
  4459. * state:是否开启可拖动,默认=false,关闭状态
  4460. */
  4461. drag=function(state) {
  4462. var doc=$(document);
  4463. var posX = 0,posY = 0,
  4464. posXRecord = 0,posYRecord = 0;
  4465. var open=false;
  4466. if(!isUndefined(state)){
  4467. open=state;
  4468. }
  4469. var mouseDown = function(e) {
  4470. e.preventDefault && e.preventDefault();
  4471. e = e || window.event;
  4472. var client = getClient(e);
  4473. posXRecord = client['x'];
  4474. posYRecord = client['y'];
  4475. doc.mousemove(docMouseMove);
  4476. doc.mouseup(docMouseUp);
  4477. CK.css({
  4478. 'cursor':'move'
  4479. });
  4480. };
  4481. var docMouseMove = function(e) {
  4482. e = e || window.event;
  4483. var client = getClient(e);
  4484. var eleOffset = CK.offset();
  4485. posY = client['y']-posYRecord;
  4486. posX = client['x']-posXRecord;
  4487. posXRecord = client['x'];
  4488. posYRecord = client['y'];
  4489. var left=eleOffset['left']+posX;
  4490. var top=eleOffset['top']+posY;
  4491. CK.css({
  4492. 'left':left+'px',
  4493. 'top':top+'px'
  4494. });
  4495. if(CK.css('position')!='fixed'){
  4496. CK.css({
  4497. 'position':'fixed'
  4498. });
  4499. }
  4500. isDrag=true;
  4501. };
  4502. var docMouseUp = function() {
  4503. doc.removeListener('mousemove', docMouseMove);
  4504. doc.removeListener('mouseup', docMouseUp);
  4505. CK.css({
  4506. 'cursor':'default'
  4507. });
  4508. };
  4509. if(open){
  4510. CK.mousedown(mouseDown);
  4511. }
  4512. else{
  4513. CK.unbind('mousedown');
  4514. }
  4515. },
  4516. /*
  4517. * checkVideoRotate
  4518. * 检查播放器尺寸
  4519. */
  4520. checkVideoRotate=function(){
  4521. var ckW=CK.getWidth()*nowZoom*0.01,ckH=CK.getHeight()*nowZoom*0.01;
  4522. var vW=CV.getWidth(),vH=CV.getHeight();
  4523. CV.css({
  4524. 'transform':'rotate('+nowRotate+'deg)',
  4525. '-ms-transform':'rotate('+nowRotate+'deg)',
  4526. '-moz-transform':'rotate('+nowRotate+'deg)',
  4527. '-webkit-transform':'rotate('+nowRotate+'deg)',
  4528. '-o-transform':'rotate('+nowRotate+'deg)',
  4529. 'width':nowZoom+'%',
  4530. 'height':nowZoom+'%'
  4531. });
  4532. if(nowRotate!=0 && nowRotate!=180){
  4533. if(vH>ckW && vW>ckH){
  4534. if(vH / ckW > vW / ckH) {
  4535. CV.css({
  4536. 'height':nowZoom+'%',
  4537. 'width':ckH+'px'
  4538. });
  4539. }
  4540. else {
  4541. CV.css({
  4542. 'width':nowZoom+'%',
  4543. 'height':ckW+'px'
  4544. });
  4545. }
  4546. return;
  4547. }
  4548. if(vH<ckW && vW<ckH){
  4549. if(ckW>ckH){
  4550. CV.css({
  4551. 'height':nowZoom+'%',
  4552. 'width':ckH+'px'
  4553. });
  4554. }
  4555. else{
  4556. if(vH / vW >= ckW / ckH) {
  4557. CV.css({
  4558. 'width':nowZoom+'%',
  4559. 'height':ckW+'px'
  4560. });
  4561. }
  4562. else {
  4563. CV.css({
  4564. 'height':nowZoom+'%',
  4565. 'width':ckH+'px'
  4566. });
  4567. }
  4568. }
  4569. return;
  4570. }
  4571. if(vH>=ckW && vW<=ckH){
  4572. CV.css({
  4573. 'width':nowZoom+'%',
  4574. 'height':ckW+'px'
  4575. });
  4576. return;
  4577. }
  4578. if(vW>=ckH && vH<ckW){
  4579. CV.css({
  4580. 'height':nowZoom+'%',
  4581. 'width':ckH+'px'
  4582. });
  4583. }
  4584. }
  4585. },
  4586. /*
  4587. * allBarShow
  4588. * 功能:控制栏显示
  4589. */
  4590. allBarShow=function(){
  4591. if(barShow){
  4592. C['bar'].show();
  4593. C['topBar'].show();
  4594. }
  4595. if(rightBarShow){
  4596. C['rightBar'].show();
  4597. }
  4598. C['tempTime'].hide();
  4599. if(!isUndefined(C['logo'])){
  4600. C['logo'].show();
  4601. }
  4602. },
  4603. /*
  4604. * allBarHide
  4605. * 功能:控制栏隐藏
  4606. */
  4607. allBarHide=function(tempTime){
  4608. if(isUndefined(tempTime)){
  4609. tempTime=true;
  4610. }
  4611. C['bar'].hide();
  4612. C['topBar'].hide();
  4613. C['rightBar'].hide();
  4614. if(tempTime){
  4615. C['tempTime'].show();
  4616. }
  4617. if(!isUndefined(C['logo'])){
  4618. C['logo'].hide();
  4619. }
  4620. },
  4621. /*
  4622. * message
  4623. * 功能:显示提示
  4624. */
  4625. message=function(str,right){
  4626. C['message'].htm('');
  4627. var msgHide=function(){
  4628. C['message'].removeClass('ck-message-right').removeClass('ck-animate-bouncein').removeClass('ck-animate');
  4629. C['message'].hide();
  4630. };
  4631. if(str){
  4632. C['message'].htm(str);
  4633. C['message'].show();
  4634. if(!C['message'].hasClass('ck-animate')){
  4635. C['message'].addClass('ck-animate ck-animate-bouncein');
  4636. }
  4637. if(!isUndefined(right) && right){
  4638. if(!C['message'].hasClass('ck-message-right')){
  4639. C['message'].addClass('ck-message-right');
  4640. }
  4641. }
  4642. if(msgSetTime){
  4643. clearTimeout(msgSetTime);
  4644. msgSetTime=null;
  4645. }
  4646. msgSetTime=setTimeout(function(){
  4647. msgHide();
  4648. msgSetTime=null;
  4649. },1500);
  4650. }
  4651. else{
  4652. msgHide();
  4653. }
  4654. },
  4655. /*
  4656. * tip
  4657. * 功能:显示Tip
  4658. * @ele:需要显示提示的对象,@str:提示文字,@cl:水平修正距离,@align:对齐方式,只有两种,一种默认对齐(箭头在提示文字下方),一种是左对齐(箭头在提示文字右边)
  4659. */
  4660. tip=function(ele,str,cl,align){
  4661. C['tip']['content'].htm('');
  4662. if(str){
  4663. C['tip']['content'].htm(str);
  4664. C['tip'].show();
  4665. if(!C['tip'].hasClass('ck-animate')){
  4666. C['tip'].addClass('ck-animate ck-animate-bouncein');
  4667. }
  4668. if(isUndefined(align)){
  4669. align='auto'
  4670. }
  4671. if(align=='left'){
  4672. C['tip']['content'].removeClass('ck-content-float-auto').addClass('ck-content-float-left');
  4673. C['tip']['triangle'].removeClass('ck-triangle-auto').addClass('ck-triangle-left');
  4674. }
  4675. else{
  4676. C['tip']['content'].removeClass('ck-content-float-left').addClass('ck-content-float-auto');
  4677. C['tip']['triangle'].removeClass('ck-triangle-left').addClass('ck-triangle-auto');
  4678. }
  4679. tipResize(ele,cl,align);
  4680. if(isUndefined(closeTipFun)){
  4681. closeTipFun=function(){
  4682. if(tipSetTime){
  4683. clearTimeout(tipSetTime);
  4684. tipSetTime=null;
  4685. }
  4686. };
  4687. closeTipMouseOut=function(ele){
  4688. closeTipFun();
  4689. tipSetTime=setTimeout(function(){
  4690. tip();
  4691. tipSetTime=null;
  4692. },100);
  4693. if(ele){
  4694. ele.removeListener('mouseout',closeTipMouseOut);
  4695. }
  4696. };
  4697. }
  4698. closeTipFun();
  4699. ele.mouseout(function(){closeTipMouseOut(ele)});
  4700. }
  4701. else{
  4702. C['tip'].hide();
  4703. C['tip'].removeClass('ck-animate');
  4704. C['tip'].removeClass('ck-animate-bouncein');
  4705. }
  4706. },
  4707. /*
  4708. * tipResize
  4709. * 功能:设置tip坐标
  4710. */
  4711. tipResize=function(ele,cl,align){
  4712. var offset=ele.offset();
  4713. var ckOffset=CK.offset();
  4714. var w=C['tip'].getWidth(),h=C['tip'].getHeight();
  4715. var ew=ele.getWidth();
  4716. var left=0,top=offset['top']-ckOffset['top']-h;
  4717. if(getBarHeight()>C['bar'].getHeight()){
  4718. top-=(getBarHeight()-C['bar'].getHeight());
  4719. }
  4720. if(w>ew){
  4721. left=offset['left']-ckOffset['left']-(w-ew)*.5;
  4722. }
  4723. else{
  4724. left=offset['left']-ckOffset['left']+(ew-w)*.5;
  4725. }
  4726. if(align=='left'){
  4727. left=offset['left']-ckOffset['left']-w;
  4728. top=offset['top']-ckOffset['top'];
  4729. }
  4730. if(!isUndefined(cl)){
  4731. left=cl['x']-ckOffset['left']-w*.5;
  4732. }
  4733. if(left<0){
  4734. left=0;
  4735. }
  4736. if(top<0){
  4737. top=0;
  4738. }
  4739. if(left>CM.getWidth()-w){
  4740. left=CM.getWidth()-w;
  4741. }
  4742. if(top>CM.getHeight()-h){
  4743. top=CM.getHeight()-h;
  4744. }
  4745. C['tip'].css({
  4746. 'left':left+'px',
  4747. 'top':top-parseInt(C['tip'].css('margin-bottom'))+'px'
  4748. });
  4749. },
  4750. /*
  4751. * progressDragX
  4752. * 功能:制作进度调节框事件
  4753. */
  4754. progressDragX=function(){
  4755. var bg=C['bar']['pbox']['bg'],
  4756. play=C['bar']['pbox']['play'],
  4757. slider=C['bar']['pbox']['slider'],
  4758. mouseLine=C['bar']['pbox']['mouseLine'];
  4759. slider.unbind();
  4760. bg.unbind();
  4761. var pos = 0,
  4762. posRecord = 0;
  4763. var doc=$(document);
  4764. var sliderDownTime=0;
  4765. var sliderMouseDown = function(e) {
  4766. e.preventDefault && e.preventDefault();
  4767. if(!vars['timeScheduleAdjust']){//禁止拖动
  4768. return;
  4769. }
  4770. e = e || window.event;
  4771. var eleOffset = slider.offset(),bgOffset=bg.offset(),client = getClient(e);
  4772. pSliderMouseDown=true;
  4773. posRecord = client['x'];
  4774. //供比较
  4775. var left = eleOffset['left']-bgOffset['left'];
  4776. sliderDownTime=left*duration/(bg.getWidth()-slider.getWidth());
  4777. slider.removeListener('mousedown', sliderMouseDown);
  4778. slider.removeListener('touchstart', sliderMouseDown);
  4779. doc.mousemove(docMouseMove);
  4780. doc.mouseup(docMouseUp);
  4781. slider.touchmove(docMouseMove);
  4782. slider.touchend(docMouseUp);
  4783. noScrolling(true);
  4784. };
  4785. var docMouseMove = function(e) {
  4786. e = e || window.event;
  4787. var eleOffset = slider.offset(),bgOffset=bg.offset(),client = getClient(e);
  4788. pSliderMouseDown=true;
  4789. pos = posRecord - client['x'];
  4790. posRecord = client['x'];
  4791. var left = eleOffset['left'] - pos-bgOffset['left'];
  4792. if(left<0){
  4793. left=0;
  4794. }
  4795. if(left>bg.getWidth()-slider.getWidth()){
  4796. left=bg.getWidth()-slider.getWidth();
  4797. }
  4798. C['bar']['pbox'].addClass('ck-bar-progress-slider-move');
  4799. //预览时间
  4800. var time='';
  4801. if(!vars['live']){
  4802. time=left*duration/(bg.getWidth()-slider.getWidth());
  4803. switch(vars['timeScheduleAdjust']){
  4804. case 2://只能前进(向右拖动
  4805. if(time<sliderDownTime){
  4806. left=-1000;
  4807. message(language['timeScheduleAdjust']['prohibitBackOff']);
  4808. }
  4809. break;
  4810. case 3://是只能后退
  4811. if(time>sliderDownTime){
  4812. left=-1000;
  4813. message(language['timeScheduleAdjust']['prohibitForward']);
  4814. return;
  4815. }
  4816. break;
  4817. case 4://只能前进但能回到第一次拖动时的位置
  4818. if(time<firstSeekTime){
  4819. left=-1000;
  4820. player.seek(firstSeekTime);
  4821. message(language['timeScheduleAdjust']['prohibitLookBack']);
  4822. return;
  4823. }
  4824. break;
  4825. case 5://看过的地方可以随意拖动
  4826. if(time>maxSeeTime){
  4827. left=-1000;
  4828. player.seek(maxSeeTime);
  4829. message(language['timeScheduleAdjust']['prohibitForwardNotViewed']);
  4830. return;
  4831. }
  4832. break;
  4833. }
  4834. time=formatSeconds(time);
  4835. }
  4836. else{
  4837. time=formatLiveTime(left*getLiveTime()/(bg.getWidth()-slider.getWidth()));
  4838. }
  4839. tip(slider,time);
  4840. if(left>=0){
  4841. slider.css({
  4842. 'left': left + 'px'
  4843. });
  4844. play.css({
  4845. 'width': left+ slider.getWidth()*.5+ 'px'
  4846. });
  4847. }
  4848. else{
  4849. pSliderMouseDown=false;
  4850. }
  4851. };
  4852. var docMouseUp = function() {
  4853. noScrolling();
  4854. doc.removeListener('mousemove', docMouseMove);
  4855. doc.removeListener('mouseup', docMouseUp);
  4856. slider.removeListener('touchmove', docMouseMove);
  4857. slider.removeListener('touchend', docMouseUp);
  4858. slider.mousedown(sliderMouseDown);
  4859. slider.touchstart(sliderMouseDown);
  4860. if(!vars['live']){
  4861. var time=play.getWidth()*duration/(bg.getWidth()-slider.getWidth()*.5);
  4862. if(time>duration){
  4863. time=duration;
  4864. }
  4865. seekTime=0;
  4866. player.seek(time);
  4867. }
  4868. else{
  4869. var playbackTime=parseInt(vars['live']+play.getWidth()*getLiveTime()/(bg.getWidth()-slider.getWidth()*.5));
  4870. eventTarget('playback',{time:playbackTime,date:date('Y-m-d H:i:s',playbackTime)});
  4871. eventTarget('seek',{time:playbackTime,state:'seeking',date:date('Y-m-d H:i:s',playbackTime)});
  4872. }
  4873. C['bar']['pbox'].removeClass('ck-bar-progress-slider-move');
  4874. if(isMouseLeave){
  4875. tip();
  4876. }
  4877. };
  4878. var isMouseLeave=true;//默认鼠标离开了进度按钮上
  4879. var sliderMouseOver=function(){
  4880. var time='';
  4881. if(!vars['live']){
  4882. time=formatSeconds(parseInt(slider.css('left'))*duration/(bg.getWidth()-slider.getWidth()));
  4883. }
  4884. else{
  4885. time=language['live'];
  4886. }
  4887. isMouseLeave=false;
  4888. tip(slider,time);
  4889. };
  4890. var sliderMouseLeave=function(){
  4891. isMouseLeave=true;
  4892. };
  4893. slider.mousedown(sliderMouseDown);
  4894. slider.mouseover(sliderMouseOver);
  4895. slider.mouseleave(sliderMouseLeave);
  4896. slider.touchstart(sliderMouseDown);
  4897. var bgMouseDown=function(e){
  4898. e = e || window.event;
  4899. var client = getClient(e);
  4900. var bgOffset=bg.offset();
  4901. var w=client['x']-bgOffset['left'];
  4902. if(CT.full){
  4903. w+=CK.offset()['left'];
  4904. }
  4905. if(!vars['live']){
  4906. var time=duration*w/bg.getWidth();
  4907. switch(vars['timeScheduleAdjust']){
  4908. case 0://禁止拖动
  4909. message(language['timeScheduleAdjust']['prohibit']);
  4910. return;
  4911. break;
  4912. case 2://只能前进(向右拖动
  4913. if(time<oldTime){
  4914. message(language['timeScheduleAdjust']['prohibitBackOff']);
  4915. return;
  4916. }
  4917. break;
  4918. case 3://是只能后退
  4919. if(time>oldTime){
  4920. message(language['timeScheduleAdjust']['prohibitForward']);
  4921. return;
  4922. }
  4923. break;
  4924. case 4://只能前进但能回到第一次拖动时的位置
  4925. if(time<firstSeekTime){
  4926. message(language['timeScheduleAdjust']['prohibitLookBack']);
  4927. return;
  4928. }
  4929. break;
  4930. case 5://看过的地方可以随意拖动
  4931. if(time>maxSeeTime){
  4932. message(language['timeScheduleAdjust']['prohibitForwardNotViewed']);
  4933. return;
  4934. }
  4935. break;
  4936. }
  4937. seekTime=0;
  4938. player.seek(time);
  4939. }
  4940. else{
  4941. var playbackTime=parseInt(vars['live']+getLiveTime()*w/bg.getWidth());
  4942. eventTarget('playback',{time:playbackTime,date:date('Y-m-d H:i:s',playbackTime)});
  4943. eventTarget('seek',{time:playbackTime,state:'seeking',date:date('Y-m-d H:i:s',playbackTime)});
  4944. }
  4945. if(w>bg.getWidth()-slider.getWidth()*.5){
  4946. w=bg.getWidth()-slider.getWidth()*.5
  4947. }
  4948. if(w<slider.getWidth()*.5){
  4949. w=slider.getWidth()*.5;
  4950. }
  4951. pSliderMouseDown=true;
  4952. play.css({
  4953. 'width': w+ 'px'
  4954. });
  4955. slider.css({
  4956. 'left': w-slider.getWidth()*.5 + 'px'
  4957. });
  4958. };
  4959. var moveTimer=null;
  4960. var bgMouseMove=function(e){
  4961. e = e || window.event;
  4962. var client = getClient(e);
  4963. var bgOffset=bg.offset();
  4964. var w=client['x']-bgOffset['left'];
  4965. clearTime();
  4966. if(CT.full){
  4967. w+=CK.offset()['left'];
  4968. }
  4969. var time=0;
  4970. if(!vars['live']){
  4971. time=duration*w/bg.getWidth();
  4972. showPreview(time);
  4973. time=formatSeconds(time);
  4974. }
  4975. else{
  4976. time=formatLiveTime(getLiveTime()*w/bg.getWidth());
  4977. }
  4978. tip(bg,time,client);
  4979. mouseLine.css({'left':w-(C['bar']['pbox']['mouseLine'].getWidth()*.5)+'px'});
  4980. };
  4981. var moveTimer=null;
  4982. var clearTime=function(){
  4983. if(moveTimer){
  4984. clearTimeout(moveTimer);
  4985. moveTimer=null;
  4986. }
  4987. closeTipFun();
  4988. };
  4989. var bgMouseOut=function(e){
  4990. clearTime();
  4991. moveTimer=setTimeout(function(){
  4992. showPreview(-1);
  4993. },30);
  4994. };
  4995. bg.mousedown(bgMouseDown);
  4996. bg.mousemove(bgMouseMove);
  4997. bg.mouseout(bgMouseOut);
  4998. mouseLine.mouseover(clearTime);
  4999. },
  5000. /*
  5001. * volumeDragY
  5002. * 功能:制作音量调节框事件
  5003. */
  5004. volumeDragY=function() {
  5005. var box=C['bar']['vbox']['volume']['box'],
  5006. bg=C['bar']['vbox']['volume']['bg'],
  5007. pp=C['bar']['vbox']['volume']['pp'],
  5008. slider=C['bar']['vbox']['volume']['slider'],
  5009. doc=$(document);
  5010. var pos = 0,
  5011. posRecord = 0;
  5012. var sliderMouseDown = function(e) {
  5013. e.preventDefault && e.preventDefault();
  5014. noScrolling(true);
  5015. e = e || window.event;
  5016. var client = getClient(e);
  5017. posRecord = client['y'];
  5018. slider.removeListener('mousedown', sliderMouseDown);
  5019. slider.removeListener('touchstart', sliderMouseDown);
  5020. C['bar']['vbox']['mouseDown']=true;
  5021. doc.mousemove(docMouseMove);
  5022. doc.mouseup(docMouseUp);
  5023. slider.touchmove(docMouseMove);
  5024. slider.touchend(docMouseUp);
  5025. };
  5026. var docMouseMove = function(e) {
  5027. e = e || window.event;
  5028. var client = getClient(e);
  5029. var eleOffset = slider.offset();
  5030. var boxOffset=box.offset();
  5031. var bgOffset=bg.offset();
  5032. pos = client['y']-posRecord;
  5033. posRecord = client['y'];
  5034. var sliderTop=eleOffset['top']-boxOffset['top']+pos;
  5035. var minTop=bgOffset['top']-boxOffset['top'],maxTop=bgOffset['top']+bg.getHeight()-boxOffset['top']-slider.getHeight();
  5036. if(sliderTop<minTop){
  5037. sliderTop=minTop;
  5038. }
  5039. if(sliderTop>maxTop){
  5040. sliderTop=maxTop;
  5041. }
  5042. slider.css({
  5043. 'top':sliderTop+'px'
  5044. });
  5045. var ppMarginTop=sliderTop-minTop+slider.getHeight()*0.5;
  5046. pp.css({
  5047. 'margin-top':ppMarginTop+'px'
  5048. });
  5049. var vol=(bg.getHeight()-ppMarginTop-slider.getHeight()*0.5)/(bg.getHeight()-slider.getHeight());
  5050. player.volume(vol);
  5051. };
  5052. var docMouseUp = function() {
  5053. noScrolling();
  5054. doc.removeListener('mousemove', docMouseMove);
  5055. doc.removeListener('mouseup', docMouseUp);
  5056. slider.removeListener('touchmove', docMouseMove);
  5057. slider.removeListener('touchend', docMouseUp);
  5058. slider.mousedown(sliderMouseDown);
  5059. slider.touchstart(sliderMouseDown);
  5060. C['bar']['vbox']['mouseDown']=false;
  5061. };
  5062. slider.mousedown(sliderMouseDown);
  5063. slider.touchstart(sliderMouseDown);
  5064. var bgMouseDown=function(e){
  5065. e = e || window.event;
  5066. var client = getClient(e);
  5067. var bgOffset=bg.offset();
  5068. var h=client['y']-bgOffset['top'];
  5069. var max=bg.getHeight();
  5070. var vol=1-h/max;
  5071. player.volume(vol);
  5072. };
  5073. bg.mousedown(bgMouseDown);
  5074. },
  5075. /*
  5076. * changeProgress
  5077. * 功能:根据时间调节播放进度
  5078. */
  5079. changeProgress=function(time){
  5080. if((valType(vars['live'])=='boolean' && vars['live'])){
  5081. return;
  5082. }
  5083. if(!pSliderMouseDown){
  5084. var bg=C['bar']['pbox']['bg'],slider=C['bar']['pbox']['slider'];
  5085. var playW=(time/duration)*100;
  5086. if(valType(vars['live'])=='number'){
  5087. playW='100';
  5088. }
  5089. C['bar']['pbox']['play'].css({'width':playW+'%'});
  5090. var sliderW=(slider.getWidth()/bg.getWidth())*100;
  5091. var sliderLeft=playW-sliderW*.5;
  5092. if(sliderLeft<0){
  5093. sliderLeft=0;
  5094. }
  5095. if(sliderLeft>100-sliderW){
  5096. sliderLeft=100-sliderW;
  5097. }
  5098. C['bar']['pbox']['slider'].css({'left':sliderLeft+'%'});
  5099. checkProgressSlider();
  5100. }
  5101. },
  5102. /*
  5103. * checkProgressSlider
  5104. * 功能:检查设置播放进度条位置
  5105. */
  5106. checkProgressSlider=function(){
  5107. var bg=C['bar']['pbox']['bg'],slider=C['bar']['pbox']['slider'];
  5108. var st=0;
  5109. if(C['bar']['pbox'].css('transition-duration')){
  5110. st=parseFloat(C['bar']['pbox'].css('transition-duration'))*1000+20;
  5111. }
  5112. var checkThis=function(){
  5113. var sliderLeft=parseInt(C['bar']['pbox']['slider'].css('left'));
  5114. if(sliderLeft<0){
  5115. sliderLeft=0;
  5116. C['bar']['pbox']['slider'].css({'left':sliderLeft+'px'});
  5117. }
  5118. if(sliderLeft>bg.getWidth()-slider.getWidth()){
  5119. sliderLeft=bg.getWidth()-slider.getWidth();
  5120. C['bar']['pbox']['slider'].css({'left':sliderLeft+'px'});
  5121. }
  5122. };
  5123. setTimeout(checkThis,st);
  5124. },
  5125. /*
  5126. * changeTopTime
  5127. * 功能:修改顶部右侧时间
  5128. */
  5129. changeTopTime=function(){
  5130. C['topBar']['timeEle'].htm(date('H:i:s'));
  5131. setTimeout(changeTopTime,1000);
  5132. },
  5133. /*
  5134. * changeVolumeSlider
  5135. * 功能:根据音量改变滑块位置
  5136. */
  5137. changeVolumeSlider=function(vol){
  5138. if(!isUndefined(C['bar']['vbox'])){
  5139. var box=C['bar']['vbox']['volume']['box'],
  5140. bg=C['bar']['vbox']['volume']['bg'],
  5141. pp=C['bar']['vbox']['volume']['pp'],
  5142. slider=C['bar']['vbox']['volume']['slider'];
  5143. C['bar']['vbox']['volume']['txt'].htm(parseInt(vol*100));
  5144. var bgH=bg.getHeight();
  5145. if(bgH){
  5146. var ppMarginTop=bgH-vol*bgH;
  5147. pp.css({
  5148. 'margin-top':ppMarginTop+'px'
  5149. });
  5150. var sliderTop=bg.offset()['top']-box.offset()['top']+ppMarginTop-slider.getHeight()*0.5;
  5151. slider.css({
  5152. 'top':sliderTop+'px'
  5153. });
  5154. }
  5155. }
  5156. },
  5157. /*
  5158. * changeLoad
  5159. * 功能:获取视频已加载部分并修改加载进度栏
  5160. */
  5161. changeLoad=function(){
  5162. if(video){
  5163. var len = video.buffered.length;
  5164. if(len>0){
  5165. var bufferEnd = video.buffered.end(len-1);
  5166. if(loadTime<bufferEnd){
  5167. loadTime=bufferEnd;
  5168. }
  5169. replaceInformation('loadTime',parseInt(loadTime*100)*0.01);
  5170. C['bar']['pbox']['load'].css('width',(loadTime/duration)*100+'%');
  5171. }
  5172. }
  5173. },
  5174. /*
  5175. * changeMuted
  5176. * 功能:修改静音和取消静音时按钮切换事件
  5177. */
  5178. changeMuted=function(b){
  5179. if(b){
  5180. C['bar']['vbox']['muted'].hide();
  5181. C['bar']['vbox']['exitMuted'].show();
  5182. C['ad']['bottom']['mutedAndExit']['muted'].hide();
  5183. C['ad']['bottom']['mutedAndExit']['exitMuted'].show();
  5184. message(language['muted']);
  5185. }
  5186. else{
  5187. C['bar']['vbox']['muted'].show();
  5188. C['bar']['vbox']['exitMuted'].hide();
  5189. C['ad']['bottom']['mutedAndExit']['muted'].show();
  5190. C['ad']['bottom']['mutedAndExit']['exitMuted'].hide()
  5191. }
  5192. },
  5193. /*
  5194. * replaceInformation
  5195. * 功能:替换关于里的内容
  5196. */
  5197. replaceInformation=function(o , n){
  5198. if(isUndefined(C['about']['sourceData']) && !isUndefined(C['about'].find('ul'))){
  5199. C['about']['sourceData']=C['about'].find('ul').eq(0).htm();
  5200. C['about']['objData']={};
  5201. var reg=/{(.*?)}/g;
  5202. var res = C['about']['sourceData'].match(reg);
  5203. while( res = reg.exec(C['about']['sourceData'])){
  5204. C['about']['objData'][res[1]]='0';
  5205. }
  5206. }
  5207. if(!isUndefined(C['about'].find('ul'))){
  5208. var reg=null;
  5209. var htm=C['about']['sourceData'];
  5210. var temp=C['about']['textareaText'];
  5211. if(C['about']['objData']){
  5212. for(var k in C['about']['objData']){
  5213. if(o!=k){
  5214. reg = new RegExp('{'+k+'}' , 'g');
  5215. var val=C['about']['objData'][k];
  5216. if(isUndefined(val)){
  5217. val='0';
  5218. }
  5219. htm=htm.replace(reg , val);
  5220. temp=temp.replace(reg , val);
  5221. }
  5222. }
  5223. }
  5224. reg = new RegExp('{'+o+'}' , 'g');
  5225. htm=htm.replace(reg , n || '');
  5226. temp=temp.replace(reg , n || '');
  5227. C['about']['textareaEle'].htm(temp);
  5228. C['about']['objData'][o]=n;
  5229. return C['about'].find('ul').eq(0).htm(htm);
  5230. }
  5231. },
  5232. /*
  5233. * calculationFps
  5234. * 功能:获取fps
  5235. */
  5236. calculationFps=function() {
  5237. var requestAnimationFrame =
  5238. window.requestAnimationFrame ||
  5239. window.webkitRequestAnimationFrame ||
  5240. window.mozRequestAnimationFrame ||
  5241. window.oRequestAnimationFrame ||
  5242. window.msRequestAnimationFrame ||
  5243. function(callback) {
  5244. window.setTimeout(callback, 1000 / 60);
  5245. };
  5246. var e, pe, pid, fps, last, offset;
  5247. fps = 0;
  5248. last = Date.now();
  5249. var step = function() {
  5250. offset = Date.now() - last;
  5251. fps += 1;
  5252. if(offset >= 1000) {
  5253. last += offset;
  5254. appendFps(fps);
  5255. fps = 0;
  5256. }
  5257. requestAnimationFrame(step);
  5258. };
  5259. var appendFps = function(fps) {
  5260. if(fps!=CT.fps){
  5261. CT.fps=fps;
  5262. replaceInformation('fps',fps);
  5263. eventTarget('fps',fps);
  5264. }
  5265. };
  5266. if(isUndefined(CT.fps)){
  5267. CT.fps=0;
  5268. }
  5269. step();
  5270. },
  5271. /*
  5272. * getElement
  5273. * 功能:获取一个外部节点
  5274. */
  5275. getElement=function(content){
  5276. var ele=$(content);
  5277. if(isUndefined(ele)) return;
  5278. if(valType(ele)=='htmlarray'){
  5279. ele=ele[0];
  5280. }
  5281. if(isUndefined(ele.captureParentNode)){
  5282. ele.captureParentNode = ele.parentNode;
  5283. ele.prevElement=ele.prev();
  5284. ele.nextElement=ele.next();
  5285. }
  5286. return ele;
  5287. },
  5288. /*
  5289. * $
  5290. * 功能:根据ID或className或节点节点名称获取对象
  5291. */
  5292. $=function(obj, eL) {
  5293. var parent = null;
  5294. if (document) {
  5295. parent = document;
  5296. }
  5297. if (!isUndefined(eL)) {
  5298. parent = eL;
  5299. }
  5300. var res = [];
  5301. if (obj) {
  5302. if (valType(obj) == 'htmlobject' || valType(obj)=='object') {
  5303. res = obj;
  5304. if (!isUndefined(res.ckplayer)) {
  5305. return res;
  5306. }
  5307. }
  5308. else if (valType(obj) == 'string' && obj!='') {
  5309. switch (obj.substr(0, 1)) {
  5310. case '.':
  5311. obj = obj.substr(1, obj.length);
  5312. if (parent.getElementsByClassName) {
  5313. res = parent.getElementsByClassName(obj);
  5314. if (!res.length) {
  5315. return null;
  5316. }
  5317. }
  5318. else if (!parent && document.getElementsByClassName) {
  5319. res = document.getElementsByClassName(obj);
  5320. if (!res.length) {
  5321. return null;
  5322. }
  5323. }
  5324. else {
  5325. var reg = new RegExp(' ' + obj + ' ', 'i');
  5326. var ele = null;
  5327. if (parent.getElementsByTagName) {
  5328. ele = parent.getElementsByTagName('*');
  5329. } else {
  5330. ele = document.getElementsByTagName('*');
  5331. }
  5332. for (var i = 0; i < ele.length; i++) {
  5333. if (reg.test(' ' + ele[i].className + ' ')) {
  5334. res.push(ele[i]);
  5335. }
  5336. }
  5337. }
  5338. if (res) {
  5339. if (res.length === 0) {
  5340. res = null;
  5341. }
  5342. }
  5343. break;
  5344. case '#':
  5345. obj = obj.substr(1, obj.length);
  5346. if (parent.getElementById) {
  5347. res = parent.getElementById(obj);
  5348. } else {
  5349. res=document.getElementById(obj);
  5350. }
  5351. break;
  5352. default:
  5353. var reg = new RegExp(' ' + obj + ' ', 'i');
  5354. if (parent.getElementsByTagName) {
  5355. res = parent.getElementsByTagName(obj);
  5356. } else {
  5357. res = document.getElementsByTagName(obj);
  5358. }
  5359. if (res) {
  5360. if (obj == 'body' || obj == 'document' || obj == 'html') {
  5361. res = res[0];
  5362. } else if (res.length === 0) {
  5363. res = null;
  5364. }
  5365. } else {
  5366. res = null;
  5367. }
  5368. break;
  5369. }
  5370. }
  5371. else {
  5372. res = obj;
  5373. }
  5374. }
  5375. else {
  5376. res = document;
  5377. }
  5378. if (res) {
  5379. if (valType(res) == 'htmlobject' || valType(res) == 'object' || valType(res) == 'document') {
  5380. res.ckplayer = 'Thanks for using';
  5381. /*
  5382. * find
  5383. * 功能:在当前节点中查找指定节点
  5384. */
  5385. res.find = function(obj) {
  5386. return $(obj, this);
  5387. };
  5388. /*
  5389. * attr
  5390. * 功能:修改或获取节点的属性值
  5391. * @key不能为空,指属性名称,$value不为空则设置属性值,为空则获取属性值
  5392. */
  5393. res.attr = function(key, value) {
  5394. if (isUndefined(value)) {
  5395. return this.getAttribute(key);
  5396. }
  5397. else {
  5398. this.setAttribute(key, value);
  5399. return this;
  5400. }
  5401. };
  5402. /*
  5403. * removeAtt
  5404. * 功能:删除节点的属性值
  5405. * @key不能为空,指属性名称
  5406. */
  5407. res.removeAttr = function(key) {
  5408. this.removeAttribute(key);
  5409. return this;
  5410. };
  5411. /*
  5412. * css
  5413. * 功能:修改或获取节点的样式样式
  5414. * @key不能为空,指属性名称,$value不为空则设置属性值,为空则获取属性值
  5415. */
  5416. res.css = function(key, value) {
  5417. // 拆解字符串并将第二单词首字母大写
  5418. var keyNew = function(str) {
  5419. // 当属性名有横杠时
  5420. if (str.indexOf('-') != -1) {
  5421. var arr = str.split('-');
  5422. var a = arr[0];
  5423. var b = '',
  5424. c = '';
  5425. if (arr.length > 1) {
  5426. b = arr[1].substr(0, 1).toLocaleUpperCase() + arr[1].substr(1, arr[1].length - 1);
  5427. }
  5428. if (arr.length > 2) {
  5429. b = arr[2].substr(0, 1).toLocaleUpperCase() + arr[2].substr(1, arr[2].length - 1);
  5430. }
  5431. return a + b + c;
  5432. }
  5433. // 没有横杠就不进行字符串拆解
  5434. return str;
  5435. };
  5436. if (isUndefined(value)){
  5437. if (!isUndefined(key) && valType(key) == 'string') {
  5438. if (this.currentStyle) {
  5439. return this.currentStyle[key];
  5440. } else {
  5441. return document.defaultView.getComputedStyle(this, null)[key];
  5442. }
  5443. }
  5444. if (isUndefined(key)) {
  5445. if (this.currentStyle) {
  5446. return this.currentStyle;
  5447. } else {
  5448. return document.defaultView.getComputedStyle(this, null);
  5449. }
  5450. }
  5451. }
  5452. // 当传进来的参数key不是一个对象,给节点添加css样式
  5453. if (valType(key) != 'object') {
  5454. var newKey = keyNew(key);
  5455. if (this.length > 1) {
  5456. // 如果this有多个值,那给每个节点都添加样式
  5457. for (var i = 0; i < this.length; i++) {
  5458. this[i].style[newKey] = value;
  5459. }
  5460. } else {
  5461. this.style[newKey] = value;
  5462. }
  5463. } else {
  5464. //如果第一个值是一个对象,遍历这个对象,并将属性名传进函数进行拆解
  5465. for (var item in key) {
  5466. var objKey = keyNew(item);
  5467. if (valType(this) == 'htmlarray') {
  5468. for (var i = 0; i < this.length; i++) {
  5469. this[i].style[objKey] = key[item];
  5470. }
  5471. } else {
  5472. this.style[objKey] = key[item];
  5473. }
  5474. }
  5475. }
  5476. return this;
  5477. };
  5478. res.hasClass = function(cName) {
  5479. if (isUndefined(cName)) return false;
  5480. var reg = new RegExp('(\\s|^)' + cName + '(\\s|$)');
  5481. if (this.className && this.className.match(reg)) {
  5482. return true;
  5483. }
  5484. return false;
  5485. };
  5486. res.addClass = function(cName) {
  5487. if (!this.hasClass(cName)) {
  5488. if (this.className && this.className.substr(this.className.length - 1, 1) != ' ') {
  5489. this.className += ' ';
  5490. }
  5491. this.className += cName;
  5492. };
  5493. return this;
  5494. };
  5495. res.removeClass = function(cName) {
  5496. if (this.hasClass(cName)) {
  5497. this.className = this.className.replace(new RegExp('(\\s|^)' + cName + '(\\s|$)'), ' ');
  5498. if (this.className.substr(this.className.length - 1, 1) == ' ') {
  5499. this.className = this.className.substr(0, this.className.length - 1);
  5500. }
  5501. if (!this.className) {
  5502. this.removeAttribute('class');
  5503. }
  5504. };
  5505. return this;
  5506. };
  5507. res.searchClass = function(cName) {
  5508. var arr = this.className.split(' ');
  5509. for (var i = 0; i < arr.length; i++) {
  5510. if (arr[i].substr(0, cName.length) == cName) {
  5511. return arr[i];
  5512. }
  5513. }
  5514. return this;
  5515. };
  5516. res.removeCss=function(cName){
  5517. var cs=this.attr('style');
  5518. if(cs){
  5519. var arr=cs.split(';');
  5520. var obj={};
  5521. for(var i=0;i<arr.length;i++){
  5522. var arrT=arr[i].split(':');
  5523. if(arrT.length==2 && arrT[0] && arrT[0].trim()!=cName){
  5524. obj[arrT[0].trim()]=arrT[1].trim();
  5525. }
  5526. }
  5527. this.attr('style','');
  5528. this.css(obj);
  5529. }
  5530. };
  5531. res.addListener = function(e, f, t) {
  5532. return addListener(this, e, f, t);
  5533. };
  5534. res.removeListener = function(e, f, t) {
  5535. return removeListener(this, e, f, t);
  5536. };
  5537. res.prev = function() {
  5538. return prev(this);
  5539. };
  5540. res.next = function() {
  5541. return next(this);
  5542. };
  5543. res.append =function(ele){
  5544. this.appendChild(ele);
  5545. return this;
  5546. };
  5547. res.remove = function() {
  5548. if(!isUndefined(this.parentNode)){
  5549. this.parentNode.removeChild(this);
  5550. }
  5551. return null;
  5552. };
  5553. res.bind=function(e, f, t) {
  5554. return addListener(this, e, f, t);
  5555. };
  5556. res.unbind =function(e,f){
  5557. var i=0;var arr=[];
  5558. if(!isUndefined(f)){
  5559. res.removeListener(e,f);
  5560. }
  5561. else if(!isUndefined(e)){
  5562. if(!isUndefined(this.listenerList)){
  5563. arr=this.listenerList;
  5564. for(i=0;i<arr.length;i++){
  5565. if(arr[i][0]==e){
  5566. res.removeListener(e,arr[i][1]);
  5567. }
  5568. }
  5569. }
  5570. }
  5571. else{
  5572. if(!isUndefined(this.listenerList)){
  5573. arr=this.listenerList;
  5574. for(i=0;i<arr.length;i++){
  5575. res.removeListener(arr[i][0],arr[i][1]);
  5576. }
  5577. }
  5578. }
  5579. };
  5580. /*
  5581. * htm
  5582. * 功能:设置或获取html
  5583. */
  5584. res.htm=function(val){
  5585. if(!isUndefined(val)){
  5586. res.innerHTML=val;
  5587. }
  5588. else{
  5589. return res.innerHTML;
  5590. }
  5591. };
  5592. /*
  5593. * htmReplace
  5594. * 功能:将html中ar替换成val
  5595. */
  5596. res.htmReplace=function(ar,val,html){
  5597. if(!isUndefined(val) && !isUndefined(ar)){
  5598. if(isUndefined(this.attr('data-htm'))){
  5599. this.attr('data-htm',html);
  5600. }
  5601. var htm=this.attr('data-htm');
  5602. var reg = new RegExp(ar , 'g');
  5603. htm=htm.replace(reg , val);
  5604. this.htm(htm);
  5605. }
  5606. };
  5607. /*
  5608. * offset
  5609. * 功能:获取节点的绝对坐标
  5610. */
  5611. res.offset = function() {
  5612. var par = this.offsetParent,
  5613. //获取当前节点的父参照物(不一定是父节点)
  5614. left = this.offsetLeft,
  5615. //获取当前节点相对父节点左偏离
  5616. top = this.offsetTop;
  5617. //获取当前节点相对父节点上偏移
  5618. while (par && par.tagName !== 'BODY') {
  5619. //判断是否已经到了最外一层 并且判断父参照物存不存在
  5620. if (!/MSIE 8\.0/.test(navigator.userAgent)){
  5621. //利用正则表达式判断
  5622. left += par.clientLeft;
  5623. top += par.clientTop;
  5624. }
  5625. left += par.offsetLeft;
  5626. //获得节点距离父节点左偏移多少
  5627. top += par.offsetTop;
  5628. //获得节点距离父节点上偏移多少
  5629. par = par.offsetParent;
  5630. }
  5631. return {
  5632. top: top,
  5633. left: left
  5634. }
  5635. };
  5636. /*
  5637. * fixed
  5638. * 功能:判断节点是否悬浮于页面
  5639. */
  5640. res.fixed = function() {
  5641. if (this.css('position') == 'fixed') {
  5642. return true;
  5643. }
  5644. if (!isUndefined(this.offsetParent)) {
  5645. return $(this.offsetParent).fixed();
  5646. }
  5647. return false;
  5648. };
  5649. /*
  5650. * getWidth
  5651. * 功能:获取节点的宽
  5652. */
  5653. res.getWidth = function() {
  5654. return this.offsetWidth;
  5655. };
  5656. /*
  5657. * getHeight
  5658. * 功能:获取节点的高
  5659. */
  5660. res.getHeight = function() {
  5661. return this.offsetHeight;
  5662. };
  5663. if(isUndefined(res.width)){
  5664. res.width=function(){
  5665. return this.offsetWidth;
  5666. }
  5667. }
  5668. if(isUndefined(res.height)){
  5669. res.height=function(){
  5670. return this.offsetWidth;
  5671. }
  5672. }
  5673. /*
  5674. * resize
  5675. * 功能:监听窗口尺寸变化
  5676. * @fn:窗口变化时执行的函数
  5677. */
  5678. res.resize = function(fn) {
  5679. addListener(window, 'resize', fn);
  5680. };
  5681. /*
  5682. * click
  5683. * 功能:节点单击时执行的函数
  5684. * @fn:执行的函数
  5685. */
  5686. res.click =function(fn){
  5687. addListener(this,'click',fn);
  5688. return this;
  5689. };
  5690. /*
  5691. * singleClick
  5692. * 功能:节点单击事件,当使用该事件时会同时注册双击事件,此时不要使用click函数进行单击事件监听
  5693. * @fn:执行的函数
  5694. */
  5695. res.singleClick=function(fn){
  5696. if(isUndefined(this.dbClick)){
  5697. doubleClickEvent(this);
  5698. this.dbClick=true;
  5699. }
  5700. this.addListener('sigClick',fn);
  5701. return this;
  5702. };
  5703. /*
  5704. * doubleClick
  5705. * 功能:节点双击事件,当使用该事件时会同时注册双击事件,此时不要使用click函数进行单击事件监听
  5706. * @fn:执行的函数
  5707. */
  5708. res.doubleClick=function(fn){
  5709. if(isUndefined(this.dbClick)){
  5710. doubleClickEvent(this);
  5711. this.dbClick=true;
  5712. }
  5713. this.addListener('dobClick',fn);
  5714. return this;
  5715. };
  5716. /*
  5717. * mouseover
  5718. * 功能:鼠标经过节点时执行的函数
  5719. * @fn:执行的函数
  5720. */
  5721. res.mouseover =function(fn){
  5722. addListener(this,'mouseover',fn);
  5723. return this;
  5724. };
  5725. /*
  5726. * mouseout
  5727. * 功能:鼠标离开节点时执行的函数
  5728. * @fn:执行的函数
  5729. */
  5730. res.mouseout =function(fn){
  5731. addListener(this,'mouseout',fn);
  5732. return this;
  5733. };
  5734. /*
  5735. * mousedown
  5736. * 功能:鼠标在节点上按下时执行的函数
  5737. * @fn:执行的函数
  5738. */
  5739. res.mousedown =function(fn){
  5740. addListener(this,'mousedown',fn);
  5741. return this;
  5742. };
  5743. /*
  5744. * mouseup
  5745. * 功能:节点上鼠标弹起时执行的函数
  5746. * @fn:执行的函数
  5747. */
  5748. res.mouseup =function(fn){
  5749. addListener(this,'mouseup',fn);
  5750. return this;
  5751. };
  5752. /*
  5753. * mousemove
  5754. * 功能:鼠标在节点上划行时执行的函数
  5755. * @fn:执行的函数
  5756. */
  5757. res.mousemove =function(fn){
  5758. addListener(this,'mousemove',fn);
  5759. return this;
  5760. };
  5761. /*
  5762. * mouseWheel
  5763. * 功能:鼠标滚轮在节点上划行时执行的函数
  5764. * @fn:执行的函数
  5765. */
  5766. res.mouseWheel =function(fn){
  5767. addListener(this,'mousewheel',fn);
  5768. addListener(this,'DOMMouseScroll',fn,false);
  5769. return this;
  5770. };
  5771. /*
  5772. * mouseleave
  5773. * 功能:鼠标指针移出节点时执行的函数
  5774. * @fn:执行的函数
  5775. */
  5776. res.mouseleave =function(fn){
  5777. addListener(this,'mouseleave',fn);
  5778. return this;
  5779. };
  5780. /*
  5781. * touchstart
  5782. * 功能:移动端鼠标在节点上按下时执行的函数
  5783. * @fn:执行的函数
  5784. */
  5785. res.touchstart =function(fn){
  5786. addListener(this,'touchstart',fn);
  5787. return this;
  5788. };
  5789. /*
  5790. * touchmove
  5791. * 功能:移动端鼠标在节点上划行时执行的函数
  5792. * @fn:执行的函数
  5793. */
  5794. res.touchmove =function(fn){
  5795. addListener(this,'touchmove',fn);
  5796. return this;
  5797. };
  5798. /*
  5799. * touchend
  5800. * 功能:移动端节点上鼠标弹起时执行的函数
  5801. * @fn:执行的函数
  5802. */
  5803. res.touchend =function(fn){
  5804. addListener(this,'touchend',fn);
  5805. return this;
  5806. };
  5807. /*
  5808. * show
  5809. * 功能:显示节点
  5810. */
  5811. res.show=function(){
  5812. this.css('display','block');
  5813. return this;
  5814. };
  5815. /*
  5816. * hide
  5817. * 功能:隐藏节点
  5818. */
  5819. res.hide=function(){
  5820. this.css('display','none');
  5821. return this;
  5822. };
  5823. /*
  5824. animate
  5825. 功能:缓动效果
  5826. parameter:String=需要改变的属性:left,top,width,height,alpha,
  5827. totalTime:Number=运动的总毫秒数
  5828. easing:String=效果名称,
  5829. callBack:完成后的回调函数
  5830. */
  5831. res.animate=function(parameter,totalTime,easing,callBack) {
  5832. if(isUndefined(this.CK)){
  5833. return res;
  5834. }
  5835. var thisTemp = this;
  5836. var parNode=this.CK;
  5837. var w =parNode.getWidth(),h = parNode.getHeight();
  5838. var speed=10;//跳针时间
  5839. this.timerTween=null;
  5840. this.tweenPlay=true;
  5841. if(isUndefined(parameter)){
  5842. return this;
  5843. }
  5844. if (isUndefined(totalTime) || totalTime== 0) {
  5845. totalTime=1000;
  5846. }
  5847. if(isUndefined(easing) || easing==''){
  5848. easing='None.easeIn';
  5849. }
  5850. var effArr = easing.split('.');
  5851. var tween = {
  5852. None: { //均速运动
  5853. easeIn: function(t, b, c, d) {
  5854. return c * t / d + b;
  5855. },
  5856. easeOut: function(t, b, c, d) {
  5857. return c * t / d + b;
  5858. },
  5859. easeInOut: function(t, b, c, d) {
  5860. return c * t / d + b;
  5861. }
  5862. },
  5863. Quadratic: {
  5864. easeIn: function(t, b, c, d) {
  5865. return c * (t /= d) * t + b;
  5866. },
  5867. easeOut: function(t, b, c, d) {
  5868. return - c * (t /= d) * (t - 2) + b;
  5869. },
  5870. easeInOut: function(t, b, c, d) {
  5871. if ((t /= d / 2) < 1) return c / 2 * t * t + b;
  5872. return - c / 2 * ((--t) * (t - 2) - 1) + b;
  5873. }
  5874. },
  5875. Cubic: {
  5876. easeIn: function(t, b, c, d) {
  5877. return c * (t /= d) * t * t + b;
  5878. },
  5879. easeOut: function(t, b, c, d) {
  5880. return c * ((t = t / d - 1) * t * t + 1) + b;
  5881. },
  5882. easeInOut: function(t, b, c, d) {
  5883. if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
  5884. return c / 2 * ((t -= 2) * t * t + 2) + b;
  5885. }
  5886. },
  5887. Quartic: {
  5888. easeIn: function(t, b, c, d) {
  5889. return c * (t /= d) * t * t * t + b;
  5890. },
  5891. easeOut: function(t, b, c, d) {
  5892. return - c * ((t = t / d - 1) * t * t * t - 1) + b;
  5893. },
  5894. easeInOut: function(t, b, c, d) {
  5895. if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
  5896. return - c / 2 * ((t -= 2) * t * t * t - 2) + b;
  5897. }
  5898. },
  5899. Quintic: {
  5900. easeIn: function(t, b, c, d) {
  5901. return c * (t /= d) * t * t * t * t + b;
  5902. },
  5903. easeOut: function(t, b, c, d) {
  5904. return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
  5905. },
  5906. easeInOut: function(t, b, c, d) {
  5907. if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
  5908. return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
  5909. }
  5910. },
  5911. Sine: {
  5912. easeIn: function(t, b, c, d) {
  5913. return - c * Math.cos(t / d * (Math.PI / 2)) + c + b;
  5914. },
  5915. easeOut: function(t, b, c, d) {
  5916. return c * Math.sin(t / d * (Math.PI / 2)) + b;
  5917. },
  5918. easeInOut: function(t, b, c, d) {
  5919. return - c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
  5920. }
  5921. },
  5922. Exponential: {
  5923. easeIn: function(t, b, c, d) {
  5924. return (t == 0) ? b: c * Math.pow(2, 10 * (t / d - 1)) + b;
  5925. },
  5926. easeOut: function(t, b, c, d) {
  5927. return (t == d) ? b + c: c * ( - Math.pow(2, -10 * t / d) + 1) + b;
  5928. },
  5929. easeInOut: function(t, b, c, d) {
  5930. if (t == 0) return b;
  5931. if (t == d) return b + c;
  5932. if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
  5933. return c / 2 * ( - Math.pow(2, -10 * --t) + 2) + b;
  5934. }
  5935. },
  5936. Circular: {
  5937. easeIn: function(t, b, c, d) {
  5938. return - c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
  5939. },
  5940. easeOut: function(t, b, c, d) {
  5941. return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
  5942. },
  5943. easeInOut: function(t, b, c, d) {
  5944. if ((t /= d / 2) < 1) return - c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
  5945. return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
  5946. }
  5947. },
  5948. Elastic: {
  5949. easeIn: function(t, b, c, d, a, p) {
  5950. if (t == 0) return b;
  5951. if ((t /= d) == 1) return b + c;
  5952. if (!p) p = d * .3;
  5953. if (!a || a < Math.abs(c)) {
  5954. a = c;
  5955. var s = p / 4;
  5956. } else var s = p / (2 * Math.PI) * Math.asin(c / a);
  5957. return - (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
  5958. },
  5959. easeOut: function(t, b, c, d, a, p) {
  5960. if (t == 0) return b;
  5961. if ((t /= d) == 1) return b + c;
  5962. if (!p) p = d * .3;
  5963. if (!a || a < Math.abs(c)) {
  5964. a = c;
  5965. var s = p / 4;
  5966. } else var s = p / (2 * Math.PI) * Math.asin(c / a);
  5967. return (a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b);
  5968. },
  5969. easeInOut: function(t, b, c, d, a, p) {
  5970. if (t == 0) return b;
  5971. if ((t /= d / 2) == 2) return b + c;
  5972. if (!p) p = d * (.3 * 1.5);
  5973. if (!a || a < Math.abs(c)) {
  5974. a = c;
  5975. var s = p / 4;
  5976. } else var s = p / (2 * Math.PI) * Math.asin(c / a);
  5977. if (t < 1) return - .5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
  5978. return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
  5979. }
  5980. },
  5981. Back: {
  5982. easeIn: function(t, b, c, d, s) {
  5983. if (s == undefined) s = 1.70158;
  5984. return c * (t /= d) * t * ((s + 1) * t - s) + b;
  5985. },
  5986. easeOut: function(t, b, c, d, s) {
  5987. if (s == undefined) s = 1.70158;
  5988. return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
  5989. },
  5990. easeInOut: function(t, b, c, d, s) {
  5991. if (s == undefined) s = 1.70158;
  5992. if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
  5993. return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
  5994. }
  5995. },
  5996. Bounce: {
  5997. easeIn: function(t, b, c, d) {
  5998. return c - tween.Bounce.easeOut(d - t, 0, c, d) + b;
  5999. },
  6000. easeOut: function(t, b, c, d) {
  6001. if ((t /= d) < (1 / 2.75)) {
  6002. return c * (7.5625 * t * t) + b;
  6003. } else if (t < (2 / 2.75)) {
  6004. return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
  6005. } else if (t < (2.5 / 2.75)) {
  6006. return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
  6007. } else {
  6008. return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
  6009. }
  6010. },
  6011. easeInOut: function(t, b, c, d) {
  6012. if (t < d / 2){
  6013. return tween.Bounce.easeIn(t * 2, 0, c, d) * .5 + b;
  6014. }
  6015. else{
  6016. return tween.Bounce.easeOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
  6017. }
  6018. }
  6019. }
  6020. };
  6021. if(effArr.length!=2){
  6022. return null;
  6023. }
  6024. if (!(effArr[0] in tween)) {
  6025. return null;
  6026. }
  6027. if (!(effArr[1] in tween[effArr[0]])) {
  6028. return null;
  6029. }
  6030. var tweenFun = tween[effArr[0]][effArr[1]];
  6031. var getStartAndEnd=function(arr){//分析初始化位置和结束位置
  6032. var vars=arr[1];
  6033. var current=0,result=0;
  6034. switch (arr[0]) {
  6035. case 'width':
  6036. current = thisTemp.getWidth();
  6037. if (vars.substring(vars.length - 1, vars.length) == '%') {
  6038. result = parseInt(vars) * h * 0.01;
  6039. }
  6040. else{
  6041. result=parseInt(vars);
  6042. }
  6043. break;
  6044. case 'height':
  6045. current = thisTemp.getHeight();
  6046. if (vars.substring(vars.length - 1, vars.length) == '%') {
  6047. result = parseInt(vars) * h * 0.01;
  6048. }
  6049. else{
  6050. result=parseInt(vars);
  6051. }
  6052. break;
  6053. case 'left':
  6054. if(!isUndefined(thisTemp.css('left'))){
  6055. current=parseInt(thisTemp.css('left'));
  6056. }
  6057. else{
  6058. current = thisTemp.offset()['left']-parNode.offset()['left'];
  6059. }
  6060. if (vars.substring(vars.length - 1, vars.length) == '%') {
  6061. result = parseInt(vars) * w * 0.01;
  6062. }
  6063. else{
  6064. result=parseInt(vars);
  6065. }
  6066. thisTemp.css('right','auto');
  6067. break;
  6068. case 'right':
  6069. if(!isUndefined(thisTemp.css('right'))){
  6070. current=parseInt(thisTemp.css('right'));
  6071. }
  6072. else{
  6073. current = parNode.getWidth()-(thisTemp.offset()['left']-parNode.offset()['left']+thisTemp.getWidth());
  6074. }
  6075. if (vars.substring(vars.length - 1, vars.length) == '%') {
  6076. result = parseInt(vars) * w * 0.01;
  6077. }
  6078. else{
  6079. result=parseInt(vars);
  6080. }
  6081. thisTemp.css('left','auto');
  6082. break;
  6083. case 'top':
  6084. if(!isUndefined(thisTemp.css('top'))){
  6085. current=parseInt(thisTemp.css('top'));
  6086. }
  6087. else{
  6088. current = thisTemp.offset()['top']-parNode.offset()['top'];
  6089. }
  6090. if (vars.substring(vars.length - 1, vars.length) == '%') {
  6091. result = parseInt(vars) * h * 0.01;
  6092. }
  6093. else{
  6094. result=parseInt(vars);
  6095. }
  6096. thisTemp.css('bottom','auto');
  6097. break;
  6098. case 'bottom':
  6099. if(!isUndefined(thisTemp.css('bottom'))){
  6100. current=parseInt(thisTemp.css('bottom'));
  6101. }
  6102. else{
  6103. current = parNode.getHeight()-(thisTemp.offset()['top']-parNode.offset()['top']+thisTemp.getHeight());
  6104. }
  6105. if (vars.substring(vars.length - 1, vars.length) == '%') {
  6106. result = parseInt(vars) * h * 0.01;
  6107. }
  6108. else{
  6109. result=parseInt(vars);
  6110. }
  6111. thisTemp.css('top','auto');
  6112. break;
  6113. case 'alpha':
  6114. if(!isUndefined(thisTemp.css('filter')) && thisTemp.css('filter')!='none'){
  6115. current=Number(thisTemp.css('filter'))*100;
  6116. }
  6117. else if(!isUndefined(thisTemp.css('opacity')) && thisTemp.css('opacity')!='none'){
  6118. current=thisTemp.css('opacity')*100;
  6119. }
  6120. else{
  6121. current = 100;
  6122. }
  6123. if (vars.substring(vars.length - 1, vars.length) == '%') {
  6124. result = parseInt(vars);
  6125. }
  6126. else{
  6127. result=vars*100;
  6128. }
  6129. break;
  6130. }
  6131. result-=current;
  6132. if(current!=result){
  6133. return {
  6134. 'type':arr[0],
  6135. 'current':current,
  6136. 'result':result
  6137. };
  6138. }
  6139. return null;
  6140. };
  6141. var stopTween = function() {
  6142. if (thisTemp.timerTween != null) {
  6143. clearInterval(thisTemp.timerTween);
  6144. thisTemp.timerTween = null;
  6145. }
  6146. };
  6147. parameter=parameter.replace(/[ ]*,[ ]*|[ ]+/g, ';');
  6148. var newCss=[];
  6149. var parameterArr=parameter.split(';');
  6150. for(var i=0;i<parameterArr.length;i++){
  6151. var cssArr=parameterArr[i].split(':');
  6152. if(cssArr.length==2){
  6153. var temp=getStartAndEnd(cssArr);
  6154. if(temp){
  6155. newCss.push(temp)
  6156. }
  6157. }
  6158. }
  6159. var funTime=0;
  6160. var timeFun=function(){
  6161. var styleObj={};
  6162. if(thisTemp.tweenPlay){
  6163. if (funTime < totalTime) {
  6164. funTime += speed;
  6165. for(var i=0;i<newCss.length;i++){
  6166. var ob=newCss[i];
  6167. var ap =Math.ceil(tweenFun(funTime, ob['current'], ob['result'], totalTime));
  6168. switch(ob['type']){
  6169. case 'width':
  6170. styleObj['width']=ap + 'px';
  6171. styleObj['overflow']='hidden';
  6172. break;
  6173. case 'height':
  6174. styleObj['height']=ap + 'px';
  6175. styleObj['overflow']='hidden';
  6176. break;
  6177. case 'left':
  6178. styleObj['left']=ap + 'px';
  6179. break;
  6180. case 'right':
  6181. styleObj['right']=ap + 'px';
  6182. break;
  6183. case 'top':
  6184. styleObj['top']=ap + 'px';
  6185. break;
  6186. case 'bottom':
  6187. styleObj['bottom']=ap + 'px';
  6188. break;
  6189. case 'alpha':
  6190. styleObj['filter']='alpha(opacity:' + ap*0.01 + ')';
  6191. styleObj['opacity']=ap*0.01;
  6192. break;
  6193. }
  6194. }
  6195. thisTemp.css(styleObj);
  6196. }
  6197. else{
  6198. stopTween();
  6199. if(!isUndefined(callBack)){
  6200. callBack(thisTemp);
  6201. }
  6202. }
  6203. }
  6204. };
  6205. stopTween();
  6206. this.timerTween=setInterval(timeFun,speed);
  6207. return this;
  6208. };
  6209. /*
  6210. * animatePlay
  6211. * 功能:播放缓动动画
  6212. */
  6213. res.animatePlay=function(){
  6214. if(!isUndefined(this.timerTween)){
  6215. this.tweenPlay=true;
  6216. }
  6217. return this;
  6218. };
  6219. /*
  6220. * animatePause
  6221. * 功能:暂停缓动动画
  6222. */
  6223. res.animatePause=function(){
  6224. if(!isUndefined(this.timerTween)){
  6225. this.tweenPlay=false;
  6226. }
  6227. return this;
  6228. };
  6229. } else {
  6230. /*
  6231. * each
  6232. * 功能:当相同节点数量大于0时,使用该函数可以进行循环节点
  6233. * @fn:循环节点时执行的函数
  6234. */
  6235. res.each = function(fn) {
  6236. for (var i in this) {
  6237. if (this.hasOwnProperty(i)) {
  6238. if (valType(this[i]) == 'htmlobject') {
  6239. fn(i, this[i]);
  6240. } else {
  6241. try {
  6242. if (!this[0].nodeName) fn(i, this[i]);
  6243. } catch (e) {
  6244. fn(i, this[i]);
  6245. }
  6246. }
  6247. }
  6248. }
  6249. };
  6250. /*
  6251. * eq
  6252. * 功能:根据索引返回指定节点
  6253. * @m:为索引数字
  6254. */
  6255. res.eq = function(m) {
  6256. if (valType(this) == 'htmlarray') {
  6257. if (this.length >= m + 1) {
  6258. return this[m];
  6259. }
  6260. return null;
  6261. }
  6262. return null;
  6263. };
  6264. for (var i = 0; i < res.length; i++) {
  6265. if ($) {
  6266. try {
  6267. res[i] = $(res[i]);
  6268. } catch (event) {}
  6269. }
  6270. }
  6271. }
  6272. }
  6273. return res;
  6274. },
  6275. /*
  6276. * createlDiv
  6277. * 功能:新建一个DIV节点
  6278. */
  6279. createlDiv=function(className,html) {
  6280. var ele = document.createElement('div');
  6281. var eleObject = $(ele);
  6282. if (className) {
  6283. eleObject.addClass(className);
  6284. }
  6285. if(html){
  6286. eleObject.htm(html);
  6287. }
  6288. return eleObject;
  6289. },
  6290. /*
  6291. * createlVideo
  6292. * 功能:新建一个video节点
  6293. */
  6294. createlVideo=function() {
  6295. var ele = document.createElement('video');
  6296. var eleObject = $(ele);
  6297. return eleObject;
  6298. },
  6299. /*
  6300. * createlButton
  6301. * 功能新建一个button节点
  6302. */
  6303. createlButton=function(className,html) {
  6304. var ele = document.createElement('button');
  6305. var eleObject = $(ele);
  6306. eleObject.attr('type','button');
  6307. if (className) {
  6308. eleObject.addClass(className);
  6309. }
  6310. if(html){
  6311. eleObject.htm(html);
  6312. }
  6313. return eleObject;
  6314. },
  6315. /*
  6316. * createlA
  6317. * 功能新建一个a节点
  6318. */
  6319. createlA=function(html,href,className) {
  6320. var ele = document.createElement('a');
  6321. var eleObject = $(ele);
  6322. if(html){
  6323. eleObject.htm(html);
  6324. }
  6325. if(!isUndefined(href) && href){
  6326. eleObject.attr('href',href);
  6327. eleObject.attr('target','_blank');
  6328. }
  6329. if (className) {
  6330. eleObject.addClass(className);
  6331. }
  6332. return eleObject;
  6333. },
  6334. /*
  6335. * createlJsLink
  6336. * 功能新建一个a节点
  6337. */
  6338. createlJsLink=function(html,js) {
  6339. var ele = document.createElement('a');
  6340. var eleObject = $(ele);
  6341. if(html){
  6342. eleObject.htm(html);
  6343. }
  6344. if(!isUndefined(js) && js){
  6345. eleObject.attr('href','javascript:'+js+'()');
  6346. }
  6347. else{
  6348. eleObject.attr('href','javascript:;');
  6349. }
  6350. return eleObject;
  6351. },
  6352. /*
  6353. * createlImg
  6354. * 功能新建一个img节点
  6355. */
  6356. createlImg=function(file,className) {
  6357. var ele = document.createElement('img');
  6358. var eleObject = $(ele);
  6359. if (className) {
  6360. ele.className = className;
  6361. }
  6362. if(file){
  6363. ele.src=file;
  6364. }
  6365. return eleObject;
  6366. },
  6367. /*
  6368. * getClient
  6369. * 功能:获取clientX和clientY
  6370. */
  6371. getClient=function(event) {
  6372. var eve = event || window.event;
  6373. if (isUndefined(eve)) {
  6374. eve = {
  6375. clientX: 0,
  6376. clientY: 0
  6377. };
  6378. }
  6379. var x=eve.clientX + (document.documentElement.scrollLeft || $('body').scrollLeft),
  6380. y=eve.clientY + (document.documentElement.scrollTop || $('body').scrollTop);
  6381. if(isUndefined(x.toString()) || x.toString()=='NaN'){
  6382. x=eve.touches[0].clientX
  6383. }
  6384. if(isUndefined(y.toString()) || y.toString()=='NaN'){
  6385. y=eve.touches[0].clientY
  6386. }
  6387. if(x.toString()=='NaN'){
  6388. x=0;
  6389. }
  6390. if(y.toString()=='NaN'){
  6391. y=0;
  6392. }
  6393. return {
  6394. x: x,
  6395. y: y
  6396. }
  6397. },
  6398. /*
  6399. * getLiveTime
  6400. * 功能:获取直播回放时间
  6401. */
  6402. getLiveTime=function(){
  6403. var notTime=Date.now();
  6404. var varsTime=vars['live'];
  6405. if(varsTime.toString().length<13){
  6406. varsTime=varsTime*1000;
  6407. }
  6408. return notTime-varsTime;
  6409. },
  6410. /*
  6411. * formatLiveTime
  6412. * 功能:将直播的时间戳格式化成标准时间
  6413. */
  6414. formatLiveTime=function(time){
  6415. var varsTime=vars['live'];
  6416. if(varsTime.toString().length<13){
  6417. varsTime=varsTime*1000;
  6418. }
  6419. varsTime+=time;
  6420. return language['lookBack']+date('H:i:s',varsTime);
  6421. },
  6422. /*
  6423. * loadJs
  6424. * 功能:加载js文件并在加载完成后执行callback函数
  6425. * @file:js文件地址
  6426. * @callback:加载完成后执行的函数
  6427. */
  6428. loadJs=function(file, callback) {
  6429. var fn =function() {};
  6430. if(!isUndefined(callback)){
  6431. fn=callback;
  6432. }
  6433. if(checkJs(file)){
  6434. fn();
  6435. return;
  6436. }
  6437. var script = document.createElement('script');
  6438. script.type = 'text/javascript';
  6439. var isReady = false;
  6440. var timer = null;
  6441. var doReady = function() {
  6442. if(timer){
  6443. clearInterval(timer);
  6444. }
  6445. if(isReady) return;
  6446. isReady = true;
  6447. if(valType(fn) == 'function') {
  6448. fn();
  6449. }
  6450. };
  6451. var bodyLoad = function() {
  6452. timer = setInterval(function() {
  6453. try {
  6454. if(!isUndefined(script.readyState) && script.readyState == 'complete') {
  6455. doReady();
  6456. }
  6457. } catch(event) {};
  6458. }, 10);
  6459. };
  6460. var w3c = function() {
  6461. if(valType(fn) == 'function') {
  6462. fn();
  6463. }
  6464. removeListener(script, 'load', w3c);
  6465. removeListener(script, 'error', w3cError);
  6466. };
  6467. var w3cError = function() {
  6468. if(valType(fn) == 'function') {
  6469. fn();
  6470. }
  6471. removeListener(script, 'load', w3c);
  6472. removeListener(script, 'error', w3cError);
  6473. };
  6474. try {
  6475. addListener(script, 'load', w3c);
  6476. addListener(script, 'error', w3cError);
  6477. } catch(event) {
  6478. bodyLoad();
  6479. }
  6480. script.src = file;
  6481. $('head').eq(0).append(script);
  6482. },
  6483. /*
  6484. * doubleClickEvent
  6485. * 功能:注册对象双击功能
  6486. * @ele:注册对象,可以是页面中的任意节点,不支持数组形式
  6487. */
  6488. doubleClickEvent=function(ele){
  6489. var setTime=null;//注册延时函数
  6490. var clickTime=0;//记录点击时间
  6491. ele=$(ele);
  6492. ele.click(function(){
  6493. if(!setTime){
  6494. setTime=setTimeout(function(){
  6495. try{
  6496. ele.dispatchEvent(new Event('sigClick'));//注册单击,针对视频播放器使用
  6497. }
  6498. catch(event){
  6499. var e = document.createEvent('HTMLEvents');
  6500. e.initEvent('sigClick', false, true);
  6501. ele.dispatchEvent(e);
  6502. }
  6503. clickTime=0;
  6504. setTime=null;
  6505. },260);
  6506. }
  6507. if(!clickTime){
  6508. clickTime=new Date().getTime();
  6509. }
  6510. else{
  6511. if(new Date().getTime()-clickTime<230){//认为是双击
  6512. try{
  6513. ele.dispatchEvent(new Event('dobClick'));//注册双击
  6514. }
  6515. catch(event){
  6516. var e = document.createEvent('HTMLEvents');
  6517. e.initEvent('dobClick', false, true);
  6518. ele.dispatchEvent(e);
  6519. }
  6520. clearTimeout(setTime);
  6521. clickTime=0;
  6522. setTime=null;
  6523. }
  6524. }
  6525. });
  6526. },
  6527. /*
  6528. * noScrolling
  6529. * 功能,禁止页面滚动操作
  6530. */
  6531. noScrolling=function(b){
  6532. if(isUndefined(b)) b=false;
  6533. var bodyScroll=function (event){
  6534. event.preventDefault();
  6535. };
  6536. if(b){ //禁止滚动
  6537. $('body').addListener('touchmove', bodyScroll, {passive: false });
  6538. }
  6539. else{ //开启滚动
  6540. $('body').removeListener('touchmove',bodyScroll, {passive: false});
  6541. }
  6542. };
  6543. return into(videoObj);
  6544. }
  6545. /*
  6546. * ajax
  6547. * 功能:ajax功能
  6548. * @cObj:传递的参数,包含请求地址,请求类型,编码等
  6549. */
  6550. function ajax(cObj) {
  6551. var callback = null;
  6552. var obj = {
  6553. method: 'get',//请求类型
  6554. dataType: 'json',//请求的数据类型
  6555. charset: 'utf-8',
  6556. async: true,//true表示异步,false表示同步
  6557. url: '',
  6558. data: null,
  6559. success: null,
  6560. error:null
  6561. };
  6562. obj = standardization(obj, cObj);
  6563. if (isUndefined(obj['url'])) {
  6564. return;
  6565. }
  6566. /*
  6567. * errorFun
  6568. *功能:执行error
  6569. */
  6570. var errorFun=function(info){
  6571. if(!isUndefined(obj['error']) && valType(obj['error'])=='function'){
  6572. obj['error'](info);
  6573. }
  6574. else{
  6575. obj['success'](null);
  6576. }
  6577. };
  6578. /*
  6579. * successFun
  6580. *功能:执行success
  6581. */
  6582. var successFun=function(success){
  6583. if(!isUndefined(obj['success']) && valType(obj['success'])=='function'){
  6584. obj['success'](success);
  6585. }
  6586. };
  6587. /*
  6588. * createXHR
  6589. *功能:用来为ajax函数提供支持
  6590. */
  6591. var createXHR=function() {
  6592. if (window.XMLHttpRequest) {
  6593. return new XMLHttpRequest();
  6594. } else if (window.ActiveXObject) {
  6595. try {
  6596. return new ActiveXObject('Microsoft.XMLHTTP');
  6597. } catch(event) {
  6598. try {
  6599. return new ActiveXObject('Msxml2.XMLHTTP');
  6600. } catch(event) {}
  6601. }
  6602. }
  6603. };
  6604. /*
  6605. * formatParams
  6606. * 功能:将对象转成地址字符串,为ajax函数提供支持
  6607. * @obj:传递一个对象
  6608. */
  6609. var formatParams=function(obj) {
  6610. var arr = [];
  6611. for (var key in obj) {
  6612. arr.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]));
  6613. }
  6614. return arr.join('&');
  6615. };
  6616. if (valType(cObj) != 'object') {
  6617. if(!isUndefined(obj['error'])){
  6618. obj.error(event);
  6619. }
  6620. return;
  6621. }
  6622. if (obj.dataType === 'json' || obj.dataType === 'text' || obj.dataType === 'html' || obj.dataType === 'xml') {
  6623. var xhr = createXHR();
  6624. callback = function() {
  6625. //判断http的交互是否成功
  6626. if (xhr.status === 200) {
  6627. if (obj.dataType === 'json') {
  6628. try {
  6629. successFun(eval('(' + xhr.responseText + ')')); //回调传递参数
  6630. }
  6631. catch(event) {
  6632. successFun(null);
  6633. }
  6634. } else {
  6635. successFun(xhr.responseText); //回调传递参数
  6636. }
  6637. }
  6638. else {
  6639. errorFun({code:xhr.status,message:xhr.statusText});
  6640. }
  6641. };
  6642. obj.data = formatParams(obj.data); //通过params()将名值对转换成字符串
  6643. if (obj.method === 'get' && !isUndefined(obj.data)) {
  6644. if (obj.data != '') {
  6645. if (obj.url.indexOf('?') == -1) {
  6646. obj.url += '?' + obj.data
  6647. } else {
  6648. obj.url += '&' + obj.data;
  6649. }
  6650. }
  6651. }
  6652. if (obj.async === true) { //true表示异步,false表示同步
  6653. addListener(xhr,'readystatechange',function(event){
  6654. if (this.readyState === 4 && callback != null) { //判断对象的状态是否交互完成
  6655. callback(); //回调
  6656. }
  6657. });
  6658. }
  6659. xhr.open(obj.method, obj.url, obj.async);
  6660. if (obj.method === 'post') {
  6661. try{
  6662. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  6663. xhr.setRequestHeader('charset', obj['charset']);
  6664. xhr.send(obj.data);
  6665. }
  6666. catch(event){
  6667. callback();
  6668. }
  6669. }
  6670. else {
  6671. try{
  6672. xhr.send(null); //get方式则填null
  6673. }
  6674. catch(event){
  6675. callback();
  6676. }
  6677. }
  6678. if (obj.async === false) { //同步
  6679. callback();
  6680. }
  6681. }
  6682. else if (obj.dataType === 'jsonp') {
  6683. var oHead = document.getElementsByTagName('head')[0];
  6684. var oScript = document.createElement('script');
  6685. var callbackName = 'callback' + new Date().getTime();
  6686. var params = formatParams(obj.data) + '&callback=' + callbackName; //按时间戳拼接字符串
  6687. //拼接好src
  6688. oScript.src = obj.url.split('?') + '?' + params;
  6689. //插入script标签
  6690. oHead.insertBefore(oScript, oHead.firstChild);
  6691. //jsonp的回调函数
  6692. window[callbackName] = function(json) {
  6693. if(!isUndefined(obj['success']) && valType(obj['success'])==='function'){
  6694. obj['success'](json);
  6695. }
  6696. oHead.removeChild(oScript);
  6697. };
  6698. }
  6699. }
  6700. /*
  6701. * documentReady
  6702. * 功能:判断页面加载完成
  6703. * @fn:页面加载完成后执行的函数
  6704. */
  6705. function documentReady(fn) {
  6706. var isReady = false;
  6707. var timer = null;
  6708. var doReady = function() {
  6709. if(timer) clearInterval(timer);
  6710. if(isReady) return;
  6711. isReady = true;
  6712. if(valType(fn) == 'function') {
  6713. fn();
  6714. }
  6715. };
  6716. var bodyLoad = function() {
  6717. timer = setInterval(function() {
  6718. try {
  6719. if(!isUndefined(document.readyState) && document.readyState == 'complete') {
  6720. doReady();
  6721. }
  6722. } catch(event) {};
  6723. }, 10);
  6724. };
  6725. var w3c = function() {
  6726. if(valType(fn) == 'function') {
  6727. fn();
  6728. }
  6729. removeListener(window, 'load', w3c);
  6730. };
  6731. if(!isUndefined(document.body)){
  6732. if(valType(fn) == 'function') {
  6733. fn();
  6734. }
  6735. }
  6736. else{
  6737. try {
  6738. addListener(window, 'load', w3c);
  6739. } catch(event) {
  6740. bodyLoad();
  6741. }
  6742. }
  6743. }
  6744. /*
  6745. * getPath
  6746. * 功能:获取该js文件所在路径
  6747. */
  6748. function getPath(siz) {
  6749. var scriptList = document.scripts,
  6750. thisPath = scriptList[scriptList.length - 1].src;
  6751. for (var i = 0; i < scriptList.length; i++) {
  6752. var scriptName = scriptList[i].getAttribute('name') || scriptList[i].getAttribute('data-name');
  6753. var src = scriptList[i].src.slice(scriptList[i].src.lastIndexOf('/') + 1, scriptList[i].src.lastIndexOf('.'));
  6754. if ((scriptName && (scriptName == 'ckplayer' || scriptName == 'ckplayer.min')) || (scriptList[i].src && (src == 'ckplayer' || src == 'ckplayer.min'))) {
  6755. thisPath = scriptList[i].src;
  6756. break;
  6757. }
  6758. }
  6759. var path=thisPath.substring(0, thisPath.lastIndexOf('/js/') + 1);
  6760. if(!isUndefined(siz)){
  6761. path+=siz+'/';
  6762. }
  6763. return path;
  6764. }
  6765. /*
  6766. * checkJs
  6767. * 功能:判断js是否已加载
  6768. * @file:js文件路径
  6769. */
  6770. function checkJs(file) {
  6771. var scriptList = document.scripts;
  6772. for (var i = 0; i < scriptList.length; i++) {
  6773. if(scriptList[i].src==file){
  6774. return scriptList[i];
  6775. }
  6776. }
  6777. return false;
  6778. }
  6779. /*
  6780. * getMaxZIndex
  6781. * 功能:获取当前页面最大深度
  6782. */
  6783. function getMaxZIndex() {
  6784. var arr = document.all || document.querySelectorAll('*');
  6785. var maxZ = -1;
  6786. for (var i = 0; i < arr.length; i++) {
  6787. var temp = null;
  6788. try {
  6789. temp = window.getComputedStyle(arr[i], null).zIndex;
  6790. } catch (event) {
  6791. if (arr[i].style) {
  6792. temp = arr[i].style.zIndex;
  6793. }
  6794. }
  6795. if (temp != 'auto' && parseInt(temp) > maxZ) {
  6796. maxZ = parseInt(temp);
  6797. }
  6798. }
  6799. return maxZ;
  6800. }
  6801. /*
  6802. * getWindowSize
  6803. * 功能:获取window的宽和高
  6804. */
  6805. function getWindowSize() {
  6806. return {
  6807. width: window.innerWidth,
  6808. height: window.innerHeight
  6809. };
  6810. }
  6811. /*
  6812. * standardization
  6813. * 功能:将对象Object标准化,将n对象替换进o对象
  6814. * @o:标准化对象,@n:外部传递对象
  6815. */
  6816. function standardization(o, n) { //n替换进o
  6817. var h = {};
  6818. var k;
  6819. for (k in o) {
  6820. h[k] = o[k];
  6821. }
  6822. for (k in n) {
  6823. if(k in h){
  6824. h[k] = n[k];
  6825. }
  6826. }
  6827. return h;
  6828. }
  6829. /*
  6830. * mergeObj
  6831. * 功能:将新对象合并到原对象中,需要确保原对像里有对应的值并且类型一样
  6832. * @o:原对象,@n:新对象
  6833. */
  6834. function mergeObj(o,n){
  6835. var h = {};
  6836. var k;
  6837. for (k in o) {
  6838. h[k] = o[k];
  6839. }
  6840. for (k in n) {
  6841. if(k in h){
  6842. switch(valType(h[k])){
  6843. case 'object':
  6844. if(valType(n[k])=='object'){
  6845. h[k] = mergeObj(h[k],n[k]);
  6846. }
  6847. break;
  6848. default:
  6849. if(valType(h[k])==valType(n[k])){
  6850. h[k] = n[k];
  6851. }
  6852. break;
  6853. }
  6854. }
  6855. }
  6856. return h;
  6857. }
  6858. /*
  6859. * valType
  6860. * 功能:判断变量类型
  6861. */
  6862. function valType(val) {
  6863. if(typeof val==='undefined') return 'undefined';
  6864. var str=Object.prototype.toString.call(val).split(' ')[1].replace(']','').toLowerCase();
  6865. if(str.substr(0,4)=='html' && (str.substr(-7)=='element' || str.substr(-8)=='document' || str=='window')){
  6866. str='htmlobject';
  6867. }
  6868. if(str=='htmlcollection' || str=='nodelist'){
  6869. str='htmlarray';
  6870. }
  6871. return str;
  6872. }
  6873. /*
  6874. * isUndefined
  6875. * 功能:判断变量是否存在或值是否为undefined
  6876. */
  6877. function isUndefined(val) {
  6878. try {
  6879. return valType(val)==='undefined' || val === undefined || val === null || (valType(val)==='number' && isNaN(val));
  6880. } catch (event) {
  6881. return true;
  6882. }
  6883. return false;
  6884. }
  6885. /*
  6886. * prev
  6887. * 功能:获取指定节点前一个同胞节点
  6888. * @ele:要获取的节点
  6889. */
  6890. function prev(ele) {
  6891. var e = ele.previousSibling;
  6892. if (e == null) { //测试同胞节点是否存在,否则返回空
  6893. return null;
  6894. }
  6895. if (e.nodeType == 3) { //如果同胞节点为文本节点
  6896. var t = prev(e);
  6897. if (t && t.nodeType == 1) {
  6898. return t;
  6899. }
  6900. } else {
  6901. if (e.nodeType == 1) { //确认节点为节点节点才返回
  6902. return e;
  6903. } else {
  6904. return false;
  6905. }
  6906. }
  6907. }
  6908. /*
  6909. * next
  6910. * 功能:获取指定节点下一个同胞节点
  6911. * @ele:要获取的节点
  6912. */
  6913. function next(ele) {
  6914. var e = ele.nextSibling;
  6915. if (e == null) { //测试同胞节点是否存在,否则返回空
  6916. return null;
  6917. }
  6918. if (e.nodeType == 3) { //如果同胞节点为文本节点
  6919. var t = next(e);
  6920. if (t && t.nodeType == 1) {
  6921. return t;
  6922. }
  6923. } else {
  6924. if (e.nodeType == 1) { //确认节点为节点才返回
  6925. return e;
  6926. } else {
  6927. return false;
  6928. }
  6929. }
  6930. }
  6931. /*
  6932. * addListener
  6933. * 功能:事件监听
  6934. * @ele:监听对象,@e:事件名称,@f:返回事件函数
  6935. */
  6936. function addListener(ele, e, f, t) {
  6937. if (isUndefined(t)) {
  6938. t = false;
  6939. }
  6940. if (ele.addEventListener) {
  6941. try {
  6942. ele.addEventListener(e, f, t);
  6943. } catch (event) {}
  6944. } else if (ele.attachEvent) {
  6945. try {
  6946. ele.attachEvent('on' + e, f);
  6947. } catch (event) {}
  6948. } else {
  6949. ele['on' + e] = f;
  6950. }
  6951. if(isUndefined(ele.listenerList)){
  6952. ele.listenerList=[];
  6953. }
  6954. ele.listenerList.push([e,f]);
  6955. return ele;
  6956. };
  6957. /*
  6958. * removeListener
  6959. * 功能:删除事件监听
  6960. * @ele:监听对象,@e:事件名称,@f:返回事件函数
  6961. */
  6962. function removeListener(ele, e, f, t) {
  6963. if (isUndefined(t)) {
  6964. t = false;
  6965. }
  6966. if (ele.removeEventListener) {
  6967. try {
  6968. ele.removeEventListener(e, f, t);
  6969. } catch (e) {}
  6970. } else if (ele.detachEvent) {
  6971. try {
  6972. ele.detachEvent('on' + e, f);
  6973. } catch (e) {}
  6974. } else {
  6975. ele['on' + e] = null;
  6976. }
  6977. if(!isUndefined(ele.listenerList)){
  6978. var temp=[];
  6979. for(var i=0;i<ele.listenerList.length;i++){
  6980. if(ele.listenerList[i][0]!=e || ele.listenerList[i][1]!=f){
  6981. temp.push(ele.listenerList[i]);
  6982. }
  6983. }
  6984. ele.listenerList=temp;
  6985. }
  6986. return ele;
  6987. }
  6988. /*
  6989. * formatSeconds
  6990. * 功能:將秒转化成时分秒
  6991. */
  6992. function formatSeconds(val) {
  6993. if(isUndefined(val)) val=0;
  6994. var result = parseInt(val);
  6995. if(isUndefined(result)) result=0;
  6996. if(result<0) result=0;
  6997. var h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600),
  6998. m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60)),
  6999. s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60)),
  7000. res = '';
  7001. if(h !== '00') res += h+':';
  7002. res += m+':'+s;
  7003. return res;
  7004. }
  7005. /*
  7006. * date
  7007. * 功能:格式化的时间字符串
  7008. */
  7009. function date(format, timestamp) {
  7010. if(isUndefined(timestamp)){
  7011. timestamp=new Date();
  7012. }
  7013. if(timestamp.toString().length<13) timestamp=timestamp*1000;
  7014. var a, jsdate = ((timestamp) ? new Date(timestamp) : new Date());
  7015. var pad = function(n, c) {
  7016. if((n = n + '').length < c) {
  7017. return new Array(++c - n.length).join('0') + n;
  7018. } else {
  7019. return n;
  7020. }
  7021. };
  7022. var txt_weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
  7023. var txt_ordin = {
  7024. 1: 'st',
  7025. 2: 'nd',
  7026. 3: 'rd',
  7027. 21: 'st',
  7028. 22: 'nd',
  7029. 23: 'rd',
  7030. 31: 'st'
  7031. };
  7032. var txt_months = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
  7033. var f = {
  7034. // Day
  7035. d: function() {
  7036. return pad(f.j(), 2)
  7037. },
  7038. D: function() {
  7039. return f.l().substr(0, 3)
  7040. },
  7041. j: function() {
  7042. return jsdate.getDate()
  7043. },
  7044. l: function() {
  7045. return txt_weekdays[f.w()]
  7046. },
  7047. N: function() {
  7048. return f.w() + 1
  7049. },
  7050. S: function() {
  7051. return txt_ordin[f.j()] ? txt_ordin[f.j()] : 'th'
  7052. },
  7053. w: function() {
  7054. return jsdate.getDay()
  7055. },
  7056. z: function() {
  7057. return(jsdate - new Date(jsdate.getFullYear() + '/1/1')) / 864e5 >> 0
  7058. },
  7059. // Week
  7060. W: function() {
  7061. var a = f.z(),
  7062. b = 364 + f.L() - a;
  7063. var nd2, nd = (new Date(jsdate.getFullYear() + '/1/1').getDay() || 7) - 1;
  7064. if(b <= 2 && ((jsdate.getDay() || 7) - 1) <= 2 - b) {
  7065. return 1;
  7066. } else {
  7067. if(a <= 2 && nd >= 4 && a >= (6 - nd)) {
  7068. nd2 = new Date(jsdate.getFullYear() - 1 + '/12/31');
  7069. return date('W', Math.round(nd2.getTime() / 1000));
  7070. } else {
  7071. return(1 + (nd <= 3 ? ((a + nd) / 7) : (a - (7 - nd)) / 7) >> 0);
  7072. }
  7073. }
  7074. },
  7075. // Month
  7076. F: function() {
  7077. return txt_months[f.n()]
  7078. },
  7079. m: function() {
  7080. return pad(f.n(), 2)
  7081. },
  7082. M: function() {
  7083. return f.F().substr(0, 3)
  7084. },
  7085. n: function() {
  7086. return jsdate.getMonth() + 1
  7087. },
  7088. t: function() {
  7089. var n;
  7090. if((n = jsdate.getMonth() + 1) == 2) {
  7091. return 28 + f.L();
  7092. } else {
  7093. if(n & 1 && n < 8 || !(n & 1) && n > 7) {
  7094. return 31;
  7095. } else {
  7096. return 30;
  7097. }
  7098. }
  7099. },
  7100. // Year
  7101. L: function() {
  7102. var y = f.Y();
  7103. return(!(y & 3) && (y % 1e2 || !(y % 4e2))) ? 1 : 0
  7104. },
  7105. //o not supported yet
  7106. Y: function() {
  7107. return jsdate.getFullYear()
  7108. },
  7109. y: function() {
  7110. return(jsdate.getFullYear() + '').slice(2)
  7111. },
  7112. // Time
  7113. a: function() {
  7114. return jsdate.getHours() > 11 ? 'pm' : 'am'
  7115. },
  7116. A: function() {
  7117. return f.a().toUpperCase()
  7118. },
  7119. B: function() {
  7120. // peter paul koch:
  7121. var off = (jsdate.getTimezoneOffset() + 60) * 60;
  7122. var theSeconds = (jsdate.getHours() * 3600) + (jsdate.getMinutes() * 60) + jsdate.getSeconds() + off;
  7123. var beat = Math.floor(theSeconds / 86.4);
  7124. if(beat > 1000) beat -= 1000;
  7125. if(beat < 0) beat += 1000;
  7126. if((String(beat)).length == 1) beat = '00' + beat;
  7127. if((String(beat)).length == 2) beat = '0' + beat;
  7128. return beat;
  7129. },
  7130. g: function() {
  7131. return jsdate.getHours() % 12 || 12
  7132. },
  7133. G: function() {
  7134. return jsdate.getHours()
  7135. },
  7136. h: function() {
  7137. return pad(f.g(), 2)
  7138. },
  7139. H: function() {
  7140. return pad(jsdate.getHours(), 2)
  7141. },
  7142. i: function() {
  7143. return pad(jsdate.getMinutes(), 2)
  7144. },
  7145. s: function() {
  7146. return pad(jsdate.getSeconds(), 2)
  7147. },
  7148. //u not supported yet
  7149. // Timezone
  7150. //e not supported yet
  7151. //I not supported yet
  7152. O: function() {
  7153. var t = pad(Math.abs(jsdate.getTimezoneOffset() / 60 * 100), 4);
  7154. if(jsdate.getTimezoneOffset() > 0) t = '-' + t;
  7155. else t = '+' + t;
  7156. return t;
  7157. },
  7158. P: function() {
  7159. var O = f.O();
  7160. return(O.substr(0, 3) + ':' + O.substr(3, 2))
  7161. },
  7162. //T not supported yet
  7163. //Z not supported yet
  7164. // Full Date/Time
  7165. c: function() {
  7166. return f.Y() + '-' + f.m() + '-' + f.d() + 'T' + f.h() + ':' + f.i() + ':' + f.s() + f.P()
  7167. },
  7168. //r not supported yet
  7169. U: function() {
  7170. return Math.round(jsdate.getTime() / 1000)
  7171. }
  7172. };
  7173. return format.replace(/([a-zA-Z])/g,function(t, s) {
  7174. var ret='';
  7175. if(t != s) {
  7176. // escaped
  7177. ret = s;
  7178. } else if(f[s]) {
  7179. // a date function exists
  7180. ret = f[s]();
  7181. } else {
  7182. // nothing special
  7183. ret = s;
  7184. }
  7185. return ret;
  7186. });
  7187. }
  7188. /*
  7189. * dataURLtoBlob
  7190. * 功能,base64转blob
  7191. */
  7192. function dataURLtoBlob(dataurl) {
  7193. var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
  7194. while (n--) {
  7195. u8arr[n] = bstr.charCodeAt(n);
  7196. }
  7197. return new Blob([u8arr], { type: mime });
  7198. }
  7199. /*
  7200. * decodeURIString
  7201. * 功能,解码中文
  7202. */
  7203. function decodeURIString(obj){
  7204. for(var k in obj){
  7205. if(valType(obj[k])=='string' && obj[k]){
  7206. try{
  7207. obj[k]=decodeURI(obj[k]);
  7208. }
  7209. catch(event){}
  7210. }
  7211. if(valType(obj[k])=='object'){
  7212. obj[k]=decodeURIString(obj[k]);
  7213. }
  7214. }
  7215. return obj;
  7216. }
  7217. /*
  7218. * getApp
  7219. * 功能,获取平台类型是否是iphone
  7220. */
  7221. function getApp(){
  7222. var u = navigator.userAgent.toLowerCase();
  7223. if(u.indexOf('iphone')>-1){
  7224. return 'iphone';
  7225. }
  7226. }
  7227. /*
  7228. * cookie
  7229. * 功能,操作cookie
  7230. */
  7231. function cookie(name,value,domain,path){
  7232. if(isUndefined(domain)){
  7233. domain='';
  7234. }
  7235. if(isUndefined(path)){
  7236. path='/';
  7237. }
  7238. var ckStr=';domain='+domain+';path='+path;
  7239. if(location.protocol=='https'){
  7240. ckStr+=';SameSite=None;Secure=true';
  7241. }
  7242. var set=function(name,value){
  7243. var time = 360*24*60*60*1000;
  7244. var exp = new Date();
  7245. exp.setTime(exp.getTime() + time);
  7246. try{
  7247. document.cookie = name + '='+ escape (value) + ';expires=' + exp.toGMTString()+ckStr;
  7248. }
  7249. catch(event){console.error(event)}
  7250. },
  7251. get=function(name){
  7252. var arr,reg=new RegExp('(^| )'+name+'=([^;]*)(;|$)');
  7253. if(arr=document.cookie.match(reg)){
  7254. return unescape(arr[2]);
  7255. }
  7256. else{
  7257. return null;
  7258. }
  7259. },
  7260. del=function(name){
  7261. var exp = new Date();
  7262. exp.setTime(exp.getTime() - 1);
  7263. var cval=get(name);
  7264. if(cval!=null){
  7265. document.cookie= name + '='+cval+';expires='+exp.toGMTString()+ckStr;
  7266. }
  7267. };
  7268. if(!isUndefined(name) && !isUndefined(value)){
  7269. if(value=='delete'){
  7270. del(name);
  7271. return null;
  7272. }
  7273. else{
  7274. set(name,value);
  7275. return get(name);
  7276. }
  7277. }
  7278. else if(!isUndefined(name) && isUndefined(value)){
  7279. return get(name);
  7280. }
  7281. else if(!isUndefined(name)){
  7282. }
  7283. }
  7284. /*
  7285. * arrayToString
  7286. * 功能,二维数组传化成字符串
  7287. */
  7288. function arrayToString(arr) {
  7289. var str='';
  7290. if(!isUndefined(arr)){
  7291. for(var i=0;i<arr.length;i++){
  7292. var temp=arr[i];
  7293. if(i>0){
  7294. str+=',';
  7295. }
  7296. for(var y=0;y<temp.length;y++){
  7297. if(y>0){
  7298. str+=';';
  7299. }
  7300. if(valType(temp[y])=='number'){
  7301. str+=parseInt(temp[y]*100);
  7302. }
  7303. else{
  7304. str+=temp[y];
  7305. }
  7306. }
  7307. }
  7308. }
  7309. return str;
  7310. }
  7311. /*
  7312. * stringToArray
  7313. * 功能,字符串转化成二维数组
  7314. */
  7315. function stringToArray(str) {
  7316. var newArr=[];
  7317. if(!isUndefined(str)){
  7318. var arr=str.split(',');
  7319. for(var i=0;i<arr.length;i++){
  7320. var temp=arr[i].split(';');
  7321. temp[1]=parseInt(temp[1])*0.01;
  7322. temp[2]=parseInt(temp[2])*0.01;
  7323. newArr.push(temp);
  7324. }
  7325. }
  7326. return newArr;
  7327. }
  7328. /*
  7329. * documentHidden
  7330. * 功能,监听页面切换到其它标签,执行fn函数
  7331. */
  7332. function documentHidden(fn){
  7333. if(!isUndefined(document.visibilityState)){
  7334. fn(document.visibilityState === 'visible'?'show':'hidden');
  7335. addListener(document,'visibilitychange',function(){
  7336. fn(document.visibilityState === 'visible'?'show':'hidden');
  7337. });
  7338. }
  7339. }
  7340. return ckplayerEmbed;
  7341. }));