ckplayer.js 206 KB

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