ckplayer.js 260 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643
  1. /*
  2. 软件名称:ckplayer
  3. 软件版本:X1
  4. 软件作者:niandeng
  5. 软件网站:http://www.ckplayer.com
  6. --------------------------------------------------------------------------------------------------------------------
  7. 开发说明:
  8. 使用的主要程序语言:javascript(js)及actionscript3.0(as3.0)(as3.0主要用于flashplayer部分的开发,不在该页面呈现)
  9. 功能:播放视频
  10. 特点:兼容HTML5-VIDEO(优先)以及FlashPlayer
  11. --------------------------------------------------------------------------------------------------------------------
  12. 使用开源代码部分:
  13. 1:flashls-http://flashls.org/
  14. =====================================================================================================================
  15. */
  16. function ckplayerConfig() {
  17. return {
  18. flashvars: {},//用来补充flashvars里的对象
  19. languagePath: '',//语言包文件地址
  20. stylePath: '',//风格包文件地址
  21. config: {
  22. fullInteractive: true,//是否开启交互功能
  23. delay: 30,//延迟加载视频,单位:毫秒
  24. timeFrequency: 100,//计算当前播放时间和加载量的时间频率,单位:毫秒
  25. autoLoad: true,//视频是否自动加载
  26. loadNext: 0,//多段视频预加载的段数,设置成0则全部加载
  27. definition: true,//是否使用清晰度组件
  28. subtitle:false,//是否使用多字幕切换组件
  29. playbackRate:true,//是否使用倍速播放组件
  30. smartRemove: true,//是否使用智能清理,使用该功能则在多段时当前播放段之前的段都会被清除出内存,减少对内存的使用
  31. bufferTime: 200,//缓存区的长度,单位:毫秒,不要小于10
  32. rtmpBufferTime:0,//rtmp视频缓存区长度,单位:毫秒
  33. click: true,//是否支持屏幕单击暂停
  34. doubleClick: true,//是否支持屏幕双击全屏
  35. doubleClickInterval: 200,//判断双击的标准,即二次单击间隔的时间差之内判断为是双击,单位:毫秒
  36. keyDown: {
  37. space: true,//是否启用空格键切换播放/暂停
  38. left: true,//是否启用左方向键快退
  39. right: true,//是否启用右方向键快进
  40. up: true,//是否支持上方向键增加音量
  41. down: true //是否支持下方向键减少音量
  42. },
  43. timeJump: 10,//快进快退时的秒数
  44. volumeJump: 0.1,//音量调整的数量,大于0小于1的小数
  45. timeScheduleAdjust: 1,//是否可调节调节栏,0不启用,1是启用,2是只能前进(向右拖动),3是只能后退,4是只能前进但能回到第一次拖动时的位置,5是看过的地方可以随意拖动
  46. previewDefaultLoad: true,//预览图片是否默认加载,优点是鼠标第一次经过进度条即可显示预览图片
  47. promptSpotTime: false,//提示点文字是否在前面加上对应时间
  48. buttonMode: {
  49. player: false,//鼠标在播放器上是否显示可点击形态
  50. controlBar: false,//鼠标在控制栏上是否显示可点击形态
  51. timeSchedule: true,//鼠标在时间进度条上是否显示可点击形态
  52. volumeSchedule: true //鼠标在音量调节栏上是否显示可点击形态
  53. },
  54. liveAndVod: { //直播+点播=回播功能
  55. open: false,//是否开启,开启该功能需要设置flashvars里live=true
  56. vodTime: 2,//可以回看的整点数
  57. start: 'start' //回看请求参数
  58. },
  59. usehardwareeecoder:false,//是否采用硬件加速,只针对flashplayer有效
  60. errorNum: 3,//错误重连次数
  61. playCorrect: false,//是否需要错误修正,这是针对rtmp的
  62. timeCorrect: true,//http视频播放时间错误纠正,有些因为视频格式的问题导致视频没有实际播放结束视频文件就返回了stop命令
  63. m3u8Definition: { //m3u8自动清晰度时按关键字来进行判断
  64. //tags:['200k','110k','400k','600k','1000k']
  65. },
  66. m3u8MaxBufferLength: 30,//m3u8每次缓冲时间,单位:秒数
  67. split: '|',//当视频地址采用字符形式并且需要使用逗号或其它符号来切割数组里定义
  68. timeStamp: '',//一个地址,用来请求当前时间戳,用于播放器内部时间效准
  69. mobileVolumeBarShow: false,//在移动端是否显示音量调节按钮
  70. addCallback: 'adPlay,adPause,playOrPause,videoPlay,videoPause,videoMute,videoEscMute,videoClear,changeVolume,fastBack,fastNext,videoSeek,newVideo,getMetaDate,videoRotation,videoBrightness,videoContrast,videoSaturation,videoHue,videoZoom,videoProportion,videoError,addListener,removeListener,addElement,getElement,deleteElement,elementShow,animate,animateResume,animatePause,deleteAnimate,changeConfig,getConfig,openUrl,fullScreen,quitFullScreen,switchFull,screenshot,custom,changeControlBarShow,getCurrentSrc,changeDefinition,changeSubtitles,changeSubtitlesSize'//需要支持的事件
  71. },
  72. menu: { //版权名称支持
  73. ckkey: '',
  74. name: '',
  75. link: '',
  76. version: '',
  77. domain: '',
  78. more: []
  79. },
  80. style: { //风格部分内容配置,这里主要配置loading和logo以及广告的部分内容
  81. loading: { //视频加载前显示在播放器中间的图片,如果不需要可以删除该属性
  82. file: 'data:image/swf;base64,Q1dTCrUjAAB4nKWZBzRc/bf3BwmJJEgQoo0SEd3odRA1iU70PjqjzYg6SESITiJatKiJMLroRIsuehC999FHveT/PBn3/p/33vu+71rG+pzf2fu7z3ef39nrzBorAFACgF0FAJBjAaRvkwMAAB/iK1cBAFFnMwthNWlZWjeonT1M+PxIjN4KDncU5uR0dXXlcOXhcHC25AQJCQlxcnFzcnOzn0eww9zt4SZu7PYwBnow7W8FaXMYxNnaEW7tYE97cWxi6uACF6On/0vWDer4R9YexmFi5mBqzgFxgHK6mThygji4OC90zoOEpZzNTeAOzhoODnZgyYsoWlk7E5gVrYqzg4U5DHYub2JHK6XOJ8r5X6Mv5ZtLn3/A3FwgbnYuAXZuIQ0QvzAvjzBIgJVLUJiL61LuvyL/lapoDjcxM4GbYJIv/ng0QHzCfOdpQpeT/1PsX+kOZtYW7v+rZEwkrSjnf+ne/7qfior/fUehUM6/o2FwNXOL/z4apuHuaM6pZg5zcHGGmJ+HM/x1RxQVhR/bw+Am9hDzx9Lg8wUOa2szYUkuLhnQIyFBWUleXhluEOiRAA+vlJS0AJ8UnwA/D8+j30b/c+rfatIOEBeouT38LzWz/wu1S6l/qyk7W1tan++Jf1AV4OLi5+PjluGTlBaSAYFAQtx80o94QYICQtz8/FJ/3Yx/lvhzrebO1s/NzWSdHaC/74KjiTPM/KJTYvR/t+qiTb/7K2z9720Skv2fjP1b6t9qZv9gSOh/MvRvqX+rOfz/tOn/KEH758Zg+vT/vKXNIH92qKOLs93vsWMG4TS3M7+oBjvfpaDfU8IMImzh4Aw1gYNNHB3trCEmF4KcbuwwKweIravJc3N2i4uJIcqJCfzHS+L8a/CBaQFS2OfjsJb05vl/LMDch4r5OCQtCAAQv75JfrFy9TuAC+A2spaI56XxbK+FKa4/7vFGNXGv/CO8q69or8TIBNHeEX7R4+l7hYsu4hH2FUnhhzJXtDQ0tVVJTu+SPPJ4CScpoP2YnULPtnk0weOQJDqh5K4uMZy4jR7r7qhyXuhM2K6uhXVVv/1uNh/3NjGU7X6dzqAYuwQ/zOal3cmynJmnq2sM8LCWaS2HYN8lW7C/ZWrylGlWpMzlHTuHQvQtahK6p4rOMeXMc9wicQNf9iYsnQdFDdbMf1Vc+f4kWHdEw7vXyGUmJm7qq0Ev1jAXkZs796YsQT4T0K0IMCxGOAy+q412HUsa3Zn2pwvScoUX3uPh1r1LnKrGY8GXcyIQGx6A0+dr9bNGzAd2ONfyKVVCh8l4hmgSyPOi2r/Os/0F4RB2gNEVGyOcsFqcD8grefqAPEPsGiGC/lXTjlnsp5UfhJKmNHX79Qer4gI6VE+HfGpwNqoa8mKKCuLi4gi/ucyaWVrqiW3U81PMVLpcL5jYlnVFJ1Kqn/heba2L6upoqcSWgfqinSSeX+MaoIydxVKA4z3wxOrD8XUvkHAX3lzmnVzkn6SHzMZsvHBQxpErxV45TBbn6Rdz1XzJNjzR2hYQHR7Q5iVGbbY9X+x4uL6i2rGQBTpLbhKMXSdUcMTihvqmchtfs/WTYfcrkfwilma94/GOfSZwqauQ13iBJOWQdHLnqK5yTsI64MQhY9TFo3Hot+Q3epzoUpHS56beieZ4IbB53QfbqNt2o46KaQtxzvOqSnVuV/sItDLp7FcjS64/sT+y8jROZ2/5QYvFSUwOe6odUhozxxzAj5UglyTO0ws5mHwYN3ahizd8x65aan9hP2TmOPmAvLPYlMQTrNbQaNXceIW0747RHvvrIvIc5k077ODqKN9jiy+M2O4othob7A6TI8tCbdsgJohCPYpXoeFaCVvzL+67OdUgMjfr4xLWvm8WCo/f/RzVRudvoSZ1qkJdF/EKO8h+fJncTZCTlbHhfdSAu4Rn3WB3l2kO5I2v5ivDrm37yXoV/U0j70fNS7OwGNHmrqKQVP3BiQ4JJYjsqBOFNIgCxd2nbLDw7fBF7Ykou91I+qujzwya4C8W3x+ZcYw7MOPG1Fdn3yns3R4a6TLc1pu55tAVzqxJT53i5SXJw6HMhLsY6aZS9ON4vdQrk9FdQS7JXHjLjqoFb+k63/R9kQhIaOyMi3WImKvdEkTLJ5aEy9mqOJowR4xonr4Ipj83DKMQDWadfOZF8nn6s0jhN3Xx/fh41+1pcsL3CUc2XmIv+nBMU/IZtRpY7NuTyiy8uGTx1cpPSGCdoSYT3BAT++LXt/aEBYJmGJhe9qUugdnWnaenBUo0fzpSzTN6o386lnVRH4ecsv2Ympqa1RM3qPG6h53zKTu7Zw6mdmAVHR/Psgob6koUqR4bG4Oj+XYZxpRkkbsoJn9CD+URpnU9t/G+k8Nd4mS5UTRkESZfHvOtO2etAu15gl7qy/IfkkBai/j4wH++HsjRCj7Kss3aWJakYOKe6/Qc32Q7AJyaP3PkzHv1VPXqhxs5G4Ix/WfctpKnubYaDYmUTWiwtbSqiD2BWSukbmtnApm7uL+LJpVS5ucAPjN6lnT+aUvi9Nrq1XKndkqIjSdunmNpfMJRUG/YbeLVYXHSZSwaMtTfKGszLdSmZYFbVYkMEOXt0dlaeMjOwvISK22jSi+GwyBkSqoDF4Gs6Mqy7ZmrfKRZgg6jA78C23/P5pzy7IFNWfY0R/RY1W4mvUFqLZcsbjuAgLzz5LBTRGsLtKph2eCBvVRPL4XbuQnbH6oPb4R/s0WpSotPOLJuoZttM7qVqk+O7OZb0ApSQXEWbN6zXaHmSy02MSHaXOIrS7X7i710BdZvyYGEhIRy5fpKob+Uhx5EmtD96hvJZGsDbn4ns7QEIVrNQzreTG7t6dTrf5ARar3pwzFOAW1HSUJf4gu0lHckvKW3JlAdrR6wnN1WO0gBqQmCewsOj3U/32Zo3pQcMl/1DEQ+Www3bd5F5x1oM89EkADJagK0/WiugD+YlW7dabGfIdI0DA1csJnS7SiQDJFmQ0p+++whjRRGbWS253gjmB2u2XdvQzyItLTiEsBuxuFKJpIvXqhNsLJ9n3Dt/brTj+xWtm1r0kxntgGTU/J4ffUYvh8aZmZjmuvUZfSh09EqcvVTmQNKW7aGaQ/m1MG4Q23gJW8iRQaE3/oGij+8w8N2ur6LoqsiMCigB3F6E04JSlQw8zXfGWdNHcd38a9lMmXvvQt7w6fXEaDic6vJfL9dDXr8sRaVWEbWOcRf52PNRxLMkqIPJ6lh6woy0An4urBCzuASqI+4w558dLCXhK7GJ9tRunl9k8edm5OZg95toTTkCkcXPXWrRQVvQ0yC34f5JlN2xphwFQaxeyv56enRHTrKP7RiJmyDY/xbtmrSQgkPw1455dd4N3n1uLIx4pIcZXOAFyv8T/psEfvaRsccO3oGoPcRWMKGQ+jXvN97Toi3U0NTa9uozPlL/ZUM5NKaKnCLRzY/6fIEEgrskdd8wS3oHjqtv+Z57Kqi0xk4y1H98Dn3frWYvkbQVmHNG33wI2HuhvAlPAiExfatzjpoMHLGD25W3OkPwzG7XmAfNW0mVcNAZeQ+cXvb5Cbl9PYtdEiNaJ3aLmvqxBsdUpvcPFvSJM4qgtTTwPIffDRLvdyIjW1a7diOgYXYiQ7qxZKZ+9PaVHPF+Y/eumrQ2bizm2r2f7w+k9YaJHyFIzeeen9f9b1+wnqeGouhp7kbt9bCR9HEadZpP2dYPMM9iKsAWes7xQQSB0fRBxNl0oghcn4FlC00RDeKEHHzGkJTK4RxVktw/NpGCTj0nYdD8QCShsRTN2l4TjOhhI98r1nHRVTGKxu/fDjoINArDHLfTGe3/mBpJZogLGzksHXxF/Iscu3Mw2H/M5lR2PXwQK55inhpXLTBIUvlvSw6jZXE2a4tOGkZmLE9KcfSSXhrfPRX6BafOppoyL9kwL5jTirm7MlaADLHJgcSrJggew1N1qL9SOxu+K3mQYniubuEOMB3MUiVYyjF6w1wQD0y2f9zNnbQN3wX7/XadPwpNgHCBfLy9drFtP7JWMHEid0+HfX8mkORVWFUw254l2FHMlhEayk7kRHK72Q3dF9JXF6kWWTCoC/qU5yej2zn942h17+KysWkdpmkKuC1BykHjcO6cfzgnaVgcDJfhlLWhi6NBviROQcYeKQ8Eni8XysdHqP8TTKN2p4C/Kjdtn+XtbZwWSuq+f3P0eFFhbCsLEIaPydPcMtOWTfEfE6mCrHeAnOgzltDaetqMQ9NLy1/1FWLGkB+ESwa+nhMt4Texs0QSxDJ3z7+YNk733lvmI/pqCC/vGjGfBsW/0sAvMiH/uiYUIN+eVQfwLxrYOAVQbMcVPDK4/5gZ20Q4aGB4YRhauFLS3WzPiam7/RS0WcFyaV93jbTJWQ78RSJLUCpk0iXpcWzFv6aCSa7j6Neox93AEkih7fau8PrvSWv6r/yyj8WtdPphIbLAF1DFOwzNiq71oXsqGRPttkOz2Z4+9KKYnfXr34R9Ihcat0/0y5ebqIFGvm9nTwdHx9PysvLIygtLW0+LM2YYTVRoAspYwYOkFreaw/IEzS0OQkSVx7yfNxa778famlErmfdp/B0zFb9wCp7PTesAHnKdRDu9c6NNm1iGDXqfyQu2jMTvr0kNOD26ugT9Ff/lDLy020B2Bz167HF6gyCnJxaGZJ2Hqq7VKpDyOznc+q6/pPmA++ygOHff87lqXzeQTRfxWEyg2zVdHMZD93bGXcKmjvK4vItiNqdX4h13WxnDd4Htiv4sEgl45azkAQZ+/j4mDY2/fypMzU5OWnn4LBh1tJxzahIw5uDyjKjnyd0TmoIVVF64yQxr0UlVAkf+OjuAeTV6WdFTnYnZOgcpKlw0KY2A5UIf0mxsbLzwcvoazLvZOdQ32kjkc9NlIRsy6aoyhmcxqkZWNRarsyRuSoUTLbMUXRc+bpJiwrYb0Ug5mjNN0cvoqfwcGBhyAytHJrw5s3ZIZUfrxd81AM70fCAhJofEdRS9kGiNjFr4+aEy/Sv1Aw9CLZUiTcynRILDAaPr6+v03BwcDQGt7W2vtkil4p35lyurDgcepYm8JoQwadscEKuhxf9LYDr/TSEDWVb8GaBLKNjZinnqvyUH/DIXxZ0u+np7NBsXzrntNvTbDpRYHGiwPLb0usQPtOwsF8rQl7Md4GHFAmUNVJ1vSyChcd+Cw3BqKna9PikmGJq4b4eM7muCVklaVxI2sLeW/mJ53cM+IFyR4otPc4IBrUhXloXKMOIg+jr4s4WpFj5Jw+1I3BDI+zhzsvBzAjvr8zRT3qJTP3g0k86XDjn8VxAGexdd5KUT1PCVU2MpvkeVBwQJUGsvP3Bb/uFRFNpFhN4fvCJW2XvsdPoNe4r4gOntR93XEdSj5hyb7nSAU3XG/V/8NsA0Ypjvnx8Mfknfe2bet9QkgXRT28n+2k0FH210a30ZriFnu9o4WlOwYOk/ZKdTokUo5HKuRUS6nJL3lA9vHFgN9DoWbjFaiS0dnvxcESZxujA2dRYOiQf2EuQRGgo8rCGHnyzSXt6bEBt5SnciXEPCHVnrU6OIIaWMKHcWBhrektwpYYOwQivQFuiinnUDlq0VlNrDOlmrz/qEtuGB7REOd1pkjdlQEyeGJEBp73R0GSVNRu9GfOq/Z/KywdtNZPXWvDmFr9c5QaL4ou32pzN0kp5dazzm1FV2AuFkTTjgCIr3tsy2waG497PtZGgn/Gbp7XmSAp7o6Pq2Q49PVLOAA9KcQTulpy/MYe+c38MtXVnKwCrxoQvC0/0lwPOr2thrDPXaCnIB56bwAvnvBmXN/KaBHygL2WVTja7kQ4sVqbyQY2p0JjiA/Gqmr98mz9szz7a02rM+xLwCzuMMNoCatrD3Rse1Lp2SCAAR86Lg5yD4glN6eKa1Bpl2nSVROR5orTTXMLSGRrlrwQviM7TZN9I2HxUbKSSrSL+cJ9oS1JIeCmg/yr7vg2ikt/oTh6SaKj2Jrow70DGiIbBEIJ0MMgHoWKHhzIGM9IHE5pWVm+hJHUlwE/QhRFXR2RLGNtEDkQlY2v7bEfkhISS9Tb59CHo4U9U2r5bQcGCJw0OVl3NsFGvW8Av5TEa9MVVd5MYo/3XAhRiKOchhb6EYbdsOrNzp2jeRGay2t7Wh+/Y1K36RGfuJX/Od3UkmgeaguVFDg7aVEIlRscKM3yAGew0Uwjl1aFjh9hGW+03NxC2m+mz6JHDjG6WY4N3/cf6omQf2eUiPjKO7PT1WA404W20p9+qerOSTyKAOlb50DSUcyB7fG1BImQO8gZRhiqDTQj5cXpXhHF0lEG3CXNc/A6M9Wmrql57nxVUdzZyS9W4a4lfscvehUCrPSiX5O+3O3ltgW3kP5yqHW0enAVC14obtbxCtWy8drVGGo4rtU3EOu/wjXqak/Dc5pkul0R5J1HC7L4qOofnNJQNTbXn1M4saSk3vF7Cm6PhiD8kza01BWlC9dfb7fEzemmB4Q4ipwtjUonBvIVjaWHWzZHJfvOriJq1HioBS//BGnmmQMJU781tYPNyQDThjAL5W7D8SvvZk6eRaNlEr+IDxQ8VXtTq+4kBXvUmD8meWe2k4at2D6S0to1MnASL25FFx35GIqfHiedTRkuJ2ZRspWHvfYr1lUt+4fKaCIU4jKcezsZx7spb9akafZjPU/uUXdPeoj19PBZL1dgWACduDlYbzDlDxiZ0jLtrbQbeqdo+f0REG+MKpqoi9CCPasWzhHYPBlyuMSN/9gvbptagKr8SzqQdDc7YPNDNtQzJd2P5kj49FDGG4IRTGRBNTs1BFz1WeYW+N9gQMgDf5ZAfHt04y5E9jc1djH1R2DBh3B3Hek1XNzfP5BMvn6FuZUK+rkH4iVDmbMNByrVEH7us9I1Gqt1juZVbLT12MtQv8QmonyZWz8RpWotldKy586ACrzm5EhI+d8YnfP78btl3FX96FgUOVy0dNNfQq+2J6cOc6CBxPZHRyQOgJ1Q05ERBqpcfGMC2kR9PaG7i74G43qmj8ovZQ2bNNjfznTo4JTe5qZpp/uNMcDJ9YfGWhfRpfa5BC5ncVdyAJz/8AokytvxwHj8ekIt6m0MgYP2tJDb2c8OPH9HJ0rJqOWJPkNVVwsWejrCIgDhCZlvnU7JO9fnsMWoum+v8AwbfVk+M6lJ9gwusCBqLZh9O69gnFr4HFWZOae70BhUwK4um5YYVP0CYYnnhEyTbJ1XaHqQpizLulgE5up4/P/NS5MBbXQVYWkpkYJPg17Ved3ScLB0dURP5Ke/yPkBa/IFy0nH+puQuCyvlSGjzftZaVIXxDmVWfunyHVPNQUnDulz19NofEtvLGsE2XZ2Q46j81ZmaN9QVb2CRj61PAhzWwNZO2w+c3qit5Ofhex5Fzz1hnJzCOjgAGBqOwVxd65qupiAab/J5Hun0iYnlnrm22eyPHpvj75elPfiisUDXvSp8K0tGrh8V/SQxC0bR64FI88g1aRt5bTTznjq+d7rV5LVNzeGXx+kJo3mJ6aSN0sa0kys33DwnzF/N5wTetqGhcYne2ytQ7Z0IP7hbe1dAPU9v2X1kXHmZT15Ma6JEe2t7u4XC81bFegxoKGXFC5JncOydORbgvYdK9N4oyiUQ2jBI0ZeitkRRTOtp5uaNlv4czp5Pb6poFnFiZdkHR1VXQBXUWHIZ3nlUG9o/mYuNrK8n44w4Iyaur5eQqEtGp8geMXeZjtp7uCvGpai1du5ApvghXuqrDO+nv5MA+aLNoVXkDf5CM68+ga27SlYq8dSOJezWufGaPCawyskPm4XOX3x0T/Y/PZbS5w1RyVNacbLuFM5Vz2qZ5QutlUF+/hkZGf026X3UHZrVjY3z7wvWYOW8N7++ComTxbxrjIhYtUahFrqJbsyemZhIWD3Moj6fiOIPMz8iFBNqdi0cHfNrExM/zZSCvBYrwzPDEipqjJgRscIWlNOj2uAd6+/VX3ERyaNjG/Uk4O93ZsEmJZFFpZC6HMv+lewPN8Kz0SmZxgWadVE2u8eyAWThqTOZuOmrX33lBKgaTlvwjo/KeibVW0aK3V2NspRESjOzHH4OV+6zcmZkUI9N1JxYZkVF2RswnTFNEF7HMjUF6HZLjNwmaURNbXSDppda52aLxdjX2rtNIUDP/vb2MUH5BOSE7QnXLFlm44PMsOT5LZNlbfuH/DwPZHmbythJjVCD7aD1yPaCJryI0rkrL3Xsu5Bzcy6Nnk58aoP9H9feq8t771J+iVPDvd+M7fRFRgYWL+GtfKrkrRxqKCfrrK8SHDgZliZbRXTD29s3h1XC9sT6LN+k9mTs88DXH+vrzc6p7WWdKCbYNL56rZF6sfLysHXe87hvX/nFuBcqi+EdzAPNwsUeW7oKSwHLfGXFBO0ZixwMO2WkA7WqRvtCuOxjoRujxVhRCdhrI1i5ejjsetjFhnRCcbaPH0t4iRJRthfc7iQPCpomn+R7Bffn9RtOObXornGpdt3wdz89zTw10lPfVofOhAihBoyaAvKGe8dE2zTO316EMr28YeQCclLfGbOES4GO7OkHiFccSNVuv01EOekzidId9a8cX+rWG7vYlPMthet4aekiZz66w1JkbqyDGK9aDYYs3RglI2sBPfIiIksn02gpKVv4SisrG4o9mNvQGRLCyKiqytHVfEZNDD21CyGIfXtjvP2gjSSPLdIndvsem44fjz/h08H6YlBUE3xWb8P9aDIL7UObt7M/88SGVs+JgthjYfJ1x/ttKCWlPTjcRukdRL1K2ok42W8bddco5iNkSdRmp0pPwHjbYnJ3CGlEzWVcf1wnEf0WZUdOTBYX5ROrPlRFNpNVDqkVcg9OrdmhtlxfEODb59qt7LcUW4svzoFT116niZ8gbXufKNHWn3jQ1nmUF25ry7ugCCLmiweSbTBp9va9uEXp2yw7PTPWGkbNE+DpKTLcpsCP8JIPRSpMrRkOuire42S/TakTz/N0ABCKsn46iITrqFMiJ10METDvZ+zC6WElz9PTJwZuIUICKeeW00lvkGEHEOLEcGABEfAFWc1BVk70Yam1yemZZ37jcfI7qjNvVGowDOasqn48emeXFTJu9OSD3eruBCv4uz6U6sMhumzZAy69cHNMg+UrKhmpjCogHrCwXn9Jg9blmKNDHALm5iQMqDdnwuuiWetSpSSe76WeBYfRvD//crPGURR4L76IS068I1HgfVv+pxLlTyfya0Ztsey7PNoVpbY3k99/2aAolDeSW/hEbPAMbxy1d4oS+SwZeaa+FkROzoMbC8L53o3X1ubLrufrh/ei7UlKDY3bEZSWc2Pan4Da0LPpF2KRljJBYiLgSACoWRQ/vGgk6F7+cxhup+zjQ0tr3DI4PKwMllcCuxZCRzc495Zd1toi6IbyQihcdgNuM3AgBmrPWpu7Eq1PDm+s6Bu0hL5vVXtrBf0YfSNHbHjvbKIQJVgLYAIAANgAq4sfjLEmAVhSWICfEoCr54sAIlJkCg1e4U2qApyCHSokAPAaFxfrPBZQC6A9P43zO0k+SskXC3B2dgYguoVMua9ceJOC5TnYT7YOEIgri30edK5VCyg/j78CcAQQpgAACAA2UfkOXg+BQSPi/GQcoEPQogMQ0gEADJ51AM7e49f/Pn0Tgdfzj2cBtKRdnhRf+qC9Go0Akg4uLGhuCf/4qO/1AHlArPWDUbWo3EoxAElRHSBKTZGZmRGA6ykPsCz9eT9o8HOJbuZo+qdAAHOsMfaong20ugxATBCBxdWrWJrBqPfcA8Bs6Yt1Pz1eTe0J4OZeBKAbWvgYcHadCHBhA+tfDbgCAEicH59dHzo3hwt4Bgi6WL0KoMQFXJwJxL2KBaC8tonhG5MYJujB8O1LTFKHYbJ8DFOkYJg6AsO0vhhmcMTwg0vMbIxhNhUMc0pgmJsLw3y0GBYkwrDIJQZf8ihxyaPUJY+yl3w9vuRL4ZIv5Uusdsnjs0setS951Lvky/CSL5NLvswuseUljzaXPEIveXS85At2yZfLJV9ul9jzkkfv3x4DLvgeju8fvG78Bwkl/iAp7R+kxCAdRuHB5B9kq/uD3Cl/UBBTAowpIY3BJ5hqKpgSmpgSepgSJpgSlpgSUAzCMNXcMSV8/pQgw8fg3T8lyOj+6JKxY1DojxiZDCZNFZOmj4m1wsTC/8SSAv6skpL/SSPlxKzKYVYNMavP/6wSU2LwKQY9LvD1Bd5W+5sIjX8/3G9wcXHOn+27AIZJ8Wvn2wqA92fYYRPlRmD74dDdr7v4Hfl88v0elXmO2H4G+Y+5Lq0BaC8G4lqa5ZWpj1k4tCK4kvRyMkrXG2S7cC+K4eKei/4u9h8UUd6/',
  83. align: 'center',
  84. vAlign: 'middle',
  85. offsetX: -100,
  86. offsetY: -40
  87. },
  88. logo: { //显示在右上角的logo图片,如果不需要可以删除该属性
  89. file: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFcAAAAUCAYAAAD4BKGuAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAVTSURBVHja1Fl/aJVVGP4cw/mH5tUWi3I53cA0WbeIzMgaq6lQoVawm0S6glHhIKM/TELICotqCxMSGWQRdFfRLEhc9mMxqA0rbdS2wsV0GkZXuaKUWlHvgeeNh7f3u1du3Ft74eGcnXu+c873vD/Pt0nZbDZyZL2gWZAQTBH8IjggeEjgPZASPIB+g/P7EsGT6J/BfHfjHFIv2Jpjj/+dlDskvCm42Jk7X3C7YJOgw/z2oOBGwdEYRW0RVAjOCZ4ugNggqwU3CTLRBJFyQ+xuwVRY14igB78tE9QKpgmeEHwkGKRnq9AeMesHRWwEsYGUxwSdBZ51ecweE4Lct0DsOVjaZvptA8jfC4JfghWpXIJ2jMY+EDShf1pwh6DvX5x1GtpDE43cNFlfhyFWpQ9xd5FgFo3fRi++C+2nCBNBRgU3O6RsEyyEQv4QLMb4CcE9RlFBLqS1WZ6BZ83A35ofVhuvfE5QJrjWebdgCJOx51qM1QgewbMzsO57MDQrB9DeC8ObHd5Xyb2eiNiQQxmtgkZBr+OuZwV7BIcF1RgbF1wTE2MbEccX48VY9sMzBilhTke/m+b1Q9lefpgruI7OsYhIGzPJuAnn3+6EM7vu1YKl5vkrYRSfCGZivCxoMklk7M5j6eFlXyRNRSAvAoFf0Fo/CC7LkbwuQjsZsf0qwbuI9wlYgIqGl6NEzDYibJ/gbmAfxpKoMDRcaSK8xZzjZbK+NMhSYoNSngV5e+ksKXp+JdqZwDDmdpSbsqa9gNAyi5JalSGv3iQ+dtNK9HvI+sNBh2AhvNYVaH+msRtAdsa4ehoKCuQsoP2PY8+kCSkJ5IRWjD2FZ4/BOFSWYv9KhI40eUKQ31CqdnLM1c1OOnHufKSS+iEZvgHNhji8g1yT5VZKdCnHO+ajvrYK/I7GkuSWjwvq8Mzl5M79NF89aCHaBNXmWv0sQVUUZEDwsDnbr2i9s31lKyGuFs7kITEBC+snJaToRYIFrRN0CeYgoSUxJ23WUm85eB41b4IUuIvGtyIMVMY8lzHGMoYworF7J/onKYk10/wVQL6zXYr+Zq9aOEhuXZPDel8Q3If+HMzTeHPKlForEK+mws3SMfH2UMxNLIJbasKsoIQZwVLbKFkN4T1C3HxUMM+EkCAfgjwNV40Y304KriOP+jIHqa+jvYsqnH/kqzKaGCFZxWnoTqooxky8+dHUsOGwr6Jfi9jmlVVTHGLnot9L3qGWqCToWYYRF5fDa96mtb93yI2g8B0IWxlTHWmi/hOG00D4mEJfJ5WhQX7ySCsDUaNkJeud6+sgXCgs3OLEG2/xdZSh10JBeiB1zQU0HuQdSib60rOdm9kFToIL8hmFiRHzm1YM0ylet5k579OFpcUk4I0oD0/QuJ7tcBy5ERY6ixdrh5uNwN3bUV7pd4E+J958HmPxbRRydqK/in6vxj5aH9din/udEPKtuU1GqBL24xJwBInQWiHLcbQVKBXTzkVpHP0tWHsIpZUqPeWcrScXuX2ImRkqlufBhdQl15ig3WLKH0/SeAmtD+uprBqGx1ThhlWN5LKG4lcNKbDblFDjVDU0wWK7yLLqnPNk6cKzKsfXt1GQmQQXSuwymhd3tr9lkvPJMUV152kc2PsmUEMxtzdPRk2SNX2DQ3Vhr02Is18LXjHVAz/bG0NEK8johus3UBiwyfkYlDkQUyLaWrwZBrbHMaB8Z3PJLaYk8IIVKKPSJdxbv3ecynNzLNr33GKLV1YVW4IyfycXfq0UxP4X5HJdXCqX4Wv0AKqYkkipw4LG6WxMNi+GhAtH+M/K8wVe7wuWvwQYAFT+UsGCXmX3AAAAAElFTkSuQmCC',
  90. align: 'right',
  91. vAlign: 'top',
  92. offsetX: -100,
  93. offsetY: 10
  94. },
  95. advertisement: { //广告相关的配置
  96. time: 5,//广告默认播放时长以及多个广告时每个广告默认播放时间,单位:秒
  97. method: 'get',//广告监测地址默认请求方式,get/post
  98. videoForce: false,//视频广告是否强制播放结束
  99. videoVolume: 0.8,//视频音量
  100. skipButtonShow: true,//是否显示跳过广告按钮
  101. linkButtonShow: true,//是否显示广告链接按钮,如果选择显示,只有在提供了广告链接地址时才会显示
  102. muteButtonShow: true,//是否在视频广告时显示静音按钮
  103. closeButtonShow: true,//暂停时是否显示关闭广告按钮
  104. closeOtherButtonShow: true,//其它广告是否需要关闭广告按钮
  105. frontSkipButtonDelay: 1,//前置广告跳过广告按钮延时显示的时间,单位:秒
  106. insertSkipButtonDelay: 0,//插入广告跳过广告按钮延时显示的时间,单位:秒
  107. endSkipButtonDelay: 0,//后置广告跳过广告按钮延时显示的时间,单位:秒
  108. frontStretched: 2,//前置广告拉伸方式,0=原始大小,1=自动缩放,2=只有当广告的宽或高大于播放器宽高时才进行缩放,3=参考播放器宽高,4=宽度参考播放器宽、高度自动,5=高度参考播放器高、宽度自动
  109. insertStretched: 2,//插入广告拉伸方式,0=原始大小,1=自动缩放,2=只有当广告的宽或高大于播放器宽高时才进行缩放,3=参考播放器宽高,4=宽度参考播放器宽、高度自动,5=高度参考播放器高、宽度自动
  110. pauseStretched: 2,//暂停广告拉伸方式,0=原始大小,1=自动缩放,2=只有当广告的宽或高大于播放器宽高时才进行缩放,3=参考播放器宽高,4=宽度参考播放器宽、高度自动,5=高度参考播放器高、宽度自动
  111. endStretched: 2 //结束广告拉伸方式,0=原始大小,1=自动缩放,2=只有当广告的宽或高大于播放器宽高时才进行缩放,3=参考播放器宽高,4=宽度参考播放器宽、高度自动,5=高度参考播放器高、宽度自动
  112. },
  113. video: { //视频的默认比例,当视频元数据里没有宽和高属性时默认使用该宽高
  114. defaultWidth: 16,//宽度
  115. defaultHeight: 9 //高度
  116. }
  117. }
  118. };
  119. }
  120. !(function() {
  121. var javascriptPath = '';
  122. !function() {
  123. var scriptList = document.scripts,
  124. thisPath = scriptList[scriptList.length - 1].src;
  125. javascriptPath = thisPath.substring(0, thisPath.lastIndexOf('/') + 1);
  126. } ();
  127. var ckplayer = function(obj) {
  128. /*
  129. javascript部分开发所用的注释说明:
  130. 1:初始化-程序调用时即运行的代码部分
  131. 2:定义样式-定义容器(div,p,canvas等)的样式表,即css
  132. 3:监听动作-监听元素节点(单击-click,鼠标进入-mouseover,鼠标离开-mouseout,鼠标移动-mousemove等)事件
  133. 4:监听事件-监听视频的状态(播放,暂停,全屏,音量调节等)事件
  134. 5:共用函数-这类函数在外部也可以使用
  135. 6:全局变量-定义成全局使用的变量
  136. 7:其它相关注释
  137. 全局变量说明:
  138. 在本软件中所使用到的全局变量(变量(类型)包括Boolean,String,Int,Object(包含元素对象和变量对象),Array,Function等)
  139. 下面列出重要的全局变量:
  140. V:Object:视频对象
  141. VA:Array:视频列表(包括视频地址,类型,清晰度说明)
  142. ID:String:视频ID
  143. CB:Object:控制栏各元素的集合对象
  144. PD:Object:内部视频容器对象
  145. ---------------------------------------------------------------------------------------------
  146. 程序开始
  147. 下面为需要初始化配置的全局变量
  148. 初始化配置
  149. config:全局变量定义一些基本配置
  150. */
  151. this.config = {
  152. videoDbClick: true,//是否支持双击全屏/退出全屏动作
  153. errorTime: 100,//延迟判断失败的时间,单位:毫秒
  154. videoDrawImage: false,//是否使用视频drawImage功能,注意,该功能在移动端表现不了
  155. adSkipClick: 'javaScript->adjump' //h5环境中点击跳过广告按钮触发的功能
  156. };
  157. //全局变量:播放器默认配置,在外部传递过来相应配置后,则进行相关替换
  158. this.varsConfig = {
  159. playerID: '',//播放器ID
  160. container: '',//视频容器的ID
  161. variable: 'ckplayer',//播放函数(变量)名称
  162. volume: 0.8,//默认音量,范围0-1
  163. poster: '',//封面图片地址
  164. autoplay: false,//是否自动播放
  165. loop: false,//是否需要循环播放
  166. live: false,//是否是直播
  167. duration: 0,//指定总时间
  168. forceduration:0,//强制使用该时间为总时间
  169. seek: 0,//默认需要跳转的秒数
  170. drag: '',//拖动时支持的前置参数
  171. front: '',//前一集按钮动作
  172. next: '',//下一集按钮动作
  173. loaded: '',//加载播放器后调用的函数
  174. flashplayer: false,//设置成true则强制使用flashplayer
  175. html5m3u8: false,//PC平台上是否使用h5播放器播放m3u8
  176. track: null,//字幕轨道
  177. cktrack: null,//ck字幕
  178. cktrackdelay:0,//字幕显示延迟时间
  179. preview: null,//预览图片对象
  180. prompt: null,//提示点功能
  181. video: null,//视频地址
  182. config: '',//调用配置函数名称
  183. type: '',//视频格式
  184. crossorigin: '',//设置html5视频的crossOrigin属性
  185. crossdomain: '',//安全策略文件地址
  186. unescape: false,//默认flashplayer里需要解码
  187. mobileCkControls: false,//移动端h5显示控制栏
  188. mobileAutoFull: true,//移动端是否默认全屏播放
  189. playbackrate: 1,//默认倍速
  190. h5container: '',//h5环境中使用自定义容器
  191. debug: false,//是否开启调试模式
  192. overspread:true,//是否让视频铺满播放器
  193. //以下为广告相关配置
  194. adfront: '',
  195. adfronttime: '',
  196. adfrontlink: '',
  197. adpause: '',
  198. adpausetime: '',
  199. adpauselink: '',
  200. adinsert: '',
  201. adinserttime: '',
  202. adinsertlink: '',
  203. inserttime: '',
  204. adend: '',
  205. adendtime: '',
  206. adendlink: '',
  207. advertisements: ''
  208. };
  209. this.vars = {};//全局变量:语言配置
  210. this.language = {
  211. volume: '音量:',
  212. play: '点击播放',
  213. pause: '点击暂停',
  214. full: '点击全屏',
  215. escFull: '退出全屏',
  216. mute: '点击静音',
  217. escMute: '取消静音',
  218. front: '上一集',
  219. next: '下一集',
  220. definition: '点击选择清晰度',
  221. playbackRate: '点击选择速度',
  222. subtitles: '点击选择字幕',
  223. error: '加载出错',
  224. adTime: '广告{$second}秒',
  225. skipAd: '跳过广告',
  226. skipAdTime: '{$second}秒后可跳过广告',
  227. adLink: '查看详情',
  228. noLoadShockwaveFlash:'您的浏览器不支持FlashPlayer插件或没有启用该插件',
  229. downLoadShockwaveFlash:'点击下载FlashPlayer插件'
  230. };
  231. //全局变量:右键菜单:[菜单标题,类型(link:链接,default:灰色,function:调用函数,javascript:调用js函数),执行内容(包含链接地址,函数名称),[line(间隔线)]]
  232. this.contextMenu = [['ckplayer', 'link', 'http://www.ckplayer.com', '_blank'], ['version:X1', 'default', 'line']];
  233. //全局变量:错误提示列表
  234. this.errorList = [['000', 'Object does not exist'], ['001', 'Variables type is not a object'], ['002', 'Video object does not exist'], ['003', 'Video object format error'], ['004', 'Video object format error'], ['005', 'Video object format error'], ['006', '[error] does not exist '], ['007', 'Ajax error'], ['008', 'Ajax error'], ['009', 'Ajax object format error'], ['010', 'Ajax.status:[error]']];
  235. //全局变量:HTML5变速播放的值数组/如果不需要可以设置成null
  236. this.playbackRateArr = [[0.5, '0.5倍'], [1, '正常'], [1.25, '1.25倍'], [1.5, '1.5倍'], [2, '2倍速'], [4, '4倍速']];
  237. //全局变量:保存倍速
  238. this.playbackRateTemp=1;
  239. //全局变量:HTML5默认变速播放的值
  240. this.playbackRateDefault = 1;
  241. //全局变量:HTML5当前显示的字幕编号
  242. this.subtitlesTemp=-1;
  243. //全局变量:定义logo
  244. this.logo = '';
  245. //全局变量:是否加载了播放器
  246. this.loaded = false;
  247. //全局变量:计时器,监听视频加载出错的状态
  248. this.timerError = null;
  249. //全局变量:是否出错
  250. this.error = false;
  251. //全局变量:出错地址的数组
  252. this.errorUrl = [];
  253. //全局变量:计时器,监听全屏与非全屏状态
  254. this.timerFull = null;
  255. //全局变量:是否全屏状态
  256. this.full = false;
  257. //全局变量:计时器,监听当前的月/日 时=分=秒
  258. this.timerTime = null;
  259. //全局变量:计时器,监听视频加载
  260. this.timerBuffer = null;
  261. //全局变量:设置进度按钮及进度条是否跟着时间变化,该属性主要用来在按下进度按钮时暂停进度按钮移动和进度条的长度变化
  262. this.isTimeButtonMove = true;
  263. //全局变量:进度栏是否有效,如果是直播,则不需要监听时间让进度按钮和进度条变化
  264. this.isTimeButtonDown = false;
  265. //全局变量:用来模拟双击功能的判断
  266. this.isClick = false;
  267. //全局变量:计时器,用来模拟双击功能的计时器
  268. this.timerClick = null;
  269. //全局变量:计时器,旋转loading
  270. this.timerLoading = null;
  271. //全局变量:计时器,监听鼠标在视频上移动显示控制栏
  272. this.timerCBar = null;
  273. //全局变量:播放视频时如果该变量的值大于0,则进行跳转后设置该值为0
  274. this.needSeek = 0;
  275. //全局变量:当前音量
  276. this.volume = 0;
  277. //全局变量:静音时保存临时音量
  278. this.volumeTemp = 0;
  279. //全局变量/变量类型:Number/功能:当前播放时间
  280. this.time = 0;
  281. //全局变量:定义首次调用
  282. this.isFirst = true;
  283. //全局变量:是否使用HTML5-VIDEO播放
  284. this.html5Video = true;
  285. //全局变量记录视频容器节点的x;y
  286. this.pdCoor = {
  287. x: 0,
  288. y: 0
  289. };
  290. //全局变量:判断当前使用的播放器类型,html5video或flashplayer
  291. this.playerType = '';
  292. //全局变量:加载进度条的长度
  293. this.loadTime = 0;
  294. //全局变量:body对象
  295. this.body = document.body || document.documentElement;
  296. //全局变量:播放器
  297. this.V = null;
  298. //全局变量:保存外部js监听事件数组
  299. this.listenerJsArr = [];
  300. //全局变量:保存控制栏显示元素的总宽度
  301. this.buttonLen = 0;
  302. //全局变量:保存控制栏显示元素的数组
  303. this.buttonArr = [];
  304. //全局变量:保存按钮元素的宽
  305. this.buttonWidth = {};
  306. //全局变量:保存播放器上新增元件的数组
  307. this.elementArr = [];
  308. //全局变量:保存播放器上弹幕的临时数组
  309. this.elementTempArr = [];
  310. //全局变量:字幕内容
  311. this.track = [];
  312. //全局变量:字幕索引
  313. this.trackIndex = 0;
  314. //全局变量:当前显示的字幕内容
  315. this.nowTrackShow = {
  316. sn: ''
  317. };
  318. //全局变量:保存字幕元件数组
  319. this.trackElement = [];
  320. //全局变量:将视频转换为图片
  321. this.timerVCanvas = null;
  322. //全局变量:animate,缓动对象数组
  323. this.animateArray = [];
  324. //全局变量:保存animate的元件
  325. this.animateElementArray = [];
  326. //全局变量:保存需要在暂停时停止缓动的数组
  327. this.animatePauseArray = [];
  328. //全局变量:预览图片加载状态/0=没有加载,1=正在加载,2=加载完成
  329. this.previewStart = 0;
  330. //全局变量:预览图片容器
  331. this.previewDiv = null;
  332. //全局变量:预览框
  333. this.previewTop = null;
  334. //全局变量:预览框的宽
  335. this.previewWidth = 120;
  336. //全局变量:预览图片容器缓动函数
  337. this.previewTween = null;
  338. //全局变量:是否是m3u8格式,是的话则可以加载hls.js
  339. this.isM3u8 = false;
  340. //全局变量:保存提示点数组
  341. this.promptArr = [];
  342. //全局变量:显示提示点文件的容器
  343. this.promptElement = null;
  344. //全局变量:配置文件函数
  345. this.ckplayerConfig = {};
  346. //全局变量:控制栏是否显示
  347. this.showFace = true;
  348. //全局变量:是否监听过h5的错误
  349. this.errorAdd = false;
  350. //全局变量:是否发送了错误
  351. this.errorSend = false;
  352. //全局变量:控制栏是否隐藏
  353. this.controlBarIsShow = true;
  354. //全局变量,保存当前缩放比例
  355. this.videoScale = 1;
  356. //全局变量:设置字体
  357. this.fontFamily = '"Microsoft YaHei"; YaHei; "\5FAE\8F6F\96C5\9ED1"; SimHei; "\9ED1\4F53";Arial';
  358. //全局变量:设置字幕的文字大小
  359. this.trackFontSize=16;
  360. //全局变量:设置字幕的行距
  361. this.trackLineHeight=30;
  362. //全局变量:记录第一次拖动进度按钮时的位置
  363. this.timeSliderLeftTemp = 0;
  364. //全局变量:判断是否记录了总时间
  365. this.durationSendJS = false;
  366. //全局变量:初始化广告分析是否结束设置
  367. this.adAnalysisEnd = false;
  368. //全局变量:广告变量
  369. this.advertisements = {};
  370. //全局变量:是否是第一次播放视频
  371. this.isFirstTimePlay = true;
  372. //全局变量:当前需要播放的广告类型
  373. this.adType = '';
  374. //全局变量:播放广告计数
  375. this.adI = 0;
  376. //全局变量:要播放的临时地址
  377. this.videoTemp = {
  378. src: '',
  379. source: '',
  380. currentSrc: '',
  381. loop: false
  382. };
  383. //全局变量:当前要播放的广告组总时间
  384. this.adTimeAllTotal = 0;
  385. //全局变量:肖前要播放的广告时间
  386. this.adTimeTotal = 0;
  387. //全局变量:用来做倒计时
  388. this.adCountDownObj = null;
  389. //全局变量:前置,中插,结尾广告是否已开始运行
  390. this.adPlayStart = false;
  391. //全局变量:目前是否在播放广告
  392. this.adPlayerPlay = false;
  393. //全局变量:当前广告是否暂停
  394. this.adIsPause = false;
  395. //全局变量:视频广告是否静音
  396. this.adVideoMute = false;
  397. //全局变量:是否需要记录当前播放的时间供广告播放结束后进行跳转
  398. this.adIsVideoTime = false;
  399. //全局变量:后置广告是否播放
  400. this.endAdPlay = false;
  401. //全局变量:暂停广告是否在显示
  402. this.adPauseShow = false;
  403. //全局变量:是否需要重置广告以实现重新播放时再播放一次
  404. this.adReset = false;
  405. //全局变量:记录鼠标在视频上点击时的坐标
  406. this.videoClickXy={x:0,y:0};
  407. //全局变量:是否在播放广告时播放过视频广告
  408. this.adVideoPlay = false;
  409. if (obj) {
  410. this.embed(obj);
  411. }
  412. //全局变量:临时存储已加载时间的变量
  413. this.loadTimeTemp=0;
  414. //全局变量,临时存储hls形式下首次加载时是否需要暂停或播放的判断
  415. this.hlsAutoPlay=true;
  416. };
  417. ckplayer.prototype = {
  418. /*
  419. 主要函数部分开始
  420. 主接口函数:
  421. 调用播放器需初始化该函数
  422. */
  423. embed: function(c) {
  424. //c:Object:是调用接口传递的属性对象
  425. if (window.location.href.substr(0, 7) == 'file://') {//如果是使用的file协议打网页则弹出提示
  426. alert('Please use the HTTP protocol to open the page');
  427. return;
  428. }
  429. if (c == undefined || !c) {
  430. this.eject(this.errorList[0]);
  431. return;
  432. }
  433. if (typeof(c) != 'object') {
  434. this.eject(this.errorList[1]);
  435. }
  436. this.vars = this.standardization(this.varsConfig, c);
  437. if (!this.vars['mobileCkControls'] && this.isMobile()) {
  438. this.vars['flashplayer'] = false;
  439. this.showFace = false;
  440. }
  441. var videoString = this.vars['video'];
  442. if (!videoString) {
  443. this.eject(this.errorList[2]);
  444. return;
  445. }
  446. if (typeof(videoString) == 'string') {
  447. if (videoString.substr(0, 3) == 'CK:' || videoString.substr(0, 3) == 'CE:' || videoString.substr(8, 3) == 'CK:' || videoString.substr(8, 3) == 'CE:') {
  448. this.vars['flashplayer'] = true;
  449. }
  450. }
  451. if (typeof(videoString) == 'object') {
  452. if (videoString.length > 1) {
  453. if (videoString[0][0].substr(0, 3) == 'CK:' || videoString[0][0].substr(0, 3) == 'CE:' || videoString[0][0].substr(8, 3) == 'CK:' || videoString[0][0].substr(8, 3) == 'CE:') {
  454. this.vars['flashplayer'] = true;
  455. }
  456. }
  457. }
  458. if (this.vars['config']) {
  459. this.ckplayerConfig = eval(this.vars['config'] + '()');
  460. } else {
  461. this.ckplayerConfig = ckplayerConfig();
  462. }
  463. if ((!this.supportVideo() && this.vars['flashplayer'] != '') || (this.vars['flashplayer'] && this.uploadFlash()) || !this.isMsie()) {
  464. this.html5Video = false;
  465. this.getVideo();
  466. } else if (videoString) {
  467. //判断视频数据类型
  468. this.analysedVideoUrl(videoString);
  469. return this;
  470. } else {
  471. this.eject(this.errorList[2]);
  472. }
  473. },
  474. /*
  475. 内部函数
  476. 根据外部传递过来的video开始分析视频地址
  477. */
  478. analysedVideoUrl: function(video) {
  479. var i = 0,
  480. y = 0;
  481. var thisTemp = this;
  482. this.VA = [];//定义全局变量VA:视频列表(包括视频地址,类型,清晰度说明)
  483. if (this.typeString(video) == 'string') { //如果是字符形式的则判断后缀进行填充
  484. if (video.substr(0, 8) != 'website:') {
  485. this.VA = [[video, '', '', 0]];
  486. var fileExt = this.getFileExt(video);
  487. switch (fileExt) {
  488. case '.mp4':
  489. this.VA[0][1] = 'video/mp4';
  490. break;
  491. case '.ogg':
  492. this.VA[0][1] = 'video/ogg';
  493. break;
  494. case '.webm':
  495. this.VA[0][1] = 'video/webm';
  496. break;
  497. default:
  498. break;
  499. }
  500. this.getVideo();
  501. } else {
  502. if (this.html5Video) {
  503. var ajaxObj = {
  504. url: video.substr(8),
  505. success: function(data) {
  506. if (data) {
  507. thisTemp.analysedUrl(data);
  508. } else {
  509. thisTemp.eject(thisTemp.errorList[5]);
  510. this.VA = video;
  511. thisTemp.getVideo();
  512. }
  513. }
  514. };
  515. this.ajax(ajaxObj);
  516. } else {
  517. this.VA = video;
  518. this.getVideo();
  519. }
  520. }
  521. }
  522. else if(this.typeString(video)=='array'){//如果视频地址是数组
  523. if (!this.isUndefined(typeof(video[0].length))) { //如果视频地址是二维数组
  524. this.VA = video;
  525. }
  526. this.getVideo();
  527. }
  528. else if(this.typeString(video)=='object'){
  529. /*
  530. 如果video格式是对象形式,则分二种
  531. 如果video对象里包含type,则直接播放
  532. */
  533. if (!this.isUndefined(video['type'])) {
  534. this.VA.push([video['file'], video['type'], '', 0]);
  535. this.getVideo();
  536. } else {
  537. this.eject(this.errorList[5]);
  538. }
  539. }
  540. else {
  541. this.eject(this.errorList[4]);
  542. }
  543. },
  544. /*
  545. 对请求到的视频地址进行重新分析
  546. */
  547. analysedUrl: function(data) {
  548. this.vars = this.standardization(this.vars, data);
  549. if (!this.isUndefined(data['video'])) {
  550. this.vars['video'] = data['video'];
  551. }
  552. this.analysedVideoUrl(this.vars['video']);
  553. },
  554. /*
  555. 内部函数
  556. 检查浏览器支持的视频格式,如果是则将支持的视频格式重新分组给播放列表
  557. */
  558. getHtml5Video: function() {
  559. var va = this.VA;
  560. var nva = [];
  561. var mobile = false;
  562. var video = document.createElement('video');
  563. var codecs = function(type) {
  564. var cod = '';
  565. switch (type) {
  566. case 'video/mp4':
  567. cod = 'avc1.4D401E, mp4a.40.2';
  568. break;
  569. case 'video/ogg':
  570. cod = 'theora, vorbis';
  571. break;
  572. case 'video/webm':
  573. cod = 'vp8.0, vorbis';
  574. break;
  575. default:
  576. break;
  577. }
  578. return cod;
  579. };
  580. var supportType = function(vidType, codType) {
  581. if (!video.canPlayType) {
  582. this.html5Video = false;
  583. return;
  584. }
  585. var isSupp = video.canPlayType(vidType + ';codecs="' + codType + '"');
  586. if (isSupp == '') {
  587. return false
  588. }
  589. return true;
  590. };
  591. if (this.vars['flashplayer'] || !this.isMsie()) {
  592. this.html5Video = false;
  593. return;
  594. }
  595. if (this.isMobile()) {
  596. mobile = true;
  597. }
  598. for (var i = 0; i < va.length; i++) {
  599. var v = va[i];
  600. if (v) {
  601. if (v[1] != '' && !mobile && supportType(v[1], codecs(v[1])) && v[0].substr(0, 4) != 'rtmp') {
  602. nva.push(v);
  603. }
  604. if ((this.getFileExt(v[0]) == '.m3u8' || this.vars['type'] == 'video/m3u8' || this.vars['type'] == 'm3u8' || v[1] == 'video/m3u8' || v[1] == 'm3u8') && this.vars['html5m3u8'] && !mobile) {
  605. this.isM3u8 = true;
  606. nva.push(v);
  607. }
  608. }
  609. }
  610. if (nva.length > 0) {
  611. this.VA = nva;
  612. } else {
  613. if (!mobile) {
  614. this.html5Video = false;
  615. }
  616. }
  617. },
  618. /*
  619. 内部函数
  620. 根据视频地址开始构建播放器
  621. */
  622. getVideo: function() {
  623. var thisTemp = this;
  624. var v = this.vars;
  625. //如果存在广告字段则开始分析广告
  626. if (!this.adAnalysisEnd && (v['adfront'] != '' || v['adpause'] != '' || v['adinsert'] != '' || v['adend'] != '' || v['advertisements'] != '')) {
  627. this.adAnalysisEnd = true;
  628. this.adAnalysis();
  629. return;
  630. }
  631. //如果存在字幕则加载
  632. if (this.V) { //如果播放器已存在,则认为是从newVideo函数发送过来的请求
  633. this.changeVideo();
  634. return;
  635. }
  636. if (this.vars['cktrack']) {
  637. this.loadTrack();
  638. }
  639. if (this.supportVideo() && !this.vars['flashplayer']) {
  640. this.getHtml5Video(); //判断浏览器支持的视频格式
  641. }
  642. var src = '',
  643. source = '',
  644. poster = '',
  645. loop = '',
  646. autoplay = '',
  647. track = '';
  648. var video = v['video'];
  649. var i = 0;
  650. this.CD = this.getByElement(v['container']);
  651. volume = v['volume'];
  652. if (!this.CD) {
  653. this.eject(this.errorList[6], v['container']);
  654. return false;
  655. }
  656. //开始构建播放器容器
  657. this.V = undefined;
  658. var thisPd = null;
  659. if (v['h5container'] != '') {
  660. thisPd = this.getByElement(v['h5container']);
  661. if (this.isUndefined(thisPd)) {
  662. thisPd = null;
  663. }
  664. }
  665. var isVideoH5 = null; //isUndefined thisPd
  666. if (v['playerID'] != '') {
  667. isVideoH5 = this.getByElement('#' + v['playerID']);
  668. if (this.isUndefined(isVideoH5)) {
  669. isVideoH5 = null;
  670. }
  671. }
  672. if (thisPd != null && isVideoH5 != null) {
  673. this.PD = thisPd; //PD:定义播放器容器对象全局变量
  674. } else {
  675. var playerID = 'ckplayer' + this.randomString();
  676. var playerDiv = document.createElement('div');
  677. playerDiv.className = playerID;
  678. this.CD.innerHTML = '';
  679. this.CD.appendChild(playerDiv);
  680. this.PD = this.getByElement(playerID); //PD:定义播放器容器对象全局变量
  681. }
  682. this.css(this.CD, {
  683. backgroundColor: '#000000',
  684. overflow: 'hidden',
  685. position: 'relative'
  686. });
  687. this.css(this.PD, {
  688. backgroundColor: '#000000',
  689. width: '100%',
  690. height: '100%',
  691. fontFamily: this.fontFamily
  692. });
  693. if (this.html5Video) { //如果支持HTML5-VIDEO则默认使用HTML5-VIDEO播放器
  694. //禁止播放器容器上鼠标选择文本
  695. this.PD.onselectstart = this.PD.ondrag = function() {
  696. return false;
  697. };
  698. //播放器容器构建完成并且设置好样式
  699. //构建播放器
  700. if (this.VA.length == 1) {
  701. this.videoTemp['src'] = decodeURIComponent(this.VA[0][0]);
  702. src = ' src="' + this.videoTemp['src'] + '"';
  703. } else {
  704. var videoArr = this.VA.slice(0);
  705. videoArr = this.arrSort(videoArr);
  706. for (i = 0; i < videoArr.length; i++) {
  707. var type = '';
  708. var va = videoArr[i];
  709. if (va[1]) {
  710. type = ' type="' + va[1] + '"';
  711. if (type == ' type="video/m3u8"' || type == ' type="m3u8"') {
  712. type = '';
  713. }
  714. }
  715. source += '<source src="' + decodeURIComponent(va[0]) + '"' + type + '>';
  716. }
  717. this.videoTemp['source'] = source;
  718. }
  719. //分析视频地址结束
  720. if (v['autoplay']) {
  721. autoplay = ' autoplay="autoplay"';
  722. }
  723. if (v['poster']) {
  724. poster = ' poster="' + v['poster'] + '"';
  725. }
  726. if (v['loop']) {
  727. loop = ' loop="loop"';
  728. }
  729. if (v['seek'] > 0) {
  730. this.needSeek = v['seek'];
  731. }
  732. if (v['track'] != null && v['cktrack'] == null) {
  733. var trackArr = v['track'];
  734. var trackDefault = '';
  735. var defaultHave = false;
  736. for (i = 0; i < trackArr.length; i++) {
  737. var trackObj = trackArr[i];
  738. if (trackObj['default'] && !defaultHave) {
  739. trackDefault = ' default';
  740. defaultHave = true;
  741. } else {
  742. trackDefault = '';
  743. }
  744. track += '<track kind="' + trackObj['kind'] + '" src="' + trackObj['src'] + '" srclang="' + trackObj['srclang'] + '" label="' + trackObj['label'] + '"' + trackDefault + '>';
  745. }
  746. }
  747. var autoLoad = this.ckplayerConfig['config']['autoLoad'];
  748. var preload = '';
  749. if (!autoLoad) {
  750. preload = ' preload="meta"';
  751. }
  752. var vid = this.randomString();
  753. var controls = '';
  754. if (!this.showFace) {
  755. controls = ' controls="controls"';
  756. }
  757. var mobileAutoFull = v['mobileAutoFull'];
  758. var mobileautofull = '';
  759. if (!mobileAutoFull) {
  760. mobileautofull = ' x-webkit-airplay="true" playsinline webkit-playsinline="true" x5-video-player-type="h5"';
  761. }
  762. if (isVideoH5 != null && thisPd != null) {
  763. this.V = isVideoH5;
  764. if (v['poster']) {
  765. this.V.poster = v['poster'];
  766. }
  767. } else {
  768. var html = '';
  769. if (!this.isM3u8) {
  770. html = '<video id="' + vid + '"' + src + ' width="100%" height="100%"' + autoplay + poster + loop + preload + controls + mobileautofull + track + '>' + source + '</video>';
  771. } else {
  772. html = '<video id="' + vid + '" width="100%" height="100%"' + poster + loop + preload + controls + mobileautofull + track + '></video>';
  773. }
  774. this.PD.innerHTML = html;
  775. this.V = this.getByElement('#' + vid); //V:定义播放器对象全局变量
  776. }
  777. if (this.vars['crossorigin']) {
  778. this.V.crossOrigin = this.vars['crossorigin'];
  779. }
  780. try {
  781. this.V.volume = volume; //定义音量
  782. if (this.playbackRateArr && this.vars['playbackrate'] > -1) {
  783. if (this.vars['playbackrate'] < this.playbackRateArr.length) {
  784. this.playbackRateDefault = this.vars['playbackrate'];
  785. }
  786. this.V.playbackRate = this.playbackRateArr[this.playbackRateDefault][0]; //定义倍速
  787. }
  788. } catch(error) {}
  789. this.css(this.V, {
  790. width: '100%',
  791. height: '100%'
  792. });
  793. if (this.isM3u8) {
  794. var loadJsHandler = function() {
  795. thisTemp.embedHls(thisTemp.VA[0][0], v['autoplay']);
  796. };
  797. this.loadJs(javascriptPath + 'hls/hls.min.js', loadJsHandler);
  798. }
  799. this.css(this.V, 'backgroundColor', '#000000');
  800. //创建一个画布容器
  801. if (this.config['videoDrawImage']) {
  802. var canvasID = 'vcanvas' + this.randomString();
  803. var canvasDiv = document.createElement('div');
  804. canvasDiv.className = canvasID;
  805. this.PD.appendChild(canvasDiv);
  806. this.MD = this.getByElement(canvasID); //定义画布存储容器
  807. this.css(this.MD, {
  808. backgroundColor: '#000000',
  809. width: '100%',
  810. height: '100%',
  811. position: 'absolute',
  812. display: 'none',
  813. cursor: 'pointer',
  814. left: '0px',
  815. top: '0px',
  816. zIndex: '10'
  817. });
  818. var cvid = 'ccanvas' + this.randomString();
  819. this.MD.innerHTML = this.newCanvas(cvid, this.PD.offsetWidth, this.PD.offsetHeight);
  820. this.MDC = this.getByElement(cvid + '-canvas');
  821. this.MDCX = this.MDC.getContext('2d');
  822. }
  823. this.playerType = 'html5video';
  824. //播放器构建完成并且设置好样式
  825. //建立播放器的监听函数,包含操作监听及事件监听
  826. this.addVEvent();
  827. //根据清晰度的值构建清晰度切换按钮
  828. if (this.showFace) {
  829. this.definition();
  830. if (!this.vars['live'] && this.playbackRateArr && this.vars['playbackrate'] > -1) {
  831. this.playbackRate();
  832. }
  833. if (v['autoplay']) {
  834. this.loadingStart(true);
  835. }
  836. this.subtitleSwitch();
  837. }
  838. this.playerLoad();
  839. } else { //如果不支持HTML5-VIDEO则调用flashplayer
  840. this.embedSWF();
  841. }
  842. },
  843. /*
  844. 分析广告数据
  845. */
  846. adAnalysis: function() {
  847. var thisTemp = this;
  848. var v = this.vars;
  849. var isAdvShow = [];
  850. var i = 0;
  851. if (v['advertisements'] != '' && v['advertisements'].substr(0, 8) == 'website:') {
  852. var ajaxObj = {
  853. url: v['advertisements'].substr(8),
  854. success: function(data) {
  855. if (data) {
  856. var newData = {};
  857. var val = null;
  858. //对广告进行分析
  859. try {
  860. if (!thisTemp.isUndefined(data['front']) || !thisTemp.isUndefined(data['pause']) || !thisTemp.isUndefined(data['end']) || !thisTemp.isUndefined(data['insert']) || !thisTemp.isUndefined(data['other'])) {
  861. val = thisTemp.arrayDel(data['front']);
  862. if (!thisTemp.isUndefined(val)) {
  863. newData['front'] = val;
  864. }
  865. val = thisTemp.arrayDel(data['pause']);
  866. if (!thisTemp.isUndefined(val)) {
  867. newData['pause'] = val;
  868. }
  869. val = thisTemp.arrayDel(data['insert']);
  870. if (!thisTemp.isUndefined(val)) {
  871. newData['insert'] = val;
  872. if (!thisTemp.isUndefined(data['inserttime'])) {
  873. newData['inserttime'] = thisTemp.arrayInt(data['inserttime']);
  874. isAdvShow = [];
  875. for (i = 0; i < newData['inserttime'].length; i++) {
  876. isAdvShow.push(false);
  877. }
  878. newData['insertPlay'] = isAdvShow;
  879. }
  880. }
  881. val = thisTemp.arrayDel(data['end']);
  882. if (!thisTemp.isUndefined(val)) {
  883. newData['end'] = val;
  884. }
  885. val = thisTemp.arrayDel(data['other']);
  886. if (!thisTemp.isUndefined(val)) {
  887. newData['other'] = val;
  888. isAdvShow = [];
  889. var arrTemp = [];
  890. for (i = 0; i < val.length; i++) {
  891. isAdvShow.push(false);
  892. arrTemp.push(parseInt('0' + val[i]['startTime']));
  893. }
  894. newData['othertime'] = arrTemp;
  895. newData['otherPlay'] = isAdvShow;
  896. }
  897. }
  898. } catch(event) {
  899. thisTemp.log(event)
  900. }
  901. thisTemp.advertisements = newData;
  902. //对广告进行分析结束
  903. }
  904. thisTemp.getVideo();
  905. }
  906. };
  907. this.ajax(ajaxObj);
  908. } else {
  909. //根据广告分析
  910. this.adAnalysisOne('front', 'adfront', 'adfronttime', 'adfrontlink', 'adfronttype');
  911. this.adAnalysisOne('pause', 'adpause', 'adpausetime', 'adpauselink', 'adpausetype');
  912. this.adAnalysisOne('insert', 'adinsert', 'adinserttime', 'adinsertlink', 'adinserttype');
  913. this.adAnalysisOne('end', 'adend', 'adendtime', 'adendlink', 'adendtype');
  914. if (!this.isUndefined(this.advertisements['insert'])) {
  915. if (!this.isUndefined(v['inserttime'])) {
  916. thisTemp.advertisements['inserttime'] = v['inserttime'];
  917. }
  918. }
  919. if (!this.isUndefined(thisTemp.advertisements['inserttime'])) {
  920. thisTemp.advertisements['inserttime'] = thisTemp.arrayInt(thisTemp.advertisements['inserttime']);
  921. isInsert = [];
  922. for (i = 0; i < thisTemp.advertisements['inserttime'].length; i++) {
  923. isInsert.push(false);
  924. }
  925. thisTemp.advertisements['insertPlay'] = isInsert;
  926. }
  927. thisTemp.getVideo();
  928. }
  929. },
  930. /*
  931. 将广告数组数据里不是视频和图片的去除
  932. */
  933. arrayDel: function(arr) {
  934. if(this.isUndefined(arr)){
  935. return arr;
  936. }
  937. if (arr.length == 0) {
  938. return null;
  939. }
  940. var newArr = [];
  941. for (var i = 0; i < arr.length; i++) {
  942. var type = arr[i]['type'];
  943. if (type == 'mp4' || type == 'mov' || this.isStrImage(type)) {
  944. newArr.push(arr[i]);
  945. }
  946. }
  947. if (newArr.length > 0) {
  948. return newArr;
  949. }
  950. return null;
  951. },
  952. /*分析单个类型的广告*/
  953. adAnalysisOne: function(adType, adName, adTime, adLink, adStype) {
  954. var v = this.vars;
  955. if (this.isUndefined(v[adName])) {
  956. v[adName] = '';
  957. }
  958. if (this.isUndefined(v[adTime])) {
  959. v[adTime] = '';
  960. }
  961. if (this.isUndefined(v[adLink])) {
  962. v[adLink] = '';
  963. }
  964. if (this.isUndefined(v[adStype])) {
  965. v[adStype] = '';
  966. }
  967. if (v[adName] != '') {
  968. var adList = [];
  969. var ad = v[adName].split(',');
  970. var adtime = v[adTime].split(',');
  971. var adlink = v[adLink].split(',');
  972. var adstype = v[adStype].split(',');
  973. var i = 0;
  974. if (ad.length > 0) {
  975. var adLinkLen = adlink.length,
  976. adTimeLen = adtime.length;
  977. if (v[adLink] == '') {
  978. adLinkLen = 0;
  979. adlink = [];
  980. }
  981. if (v[adTime] == '') {
  982. adTimeLen = 0;
  983. adtime = [];
  984. }
  985. if (adLinkLen < ad.length) {
  986. for (i = adLinkLen; i < ad.length; i++) {
  987. adlink.push('');
  988. }
  989. }
  990. if (adTimeLen < ad.length) {
  991. for (i = adTimeLen; i < ad.length; i++) {
  992. adtime.push('');
  993. }
  994. }
  995. var adstypeLen = adstype.length;
  996. if (v[adStype] == '') {
  997. adstypeLen = 0;
  998. adstype = [];
  999. }
  1000. if (adstypeLen < ad.length) {
  1001. for (i = adstypeLen; i < ad.length; i++) {
  1002. adstype.push(this.getFileExt(ad[i]).replace('.', ''));
  1003. }
  1004. }
  1005. for (i = 0; i < ad.length; i++) {
  1006. var type = adstype[i];
  1007. if (type == 'mp4' || type == 'mov' || this.isStrImage(type)) {
  1008. var obj = {
  1009. file: ad[i],
  1010. type: type,
  1011. time: parseInt(adtime[i]) > 0 ? parseInt(adtime[i]) : this.ckplayerConfig['style']['advertisement']['time'],
  1012. link: adlink[i]
  1013. };
  1014. adList.push(obj);
  1015. }
  1016. }
  1017. if (this.isUndefined(this.advertisements)) {
  1018. this.advertisements = {};
  1019. }
  1020. if (adList.length > 0) {
  1021. this.advertisements[adType] = adList;
  1022. }
  1023. }
  1024. }
  1025. },
  1026. /*
  1027. 内部函数
  1028. 发送播放器加载成功的消息
  1029. */
  1030. playerLoad: function() {
  1031. var thisTemp = this;
  1032. if (this.isFirst) {
  1033. this.isFirst = false;
  1034. setTimeout(function() {
  1035. thisTemp.loadedHandler();
  1036. },1);
  1037. }
  1038. },
  1039. /*
  1040. 内部函数
  1041. 建立播放器的监听函数,包含操作监听及事件监听
  1042. */
  1043. addVEvent: function() {
  1044. var thisTemp = this;
  1045. var duration=0;
  1046. //监听视频单击事件
  1047. var eventVideoClick = function(event) {
  1048. thisTemp.videoClickXy={x:event.clientX,y:event.clientY};
  1049. thisTemp.videoClick();
  1050. };
  1051. this.addListenerInside('click', eventVideoClick);
  1052. this.addListenerInside('click', eventVideoClick, this.MDC);
  1053. //延迟计算加载失败事件
  1054. this.timerErrorFun();
  1055. //监听视频加载到元数据事件
  1056. var eventJudgeIsLive = function(event) {
  1057. thisTemp.sendJS('loadedmetadata');
  1058. if (typeof(thisTemp.V.duration) == 'number' && thisTemp.V.duration > 1) {
  1059. duration = thisTemp.V.duration;
  1060. if(!duration){
  1061. if(thisTemp.vars['duration']>0){
  1062. duration=thisTemp.vars['duration'];
  1063. }
  1064. }
  1065. if(thisTemp.vars['forceduration']>0){
  1066. duration=thisTemp.vars['forceduration'];
  1067. }
  1068. thisTemp.sendJS('duration', duration);
  1069. thisTemp.formatInserttime(duration);
  1070. if (thisTemp.adPlayerPlay) {
  1071. thisTemp.advertisementsTime(duration + 1);
  1072. }
  1073. thisTemp.durationSendJS = true;
  1074. }
  1075. thisTemp.judgeIsLive();
  1076. };
  1077. this.addListenerInside('loadedmetadata', eventJudgeIsLive);
  1078. //监听视频播放事件
  1079. var eventPlaying = function(event) {
  1080. thisTemp.playingHandler();
  1081. thisTemp.sendJS('play');
  1082. thisTemp.sendJS('paused', false);
  1083. if (!thisTemp.durationSendJS && typeof(thisTemp.V.duration) == 'number' && thisTemp.V.duration > 0) {
  1084. duration = thisTemp.V.duration;
  1085. if(!duration){
  1086. if(thisTemp.vars['duration']>0){
  1087. duration=thisTemp.vars['duration'];
  1088. }
  1089. }
  1090. if(thisTemp.vars['forceduration']>0){
  1091. duration=thisTemp.vars['forceduration'];
  1092. }
  1093. thisTemp.durationSendJS = true;
  1094. thisTemp.sendJS('duration', duration);
  1095. thisTemp.formatInserttime(duration);
  1096. }
  1097. };
  1098. this.addListenerInside('playing', eventPlaying);
  1099. //监听视频暂停事件
  1100. var eventPause = function(event) {
  1101. thisTemp.pauseHandler();
  1102. thisTemp.sendJS('pause');
  1103. thisTemp.sendJS('paused', true);
  1104. };
  1105. this.addListenerInside('pause', eventPause);
  1106. //监听视频播放结束事件
  1107. var eventEnded = function(event) {
  1108. thisTemp.endedHandler();
  1109. };
  1110. this.addListenerInside('ended', eventEnded);
  1111. //监听视频播放时间事件
  1112. var eventTimeupdate = function(event) {
  1113. if (thisTemp.timerLoading != null) {
  1114. thisTemp.loadingStart(false);
  1115. }
  1116. if (thisTemp.time) {
  1117. if (!thisTemp.adPlayerPlay) {
  1118. thisTemp.sendJS('time', thisTemp.time);
  1119. //监听中间插入广告是否需要播放
  1120. if (!thisTemp.isUndefined(thisTemp.advertisements['insert'])) {
  1121. thisTemp.checkAdInsert(thisTemp.time);
  1122. }
  1123. //监听其它广告
  1124. if (!thisTemp.isUndefined(thisTemp.advertisements['other'])) {
  1125. thisTemp.checkAdOther(thisTemp.time);
  1126. }
  1127. if (thisTemp.time < 3 && thisTemp.adReset) {
  1128. thisTemp.adReset = false;
  1129. thisTemp.endedAdReset();
  1130. }
  1131. } else { //如果是广告则进行广告倒计时
  1132. thisTemp.adPlayerTimeHandler(thisTemp.time);
  1133. }
  1134. }
  1135. };
  1136. this.addListenerInside('timeupdate', eventTimeupdate);
  1137. //监听视频缓冲事件
  1138. var eventWaiting = function(event) {
  1139. thisTemp.loadingStart(true);
  1140. };
  1141. this.addListenerInside('waiting', eventWaiting);
  1142. //监听视频seek开始事件
  1143. var eventSeeking = function(event) {
  1144. thisTemp.sendJS('seek', 'start');
  1145. };
  1146. this.addListenerInside('seeking', eventSeeking);
  1147. //监听视频seek结束事件
  1148. var eventSeeked = function(event) {
  1149. thisTemp.seekedHandler();
  1150. thisTemp.sendJS('seek', 'ended');
  1151. };
  1152. this.addListenerInside('seeked', eventSeeked);
  1153. //监听视频音量
  1154. var eventVolumeChange = function(event) {
  1155. try {
  1156. thisTemp.volumechangeHandler();
  1157. thisTemp.sendJS('volume', thisTemp.volume || thisTemp.V.volume);
  1158. } catch(event) {}
  1159. };
  1160. this.addListenerInside('volumechange', eventVolumeChange);
  1161. //监听全屏事件
  1162. var eventFullChange = function(event) {
  1163. var fullState = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
  1164. thisTemp.sendJS('full', fullState);
  1165. };
  1166. this.addListenerInside('fullscreenchange', eventFullChange);
  1167. this.addListenerInside('webkitfullscreenchange', eventFullChange);
  1168. this.addListenerInside('mozfullscreenchange', eventFullChange);
  1169. //建立界面
  1170. if (this.showFace) {
  1171. this.interFace();
  1172. }
  1173. },
  1174. /*
  1175. 内部函数
  1176. 重置界面元素
  1177. */
  1178. resetPlayer: function() {
  1179. this.timeTextHandler();
  1180. if (this.showFace) {
  1181. this.timeProgress(0, 1); //改变时间进度条宽
  1182. this.changeLoad(0);
  1183. this.initPlayPause(); //判断显示播放或暂停按钮
  1184. this.definition(); //构建清晰度按钮
  1185. this.showFrontNext(); //构建上一集下一集按钮
  1186. this.deletePrompt(); //删除提示点
  1187. this.deletePreview(); //删除预览图
  1188. this.trackHide(); //重置字幕
  1189. this.resetTrack();
  1190. this.trackElement = [];
  1191. this.track = [];
  1192. }
  1193. },
  1194. /*
  1195. 内部函数
  1196. 构建界面元素
  1197. */
  1198. interFace: function() {
  1199. this.showFace = true;
  1200. var thisTemp = this;
  1201. var html = ''; //控制栏内容
  1202. var i = 0;
  1203. var bWidth = 38,//按钮的宽
  1204. bHeight = 38; //按钮的高
  1205. var bBgColor = '#FFFFFF',//按钮元素默认颜色
  1206. bOverColor = '#0782F5'; //按钮元素鼠标经过时的颜色
  1207. var timeInto = this.formatTime(0) + ' / ' + this.formatTime(this.vars['duration']); //时间显示框默认显示内容
  1208. var randomS = this.randomString(10); //获取一个随机字符串
  1209. /*
  1210. 以下定义界面各元素的ID,统一以ID结束
  1211. */
  1212. var controlBarBgID = 'controlbgbar' + randomS,//控制栏背景
  1213. controlBarID = 'controlbar' + randomS,//控制栏容器
  1214. timeProgressBgID = 'timeprogressbg' + randomS,//播放进度条背景
  1215. loadProgressID = 'loadprogress' + randomS,//加载进度条
  1216. timeProgressID = 'timeprogress' + randomS,//播放进度条
  1217. timeBOBGID = 'timebobg' + randomS,//播放进度按钮容器,该元素为一个透明覆盖在播放进度条上
  1218. timeBOID = 'timebo' + randomS,//播放进度可拖动按钮外框
  1219. timeBWID = 'timebw' + randomS,//播放进度可拖动按钮内框
  1220. timeTextID = 'timetext' + randomS,//时间文本框
  1221. playID = 'play' + randomS,//播放按钮
  1222. pauseID = 'pause' + randomS,//暂停按钮
  1223. frontID = 'front' + randomS,//前一集按钮
  1224. nextID = 'next' + randomS,//下一集按钮
  1225. fullID = 'full' + randomS,//全屏按钮
  1226. escFullID = 'escfull' + randomS,//退出全屏按钮
  1227. muteID = 'mute' + randomS,//静音按钮
  1228. escMuteID = 'escmute' + randomS,//取消静音按钮
  1229. volumeID = 'volume' + randomS,//音量调节框容器
  1230. volumeDbgID = 'volumedbg' + randomS,//音量调节框容器背景
  1231. volumeBgID = 'volumebg' + randomS,//音量调节框背景层
  1232. volumeUpID = 'volumeup' + randomS,//音量调节框可变宽度层
  1233. volumeBOID = 'volumebo' + randomS,//音量调节按钮外框
  1234. volumeBWID = 'volumebw' + randomS,//音量调节按钮内框
  1235. definitionID = 'definition' + randomS,//清晰度容器
  1236. definitionPID = 'definitionp' + randomS,//清晰度列表容器
  1237. playbackRateID = 'playbackrate' + randomS,//倍速容器
  1238. playbackRatePID = 'playbackratep' + randomS,//倍速列表容器
  1239. subtitlesID = 'subtitles' + randomS,//多字幕容器
  1240. subtitlesPID = 'subtitlesp' + randomS,//多字幕列表容器
  1241. promptBgID = 'promptbg' + randomS,//提示框背景
  1242. promptID = 'prompt' + randomS,//提示框
  1243. dlineID = 'dline' + randomS,//分隔线共用前缀
  1244. menuID = 'menu' + randomS,//右键容器
  1245. pauseCenterID = 'pausecenter' + randomS,//中间暂停按钮
  1246. loadingID = 'loading' + randomS,//缓冲
  1247. errorTextID = 'errortext' + randomS,//错误文本框
  1248. logoID = 'logo' + randomS,//logo
  1249. adBackgroundID = 'background' + randomS,//广告背景图片
  1250. adElementID = 'adelement' + randomS,//广告容器
  1251. adBarID = 'adBar' + randomS,//广告顶部倒计时,跳过广告,静音按钮容器
  1252. adSkipID = 'adskip' + randomS,//跳过广告按钮
  1253. adTimeID = 'adtime' + randomS,//倒计时按钮
  1254. adLinkID = 'adlink' + randomS,//广告链接按钮
  1255. adMuteID = 'admute' + randomS,//广告静音按钮
  1256. adEscMuteID = 'adescmute' + randomS,//广告取消静音按钮
  1257. adPauseCloseID = 'adpauseclose' + randomS; //暂停广场的关闭按钮
  1258. /*
  1259. 构建一些PD(播放器容器)里使用的元素
  1260. */
  1261. var controlBarBg = document.createElement('div'),
  1262. controlBar = document.createElement('div'),
  1263. timeProgressBg = document.createElement('div'),
  1264. timeBoBg = document.createElement('div'),
  1265. pauseCenter = document.createElement('div'),
  1266. errorText = document.createElement('div'),
  1267. promptBg = document.createElement('div'),
  1268. prompt = document.createElement('div'),
  1269. menuDiv = document.createElement('div'),
  1270. definitionP = document.createElement('div'),
  1271. playbackrateP = document.createElement('div'),
  1272. subtitlesP = document.createElement('div'),
  1273. loading = document.createElement('div'),
  1274. logo = document.createElement('div'),
  1275. adBackground = document.createElement('div'),
  1276. adElement = document.createElement('div'),
  1277. adBar = document.createElement('div'),
  1278. adLink = document.createElement('div'),
  1279. adPauseClose = document.createElement('div');
  1280. /*
  1281. 定义各节点的样式
  1282. */
  1283. controlBarBg.className = controlBarBgID;
  1284. controlBar.className = controlBarID;
  1285. timeProgressBg.className = timeProgressBgID;
  1286. timeBoBg.className = timeBOBGID;
  1287. promptBg.className = promptBgID;
  1288. prompt.className = promptID;
  1289. menuDiv.className = menuID;
  1290. definitionP.className = definitionPID;
  1291. playbackrateP.className = playbackRatePID;
  1292. subtitlesP.className = subtitlesPID;
  1293. pauseCenter.className = pauseCenterID;
  1294. loading.className = loadingID;
  1295. logo.className = logoID;
  1296. errorText.className = errorTextID;
  1297. adBackground.className = adBackgroundID;
  1298. adElement.className = adElementID;
  1299. adBar.className = adBarID;
  1300. adLink.className = adLinkID;
  1301. adPauseClose.className = adPauseCloseID;
  1302. /*
  1303. 加载节点到播放器容器中
  1304. */
  1305. this.PD.appendChild(controlBarBg);
  1306. this.PD.appendChild(controlBar);
  1307. this.PD.appendChild(timeProgressBg);
  1308. this.PD.appendChild(timeBoBg);
  1309. this.PD.appendChild(promptBg);
  1310. this.PD.appendChild(prompt);
  1311. this.PD.appendChild(definitionP);
  1312. this.PD.appendChild(playbackrateP);
  1313. this.PD.appendChild(subtitlesP);
  1314. this.PD.appendChild(pauseCenter);
  1315. this.PD.appendChild(loading);
  1316. this.PD.appendChild(errorText);
  1317. this.PD.appendChild(logo);
  1318. this.PD.appendChild(adBackground);
  1319. this.PD.appendChild(adElement);
  1320. this.PD.appendChild(adBar);
  1321. this.PD.appendChild(adLink);
  1322. this.PD.appendChild(adPauseClose);
  1323. this.body.appendChild(menuDiv);
  1324. if (this.vars['live']) { //如果是直播,时间显示文本框里显示当前系统时间
  1325. timeInto = this.getNowDate();
  1326. }
  1327. /*
  1328. 构建控制栏的内容
  1329. */
  1330. html += '<div class="' + playID + '" data-title="' + thisTemp.language['play'] + '">' + this.newCanvas(playID, bWidth, bHeight) + '</div>'; //播放按钮
  1331. html += '<div class="' + pauseID + '" data-title="' + thisTemp.language['pause'] + '">' + this.newCanvas(pauseID, bWidth, bHeight) + '</div>'; //暂停按钮
  1332. html += '<div class="' + dlineID + '-la"></div>'; //分隔线
  1333. html += '<div class="' + frontID + '" data-title="' + thisTemp.language['front'] + '">' + this.newCanvas(frontID, bWidth, bHeight) + '</div>'; //前一集按钮
  1334. html += '<div class="' + dlineID + '-lb"></div>'; //分隔线
  1335. html += '<div class="' + nextID + '" data-title="' + thisTemp.language['next'] + '">' + this.newCanvas(nextID, bWidth, bHeight) + '</div>'; //下一集按钮
  1336. html += '<div class="' + dlineID + '-lc"></div>'; //分隔线
  1337. html += '<div class="' + timeTextID + '">' + timeInto + '</div>'; //时间文本
  1338. html += '<div class="' + fullID + '" data-title="' + thisTemp.language['full'] + '">' + this.newCanvas(fullID, bWidth, bHeight) + '</div>'; //全屏按钮
  1339. html += '<div class="' + escFullID + '" data-title="' + thisTemp.language['escFull'] + '">' + this.newCanvas(escFullID, bWidth, bHeight) + '</div>'; //退出全屏按钮
  1340. html += '<div class="' + dlineID + '-ra"></div>'; //分隔线
  1341. html += '<div class="' + definitionID + '" data-title="' + thisTemp.language['definition'] + '"></div>'; //清晰度容器
  1342. html += '<div class="' + dlineID + '-rb"></div>'; //分隔线
  1343. html += '<div class="' + playbackRateID + '" data-title="' + thisTemp.language['playbackRate'] + '"></div>'; //倍速
  1344. html += '<div class="' + dlineID + '-rc"></div>'; //分隔线
  1345. html += '<div class="' + subtitlesID + '" data-title="' + thisTemp.language['subtitles'] + '"></div>'; //字幕
  1346. html += '<div class="' + dlineID + '-rd"></div>'; //分隔线
  1347. html += '<div class="' + volumeID + '"><div class="' + volumeDbgID + '"><div class="' + volumeBgID + '"><div class="' + volumeUpID + '"></div></div><div class="' + volumeBOID + '"><div class="' + volumeBWID + '"></div></div></div></div>'; //音量调节框,音量调节按钮
  1348. html += '<div class="' + muteID + '" data-title="' + thisTemp.language['mute'] + '">' + this.newCanvas(muteID, bWidth, bHeight) + '</div>'; //静音按钮
  1349. html += '<div class="' + escMuteID + '" data-title="' + thisTemp.language['escMute'] + '">' + this.newCanvas(escMuteID, bWidth, bHeight) + '</div>'; //退出静音按钮
  1350. html += '<div class="' + dlineID + '-re"></div>'; //分隔线
  1351. this.getByElement(controlBarID).innerHTML = html;
  1352. //构建进度条内容
  1353. this.getByElement(timeProgressBgID).innerHTML = '<div class="' + loadProgressID + '"></div><div class="' + timeProgressID + '"></div>';
  1354. this.getByElement(timeBOBGID).innerHTML = '<div class="' + timeBOID + '"><div class="' + timeBWID + '"></div></div>';
  1355. //构建进度条内容结束
  1356. this.getByElement(pauseCenterID).innerHTML = this.newCanvas(pauseCenterID, 80, 80); //构建中间暂停按钮
  1357. this.getByElement(loadingID).innerHTML = this.newCanvas(loadingID, 60, 60); //构建中间缓冲时显示的图标
  1358. this.getByElement(errorTextID).innerHTML = this.language['error']; //构建错误时显示的文本框
  1359. //构建广告相关
  1360. html = '<div class="' + adTimeID + '">' + this.language['adTime'].replace('{$second}', 0) + '</div>';
  1361. html += '<div class="' + adMuteID + '">' + this.newCanvas(adMuteID, 30, 30) + '</div>';
  1362. html += '<div class="' + adEscMuteID + '">' + this.newCanvas(adEscMuteID, 30, 30) + '</div>';
  1363. html += '<div class="' + adSkipID + '"></div>';
  1364. this.getByElement(adBarID).innerHTML = html;
  1365. this.getByElement(adLinkID).innerHTML = this.language['adLink'];
  1366. this.getByElement(adPauseCloseID).innerHTML = this.newCanvas(adPauseCloseID, 20, 20);
  1367. if (this.ckplayerConfig['style']['logo']) {
  1368. if (this.ckplayerConfig['style']['logo']['file']) {
  1369. var logoFile = this.ckplayerConfig['style']['logo']['file'];
  1370. if (logoFile.substr(0, 15) == 'data:image/png;' || logoFile.substr(0, 15) == 'data:image/jpg;' || logoFile.substr(0, 16) == 'data:image/jpeg;') {
  1371. this.getByElement(logoID).innerHTML = '<img src="' + logoFile + '" border="0">'; //构建logo
  1372. }
  1373. }
  1374. } else {
  1375. this.getByElement(logoID).innerHTML = this.vars['logo'] || this.logo || ''; //构建logo
  1376. }
  1377. var pd = this.PD;
  1378. //CB:Object:全局变量,将一些全局需要用到的元素统一放在CB对象里
  1379. this.CB = {
  1380. controlBarBg: this.getByElement(controlBarBgID, pd),
  1381. controlBar: this.getByElement(controlBarID, pd),
  1382. promptBg: this.getByElement(promptBgID, pd),
  1383. prompt: this.getByElement(promptID, pd),
  1384. timeProgressBg: this.getByElement(timeProgressBgID, pd),
  1385. loadProgress: this.getByElement(loadProgressID, pd),
  1386. timeProgress: this.getByElement(timeProgressID, pd),
  1387. timeBoBg: this.getByElement(timeBOBGID, pd),
  1388. timeButton: this.getByElement(timeBOID, pd),
  1389. timeText: this.getByElement(timeTextID, pd),
  1390. play: this.getByElement(playID, pd),
  1391. front: this.getByElement(frontID, pd),
  1392. next: this.getByElement(nextID, pd),
  1393. pause: this.getByElement(pauseID, pd),
  1394. definition: this.getByElement(definitionID, pd),
  1395. definitionP: this.getByElement(definitionPID, pd),
  1396. definitionLine: this.getByElement(dlineID + '-rb', pd),
  1397. playbackrate: this.getByElement(playbackRateID, pd),
  1398. playbackrateP: this.getByElement(playbackRatePID, pd),
  1399. playbackrateLine: this.getByElement(dlineID + '-rc', pd),
  1400. subtitles: this.getByElement(subtitlesID, pd),
  1401. subtitlesP: this.getByElement(subtitlesPID, pd),
  1402. subtitlesLine: this.getByElement(dlineID + '-rd', pd),
  1403. full: this.getByElement(fullID, pd),
  1404. escFull: this.getByElement(escFullID, pd),
  1405. mute: this.getByElement(muteID, pd),
  1406. escMute: this.getByElement(escMuteID, pd),
  1407. volume: this.getByElement(volumeID, pd),
  1408. volumeBg: this.getByElement(volumeBgID, pd),
  1409. volumeUp: this.getByElement(volumeUpID, pd),
  1410. volumeBO: this.getByElement(volumeBOID, pd),
  1411. pauseCenter: this.getByElement(pauseCenterID, pd),
  1412. menu: this.getByElement(menuID),
  1413. loading: this.getByElement(loadingID, pd),
  1414. loadingCanvas: this.getByElement(loadingID + '-canvas', pd),
  1415. errorText: this.getByElement(errorTextID, pd),
  1416. logo: this.getByElement(logoID, pd),
  1417. playLine: this.getByElement(dlineID + '-la', pd),
  1418. frontLine: this.getByElement(dlineID + '-lb', pd),
  1419. nextLine: this.getByElement(dlineID + '-lc', pd),
  1420. fullLine: this.getByElement(dlineID + '-ra'),
  1421. muteLine: this.getByElement(dlineID + '-re', pd),
  1422. adBackground: this.getByElement(adBackgroundID, pd),
  1423. adElement: this.getByElement(adElementID, pd),
  1424. adBar: this.getByElement(adBarID, pd),
  1425. adSkip: this.getByElement(adSkipID, pd),
  1426. adTime: this.getByElement(adTimeID, pd),
  1427. adLink: this.getByElement(adLinkID, pd),
  1428. adMute: this.getByElement(adMuteID, pd),
  1429. adEscMute: this.getByElement(adEscMuteID, pd),
  1430. adPauseClose: this.getByElement(adPauseCloseID, pd)
  1431. };
  1432. this.buttonWidth = {
  1433. play: bWidth,
  1434. full: bWidth,
  1435. front: bWidth,
  1436. next: bWidth,
  1437. mute: bWidth
  1438. };
  1439. //定义界面元素的样式
  1440. //控制栏背景
  1441. this.css(controlBarBgID, {
  1442. width: '100%',
  1443. height: bHeight + 'px',
  1444. backgroundColor: '#000000',
  1445. position: 'absolute',
  1446. bottom: '0px',
  1447. filter: 'alpha(opacity:0.8)',
  1448. opacity: '0.8',
  1449. zIndex: '990'
  1450. });
  1451. //控制栏容器
  1452. this.css(controlBarID, {
  1453. width: '100%',
  1454. height: bHeight + 'px',
  1455. position: 'absolute',
  1456. bottom: '0px',
  1457. zIndex: '990'
  1458. });
  1459. //中间暂停按钮
  1460. this.css(pauseCenterID, {
  1461. width: '80px',
  1462. height: '80px',
  1463. borderRadius: '50%',
  1464. position: 'absolute',
  1465. display: 'none',
  1466. cursor: 'pointer',
  1467. zIndex: '996'
  1468. });
  1469. //loading
  1470. this.css(loadingID, {
  1471. width: '60px',
  1472. height: '60px',
  1473. position: 'absolute',
  1474. display: 'none',
  1475. zIndex: '996'
  1476. });
  1477. //出错文本框
  1478. this.css(errorTextID, {
  1479. width: '120px',
  1480. height: '30px',
  1481. lineHeight: '30px',
  1482. color: '#FFFFFF',
  1483. fontSize: '14px',
  1484. textAlign: 'center',
  1485. position: 'absolute',
  1486. display: 'none',
  1487. zIndex: '101',
  1488. cursor: 'default',
  1489. zIndex: '996'
  1490. });
  1491. //定义logo文字的样式
  1492. this.css(logoID, {
  1493. height: '30px',
  1494. lineHeight: '30px',
  1495. color: '#FFFFFF',
  1496. fontFamily: 'Arial',
  1497. fontSize: '28px',
  1498. textAlign: 'center',
  1499. position: 'absolute',
  1500. float: 'left',
  1501. left: '-1000px',
  1502. top: '20px',
  1503. zIndex: '996',
  1504. filter: 'alpha(opacity:0.8)',
  1505. opacity: '0.8',
  1506. cursor: 'default'
  1507. });
  1508. this.css(this.CB['loadingCanvas'], {
  1509. transform: 'rotate(0deg)',
  1510. msTransform: 'rotate(0deg)',
  1511. mozTransform: 'rotate(0deg)',
  1512. webkitTransform: 'rotate(0deg)',
  1513. oTransform: 'rotate(0deg)'
  1514. });
  1515. //定义提示语的样式
  1516. this.css([promptBgID, promptID], {
  1517. height: '30px',
  1518. lineHeight: '30px',
  1519. color: '#FFFFFF',
  1520. fontSize: '14px',
  1521. textAlign: 'center',
  1522. position: 'absolute',
  1523. borderRadius: '5px',
  1524. paddingLeft: '5px',
  1525. paddingRight: '5px',
  1526. bottom: '0px',
  1527. display: 'none',
  1528. zIndex: '995'
  1529. });
  1530. this.css(promptBgID, {
  1531. backgroundColor: '#000000',
  1532. filter: 'alpha(opacity:0.5)',
  1533. opacity: '0.5'
  1534. });
  1535. //时间进度条背景容器
  1536. this.css(timeProgressBgID, {
  1537. width: '100%',
  1538. height: '6px',
  1539. backgroundColor: '#3F3F3F',
  1540. overflow: 'hidden',
  1541. position: 'absolute',
  1542. bottom: '38px',
  1543. zIndex: '888'
  1544. });
  1545. //加载进度和时间进度
  1546. this.css([loadProgressID, timeProgressID], {
  1547. width: '1px',
  1548. height: '6px',
  1549. position: 'absolute',
  1550. bottom: '38px',
  1551. top: '0px',
  1552. zIndex: '991'
  1553. });
  1554. this.css(loadProgressID, 'backgroundColor', '#6F6F6F');
  1555. this.css(timeProgressID, 'backgroundColor', bOverColor);
  1556. //时间进度按钮
  1557. this.css(timeBOBGID, {
  1558. width: '100%',
  1559. height: '14px',
  1560. overflow: 'hidden',
  1561. position: 'absolute',
  1562. bottom: '34px',
  1563. cursor: 'pointer',
  1564. zIndex: '992'
  1565. });
  1566. this.css(timeBOID, {
  1567. width: '14px',
  1568. height: '14px',
  1569. overflow: 'hidden',
  1570. borderRadius: '50%',
  1571. backgroundColor: bBgColor,
  1572. cursor: 'pointer',
  1573. position: 'absolute',
  1574. top: '0px',
  1575. zIndex: '200'
  1576. });
  1577. this.css(timeBWID, {
  1578. width: '8px',
  1579. height: '8px',
  1580. overflow: 'hidden',
  1581. borderRadius: '50%',
  1582. position: 'absolute',
  1583. backgroundColor: bOverColor,
  1584. left: '3px',
  1585. top: '3px'
  1586. });
  1587. this.css(timeTextID, {
  1588. lineHeight: bHeight + 'px',
  1589. color: '#FFFFFF',
  1590. fontFamily: 'arial',
  1591. fontSize: '16px',
  1592. paddingLeft: '10px',
  1593. float: 'left',
  1594. overflow: 'hidden',
  1595. cursor: 'default'
  1596. });
  1597. //分隔线
  1598. this.css([dlineID + '-la', dlineID + '-lb', dlineID + '-lc', dlineID + '-ra', dlineID + '-rb', dlineID + '-rc', dlineID + '-rd', dlineID + '-re'], {
  1599. width: '0px',
  1600. height: bHeight + 'px',
  1601. overflow: 'hidden',
  1602. borderLeft: '1px solid #303030',
  1603. borderRight: '1px solid #151515',
  1604. filter: 'alpha(opacity:0.9)',
  1605. opacity: '0.9'
  1606. });
  1607. this.css([dlineID + '-la', dlineID + '-lb', dlineID + '-lc'], 'float', 'left');
  1608. this.css([dlineID + '-ra', dlineID + '-rb', dlineID + '-rc', dlineID + '-rd', dlineID + '-re'], 'float', 'right');
  1609. this.css([dlineID + '-lb', dlineID + '-lc', dlineID + '-rb', dlineID + '-rc', dlineID + '-rd'], 'display', 'none');
  1610. //播放/暂停/上一集/下一集按钮
  1611. this.css([playID, pauseID, frontID, nextID], {
  1612. width: bWidth + 'px',
  1613. height: bHeight + 'px',
  1614. float: 'left',
  1615. overflow: 'hidden',
  1616. cursor: 'pointer'
  1617. });
  1618. this.css([frontID, nextID], 'display', 'none');
  1619. //初始化判断播放/暂停按钮隐藏项
  1620. this.initPlayPause();
  1621. //设置静音/取消静音的按钮样式
  1622. this.css([muteID, escMuteID], {
  1623. width: bWidth + 'px',
  1624. height: bHeight + 'px',
  1625. float: 'right',
  1626. overflow: 'hidden',
  1627. cursor: 'pointer'
  1628. });
  1629. if (this.vars['volume'] > 0) {
  1630. this.css(escMuteID, 'display', 'none');
  1631. } else {
  1632. this.css(muteID, 'display', 'none');
  1633. }
  1634. if (!this.ckplayerConfig['config']['mobileVolumeBarShow'] && this.isMobile()) {
  1635. this.css([muteID, escMuteID, volumeID, volumeDbgID, dlineID + '-re'], {
  1636. display: 'none'
  1637. });
  1638. }
  1639. //音量调节框
  1640. this.css([volumeID, volumeDbgID], {
  1641. width: '70px',
  1642. height: bHeight + 'px',
  1643. overflow: 'hidden',
  1644. float: 'right'
  1645. });
  1646. this.css(volumeDbgID, {
  1647. position: 'absolute'
  1648. });
  1649. this.css([volumeBgID, volumeUpID], {
  1650. width: '60px',
  1651. height: '6px',
  1652. overflow: 'hidden',
  1653. borderRadius: '5px',
  1654. cursor: 'pointer'
  1655. });
  1656. this.css(volumeBgID, {
  1657. position: 'absolute',
  1658. top: '16px'
  1659. });
  1660. this.css(volumeBgID, 'backgroundColor', '#666666');
  1661. this.css(volumeUpID, 'backgroundColor', bOverColor);
  1662. this.buttonWidth['volume'] = 100;
  1663. //音量调节按钮
  1664. this.css(volumeBOID, {
  1665. width: '12px',
  1666. height: '12px',
  1667. overflow: 'hidden',
  1668. borderRadius: '50%',
  1669. position: 'absolute',
  1670. backgroundColor: bBgColor,
  1671. top: '13px',
  1672. left: '0px',
  1673. cursor: 'pointer'
  1674. });
  1675. this.css(volumeBWID, {
  1676. width: '6px',
  1677. height: '6px',
  1678. overflow: 'hidden',
  1679. borderRadius: '50%',
  1680. position: 'absolute',
  1681. backgroundColor: bOverColor,
  1682. left: '3px',
  1683. top: '3px'
  1684. });
  1685. //清晰度容器
  1686. this.css(definitionID, {
  1687. lineHeight: bHeight + 'px',
  1688. color: '#FFFFFF',
  1689. float: 'right',
  1690. fontSize: '14px',
  1691. textAlign: 'center',
  1692. overflow: 'hidden',
  1693. display: 'none',
  1694. cursor: 'pointer'
  1695. });
  1696. this.css(definitionPID, {
  1697. lineHeight: (bHeight - 8) + 'px',
  1698. color: '#FFFFFF',
  1699. overflow: 'hidden',
  1700. position: 'absolute',
  1701. bottom: '4px',
  1702. backgroundColor: '#000000',
  1703. textAlign: 'center',
  1704. zIndex: '995',
  1705. cursor: 'pointer',
  1706. display: 'none'
  1707. });
  1708. //倍速容器
  1709. this.css(playbackRateID, {
  1710. lineHeight: bHeight + 'px',
  1711. color: '#FFFFFF',
  1712. float: 'right',
  1713. fontSize: '14px',
  1714. textAlign: 'center',
  1715. overflow: 'hidden',
  1716. display: 'none',
  1717. cursor: 'pointer'
  1718. });
  1719. this.css(playbackRatePID, {
  1720. lineHeight: (bHeight - 8) + 'px',
  1721. color: '#FFFFFF',
  1722. overflow: 'hidden',
  1723. position: 'absolute',
  1724. bottom: '4px',
  1725. backgroundColor: '#000000',
  1726. textAlign: 'center',
  1727. zIndex: '995',
  1728. cursor: 'pointer',
  1729. display: 'none'
  1730. });
  1731. //字幕容器
  1732. this.css(subtitlesID, {
  1733. lineHeight: bHeight + 'px',
  1734. color: '#FFFFFF',
  1735. float: 'right',
  1736. fontSize: '14px',
  1737. textAlign: 'center',
  1738. overflow: 'hidden',
  1739. display: 'none',
  1740. cursor: 'pointer'
  1741. });
  1742. this.css(subtitlesPID, {
  1743. lineHeight: (bHeight - 8) + 'px',
  1744. color: '#FFFFFF',
  1745. overflow: 'hidden',
  1746. position: 'absolute',
  1747. bottom: '4px',
  1748. backgroundColor: '#000000',
  1749. textAlign: 'center',
  1750. zIndex: '995',
  1751. cursor: 'pointer',
  1752. display: 'none'
  1753. });
  1754. //设置全屏/退出全屏按钮样式
  1755. this.css([fullID, escFullID], {
  1756. width: bWidth + 'px',
  1757. height: bHeight + 'px',
  1758. float: 'right',
  1759. overflow: 'hidden',
  1760. cursor: 'pointer'
  1761. });
  1762. this.css(escFullID, 'display', 'none');
  1763. //设置广告背景层样式
  1764. this.css(adBackgroundID, {
  1765. width: '100%',
  1766. height: '100%',
  1767. backgroundColor: '#000000',
  1768. position: 'absolute',
  1769. top: '0px',
  1770. zIndex: '997',
  1771. display: 'none'
  1772. });
  1773. this.css(adElementID, {
  1774. position: 'absolute',
  1775. overflow: 'hidden',
  1776. top: '0px',
  1777. zIndex: '998',
  1778. float: 'center',
  1779. display: 'none'
  1780. });
  1781. this.css(adBarID, {
  1782. position: 'absolute',
  1783. overflow: 'hidden',
  1784. top: '10px',
  1785. right: '10px',
  1786. zIndex: '999',
  1787. textAlign: 'right',
  1788. display: 'none'
  1789. });
  1790. this.css(adTimeID, {
  1791. backgroundColor: '#000000',
  1792. color: '#FF0000',
  1793. paddingLeft: '10px',
  1794. paddingRight: '10px',
  1795. lineHeight: (bHeight - 8) + 'px',
  1796. marginLeft: '5px',
  1797. float: 'right',
  1798. cursor: 'pointer'
  1799. });
  1800. this.css([adMuteID, adEscMuteID], {
  1801. backgroundColor: '#000000',
  1802. width: '30px',
  1803. height: '30px',
  1804. marginLeft: '5px',
  1805. float: 'right',
  1806. display: 'none',
  1807. cursor: 'pointer'
  1808. });
  1809. this.css(adSkipID, {
  1810. backgroundColor: '#000000',
  1811. lineHeight: (bHeight - 8) + 'px',
  1812. color: '#FFFFFF',
  1813. paddingLeft: '10px',
  1814. paddingRight: '10px',
  1815. float: 'right',
  1816. display: 'none',
  1817. cursor: 'pointer'
  1818. });
  1819. this.css(adLinkID, {
  1820. backgroundColor: '#ea5503',
  1821. lineHeight: (bHeight - 8) + 'px',
  1822. color: '#FFFFFF',
  1823. paddingLeft: '10px',
  1824. paddingRight: '10px',
  1825. position: 'absolute',
  1826. overflow: 'hidden',
  1827. bottom: '10px',
  1828. right: '10px',
  1829. zIndex: '999',
  1830. display: 'none'
  1831. });
  1832. this.css(adPauseCloseID, {
  1833. backgroundColor: '#f7f7f7',
  1834. //f8f7f7
  1835. widht: '20px',
  1836. height: '20px',
  1837. position: 'absolute',
  1838. overflow: 'hidden',
  1839. zIndex: '999',
  1840. top: '60px',
  1841. left: '30px',
  1842. borderRadius: '20px',
  1843. display: 'none',
  1844. cursor: 'pointer'
  1845. });
  1846. //构建各按钮的形状
  1847. //播放按钮
  1848. var cPlay = this.getByElement(playID + '-canvas').getContext('2d');
  1849. var cPlayFillRect = function() {
  1850. thisTemp.canvasFill(cPlay, [[12, 10], [29, 19], [12, 28]]);
  1851. };
  1852. cPlay.fillStyle = bBgColor;
  1853. cPlayFillRect();
  1854. var cPlayOver = function(event) {
  1855. cPlay.clearRect(0, 0, bWidth, bHeight);
  1856. cPlay.fillStyle = bOverColor;
  1857. cPlayFillRect();
  1858. };
  1859. var cPlayOut = function(event) {
  1860. cPlay.clearRect(0, 0, bWidth, bHeight);
  1861. cPlay.fillStyle = bBgColor;
  1862. cPlayFillRect();
  1863. };
  1864. this.addListenerInside('mouseover', cPlayOver, this.getByElement(playID + '-canvas'));
  1865. this.addListenerInside('mouseout', cPlayOut, this.getByElement(playID + '-canvas'));
  1866. //暂停按钮
  1867. var cPause = this.getByElement(pauseID + '-canvas').getContext('2d');
  1868. var cPauseFillRect = function() {
  1869. thisTemp.canvasFillRect(cPause, [[10, 10, 5, 18], [22, 10, 5, 18]]);
  1870. };
  1871. cPause.fillStyle = bBgColor;
  1872. cPauseFillRect();
  1873. var cPauseOver = function(event) {
  1874. cPause.clearRect(0, 0, bWidth, bHeight);
  1875. cPause.fillStyle = bOverColor;
  1876. cPauseFillRect();
  1877. };
  1878. var cPauseOut = function(event) {
  1879. cPause.clearRect(0, 0, bWidth, bHeight);
  1880. cPause.fillStyle = bBgColor;
  1881. cPauseFillRect();
  1882. };
  1883. this.addListenerInside('mouseover', cPauseOver, this.getByElement(pauseID + '-canvas'));
  1884. this.addListenerInside('mouseout', cPauseOut, this.getByElement(pauseID + '-canvas'));
  1885. //前一集按钮
  1886. var cFront = this.getByElement(frontID + '-canvas').getContext('2d');
  1887. var cFrontFillRect = function() {
  1888. thisTemp.canvasFill(cFront, [[16, 19], [30, 10], [30, 28]]);
  1889. thisTemp.canvasFillRect(cFront, [[8, 10, 5, 18]]);
  1890. };
  1891. cFront.fillStyle = bBgColor;
  1892. cFrontFillRect();
  1893. var cFrontOver = function(event) {
  1894. cFront.clearRect(0, 0, bWidth, bHeight);
  1895. cFront.fillStyle = bOverColor;
  1896. cFrontFillRect();
  1897. };
  1898. var cFrontOut = function(event) {
  1899. cFront.clearRect(0, 0, bWidth, bHeight);
  1900. cFront.fillStyle = bBgColor;
  1901. cFrontFillRect();
  1902. };
  1903. this.addListenerInside('mouseover', cFrontOver, this.getByElement(frontID + '-canvas'));
  1904. this.addListenerInside('mouseout', cFrontOut, this.getByElement(frontID + '-canvas'));
  1905. //下一集按钮
  1906. var cNext = this.getByElement(nextID + '-canvas').getContext('2d');
  1907. var cNextFillRect = function() {
  1908. thisTemp.canvasFill(cNext, [[8, 10], [22, 19], [8, 28]]);
  1909. thisTemp.canvasFillRect(cNext, [[25, 10, 5, 18]]);
  1910. };
  1911. cNext.fillStyle = bBgColor;
  1912. cNextFillRect();
  1913. var cNextOver = function(event) {
  1914. cNext.clearRect(0, 0, bWidth, bHeight);
  1915. cNext.fillStyle = bOverColor;
  1916. cNextFillRect();
  1917. };
  1918. var cNextOut = function(event) {
  1919. cNext.clearRect(0, 0, bWidth, bHeight);
  1920. cNext.fillStyle = bBgColor;
  1921. cNextFillRect();
  1922. };
  1923. this.addListenerInside('mouseover', cNextOver, this.getByElement(nextID + '-canvas'));
  1924. this.addListenerInside('mouseout', cNextOut, this.getByElement(nextID + '-canvas'));
  1925. //全屏按钮
  1926. var cFull = this.getByElement(fullID + '-canvas').getContext('2d');
  1927. var cFullFillRect = function() {
  1928. thisTemp.canvasFillRect(cFull, [[19, 10, 9, 3], [25, 13, 3, 6], [10, 19, 3, 9], [13, 25, 6, 3]]);
  1929. };
  1930. cFull.fillStyle = bBgColor;
  1931. cFullFillRect();
  1932. var cFullOver = function() {
  1933. cFull.clearRect(0, 0, bWidth, bHeight);
  1934. cFull.fillStyle = bOverColor;
  1935. cFullFillRect();
  1936. };
  1937. var cFullOut = function() {
  1938. cFull.clearRect(0, 0, bWidth, bHeight);
  1939. cFull.fillStyle = bBgColor;
  1940. cFullFillRect();
  1941. };
  1942. this.addListenerInside('mouseover', cFullOver, this.getByElement(fullID + '-canvas'));
  1943. this.addListenerInside('mouseout', cFullOut, this.getByElement(fullID + '-canvas'));
  1944. //定义退出全屏按钮样式
  1945. var cEscFull = this.getByElement(escFullID + '-canvas').getContext('2d');
  1946. var cEscFullFillRect = function() {
  1947. thisTemp.canvasFillRect(cEscFull, [[20, 9, 3, 9], [23, 15, 6, 3], [9, 20, 9, 3], [15, 23, 3, 6]]);
  1948. };
  1949. cEscFull.fillStyle = bBgColor;
  1950. cEscFullFillRect();
  1951. var cEscFullOver = function() {
  1952. cEscFull.clearRect(0, 0, bWidth, bHeight);
  1953. cEscFull.fillStyle = bOverColor;
  1954. cEscFullFillRect();
  1955. };
  1956. var cEscFullOut = function() {
  1957. cEscFull.clearRect(0, 0, bWidth, bHeight);
  1958. cEscFull.fillStyle = bBgColor;
  1959. cEscFullFillRect();
  1960. };
  1961. this.addListenerInside('mouseover', cEscFullOver, this.getByElement(escFullID + '-canvas'));
  1962. this.addListenerInside('mouseout', cEscFullOut, this.getByElement(escFullID + '-canvas'));
  1963. //定义静音按钮的样式
  1964. var cMute = this.getByElement(muteID + '-canvas').getContext('2d');
  1965. var cMuteFillRect = function() {
  1966. thisTemp.canvasFill(cMute, [[10, 15], [15, 15], [21, 10], [21, 28], [15, 23], [10, 23]]);
  1967. thisTemp.canvasFillRect(cMute, [[23, 15, 2, 8], [27, 10, 2, 18]]);
  1968. };
  1969. cMute.fillStyle = bBgColor;
  1970. cMuteFillRect();
  1971. var cMuteOver = function() {
  1972. cMute.clearRect(0, 0, bWidth, bHeight);
  1973. cMute.fillStyle = bOverColor;
  1974. cMuteFillRect();
  1975. };
  1976. var cMuteOut = function() {
  1977. cMute.clearRect(0, 0, bWidth, bHeight);
  1978. cMute.fillStyle = bBgColor;
  1979. cMuteFillRect();
  1980. };
  1981. this.addListenerInside('mouseover', cMuteOver, this.getByElement(muteID + '-canvas'));
  1982. this.addListenerInside('mouseout', cMuteOut, this.getByElement(muteID + '-canvas'));
  1983. //定义取消广告静音按钮样式
  1984. var cEscMute = this.getByElement(escMuteID + '-canvas').getContext('2d');
  1985. var cEscMuteFillRect = function() {
  1986. thisTemp.canvasFill(cEscMute, [[10, 15], [15, 15], [21, 10], [21, 28], [15, 23], [10, 23]]);
  1987. thisTemp.canvasFill(cEscMute, [[23, 13], [24, 13], [33, 25], [32, 25]]);
  1988. thisTemp.canvasFill(cEscMute, [[32, 13], [33, 13], [24, 25], [23, 25]]);
  1989. };
  1990. cEscMute.fillStyle = bBgColor;
  1991. cEscMuteFillRect();
  1992. var cEscMuteOver = function() {
  1993. cEscMute.clearRect(0, 0, bWidth, bHeight);
  1994. cEscMute.fillStyle = bOverColor;
  1995. cEscMuteFillRect();
  1996. };
  1997. var cEscMuteOut = function() {
  1998. cEscMute.clearRect(0, 0, bWidth, bHeight);
  1999. cEscMute.fillStyle = bBgColor;
  2000. cEscMuteFillRect();
  2001. };
  2002. this.addListenerInside('mouseover', cEscMuteOver, this.getByElement(escMuteID + '-canvas'));
  2003. this.addListenerInside('mouseout', cEscMuteOut, this.getByElement(escMuteID + '-canvas'));
  2004. //定义广告静音按钮的样式
  2005. var cAdMute = this.getByElement(adMuteID + '-canvas').getContext('2d');
  2006. var cAdMuteFillRect = function() {
  2007. thisTemp.canvasFill(cAdMute, [[8, 12], [12, 12], [16, 8], [16, 21], [12, 18], [8, 18]]);
  2008. thisTemp.canvasFillRect(cAdMute, [[18, 12, 2, 6], [21, 8, 2, 14]]);
  2009. };
  2010. cAdMute.fillStyle = bBgColor;
  2011. cAdMuteFillRect();
  2012. var cAdMuteOver = function() {
  2013. cAdMute.clearRect(0, 0, bWidth, bHeight);
  2014. cAdMute.fillStyle = bOverColor;
  2015. cAdMuteFillRect();
  2016. };
  2017. var cAdMuteOut = function() {
  2018. cAdMute.clearRect(0, 0, bWidth, bHeight);
  2019. cAdMute.fillStyle = bBgColor;
  2020. cAdMuteFillRect();
  2021. };
  2022. this.addListenerInside('mouseover', cAdMuteOver, this.getByElement(adMuteID + '-canvas'));
  2023. this.addListenerInside('mouseout', cAdMuteOut, this.getByElement(adMuteID + '-canvas'));
  2024. //定义取消静音广告按钮样式
  2025. var cAdEscMute = this.getByElement(adEscMuteID + '-canvas').getContext('2d');
  2026. var cAdEscMuteFillRect = function() {
  2027. thisTemp.canvasFill(cAdEscMute, [[8, 12], [12, 12], [16, 8], [16, 21], [12, 18], [8, 18]]);
  2028. thisTemp.canvasFill(cAdEscMute, [[18, 10], [20, 10], [26, 20], [24, 20]]);
  2029. thisTemp.canvasFill(cAdEscMute, [[25, 10], [27, 10], [20, 20], [18, 20]]);
  2030. };
  2031. cAdEscMute.fillStyle = bBgColor;
  2032. cAdEscMuteFillRect();
  2033. var cAdEscMuteOver = function() {
  2034. cAdEscMute.clearRect(0, 0, bWidth, bHeight);
  2035. cAdEscMute.fillStyle = bOverColor;
  2036. cAdEscMuteFillRect();
  2037. };
  2038. var cAdEscMuteOut = function() {
  2039. cAdEscMute.clearRect(0, 0, bWidth, bHeight);
  2040. cAdEscMute.fillStyle = bBgColor;
  2041. cAdEscMuteFillRect();
  2042. };
  2043. this.addListenerInside('mouseover', cAdEscMuteOver, this.getByElement(adEscMuteID + '-canvas'));
  2044. this.addListenerInside('mouseout', cAdEscMuteOut, this.getByElement(adEscMuteID + '-canvas'));
  2045. //定义暂停广告关闭按钮
  2046. var adPauseClose = this.getByElement(adPauseCloseID + '-canvas').getContext('2d');
  2047. var adPauseCloseFillRect = function() {
  2048. thisTemp.canvasFill(adPauseClose, [[4, 6], [6, 6], [16, 15], [14, 15]]);
  2049. thisTemp.canvasFill(adPauseClose, [[14, 6], [16, 6], [6, 15], [4, 15]]);
  2050. };
  2051. adPauseClose.fillStyle = '#404856';
  2052. adPauseCloseFillRect();
  2053. var adPauseCloseOver = function() {
  2054. adPauseClose.clearRect(0, 0, bWidth, bHeight);
  2055. adPauseClose.fillStyle = bOverColor;
  2056. adPauseCloseFillRect();
  2057. };
  2058. var adPauseCloseOut = function() {
  2059. adPauseClose.clearRect(0, 0, bWidth, bHeight);
  2060. adPauseClose.fillStyle = '#404856';
  2061. adPauseCloseFillRect();
  2062. };
  2063. this.addListenerInside('mouseover', adPauseCloseOver, this.getByElement(adPauseCloseID + '-canvas'));
  2064. this.addListenerInside('mouseout', adPauseCloseOut, this.getByElement(adPauseCloseID + '-canvas'));
  2065. //定义loading样式
  2066. var cLoading = this.getByElement(loadingID + '-canvas').getContext('2d');
  2067. var cLoadingFillRect = function() {
  2068. cLoading.save();
  2069. var grad = cLoading.createLinearGradient(0, 0, 60, 60);
  2070. grad.addColorStop(0, bBgColor);
  2071. var grad2 = cLoading.createLinearGradient(0, 0, 80, 60);
  2072. grad2.addColorStop(1, bOverColor);
  2073. var grad3 = cLoading.createLinearGradient(0, 0, 80, 60);
  2074. grad3.addColorStop(1, '#FF9900');
  2075. var grad4 = cLoading.createLinearGradient(0, 0, 80, 60);
  2076. grad4.addColorStop(1, '#CC3300');
  2077. cLoading.strokeStyle = grad; //设置描边样式
  2078. cLoading.lineWidth = 8; //设置线宽
  2079. cLoading.beginPath(); //路径开始
  2080. cLoading.arc(30, 30, 25, 0, 0.4 * Math.PI, false); //用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
  2081. cLoading.stroke(); //绘制
  2082. cLoading.closePath(); //路径结束
  2083. cLoading.beginPath(); //路径开始
  2084. cLoading.strokeStyle = grad2; //设置描边样式
  2085. cLoading.arc(30, 30, 25, 0.5 * Math.PI, 0.9 * Math.PI, false); //用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
  2086. cLoading.stroke(); //绘制
  2087. cLoading.beginPath(); //路径开始
  2088. cLoading.strokeStyle = grad3; //设置描边样式
  2089. cLoading.arc(30, 30, 25, Math.PI, 1.4 * Math.PI, false); //用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
  2090. cLoading.stroke(); //绘制
  2091. cLoading.beginPath(); //路径开始
  2092. cLoading.strokeStyle = grad4; //设置描边样式
  2093. cLoading.arc(30, 30, 25, 1.5 * Math.PI, 1.9 * Math.PI, false); //用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
  2094. cLoading.stroke(); //绘制
  2095. cLoading.closePath(); //路径结束
  2096. cLoading.restore();
  2097. };
  2098. cLoading.fillStyle = bBgColor;
  2099. cLoadingFillRect();
  2100. //定义中间暂停按钮的样式
  2101. var cPauseCenter = this.getByElement(pauseCenterID + '-canvas').getContext('2d');
  2102. var cPauseCenterFillRect = function() {
  2103. thisTemp.canvasFill(cPauseCenter, [[28, 22], [59, 38], [28, 58]]);
  2104. /* 指定几个颜色 */
  2105. cPauseCenter.save();
  2106. cPauseCenter.lineWidth = 5; //设置线宽
  2107. cPauseCenter.beginPath(); //路径开始
  2108. cPauseCenter.arc(40, 40, 35, 0, 2 * Math.PI, false); //用于绘制圆弧context.arc(x坐标,y坐标,半径,起始角度,终止角度,顺时针/逆时针)
  2109. cPauseCenter.stroke(); //绘制
  2110. cPauseCenter.closePath(); //路径结束
  2111. cPauseCenter.restore();
  2112. };
  2113. cPauseCenter.fillStyle = bBgColor;
  2114. cPauseCenter.strokeStyle = bBgColor;
  2115. cPauseCenterFillRect();
  2116. var cPauseCenterOver = function() {
  2117. cPauseCenter.clearRect(0, 0, 80, 80);
  2118. cPauseCenter.fillStyle = bOverColor;
  2119. cPauseCenter.strokeStyle = bOverColor;
  2120. cPauseCenterFillRect();
  2121. };
  2122. var cPauseCenterOut = function() {
  2123. cPauseCenter.clearRect(0, 0, 80, 80);
  2124. cPauseCenter.fillStyle = bBgColor;
  2125. cPauseCenter.strokeStyle = bBgColor;
  2126. cPauseCenterFillRect();
  2127. };
  2128. this.addListenerInside('mouseover', cPauseCenterOver, this.getByElement(pauseCenterID + '-canvas'));
  2129. this.addListenerInside('mouseout', cPauseCenterOut, this.getByElement(pauseCenterID + '-canvas'));
  2130. //鼠标经过/离开音量调节按钮
  2131. var volumeBOOver = function() {
  2132. thisTemp.css(volumeBOID, 'backgroundColor', bOverColor);
  2133. thisTemp.css(volumeBWID, 'backgroundColor', bBgColor);
  2134. };
  2135. var volumeBOOut = function() {
  2136. thisTemp.css(volumeBOID, 'backgroundColor', bBgColor);
  2137. thisTemp.css(volumeBWID, 'backgroundColor', bOverColor);
  2138. };
  2139. this.addListenerInside('mouseover', volumeBOOver, this.getByElement(volumeBOID));
  2140. this.addListenerInside('mouseout', volumeBOOut, this.getByElement(volumeBOID));
  2141. //鼠标经过/离开进度按钮
  2142. var timeBOOver = function() {
  2143. thisTemp.css(timeBOID, 'backgroundColor', bOverColor);
  2144. thisTemp.css(timeBWID, 'backgroundColor', bBgColor);
  2145. };
  2146. var timeBOOut = function() {
  2147. thisTemp.css(timeBOID, 'backgroundColor', bBgColor);
  2148. thisTemp.css(timeBWID, 'backgroundColor', bOverColor);
  2149. };
  2150. this.addListenerInside('mouseover', timeBOOver, this.getByElement(timeBOID));
  2151. this.addListenerInside('mouseout', timeBOOut, this.getByElement(timeBOID));
  2152. this.addButtonEvent(); //注册按钮及音量调节,进度操作事件
  2153. this.newMenu(); //单独设置右键的样式和事件
  2154. this.controlBarHide(); //单独注册控制栏隐藏事件
  2155. this.keypress(); //单独注册键盘事件
  2156. //初始化音量调节框
  2157. this.changeVolume(this.vars['volume']);
  2158. //初始化判断是否需要显示上一集和下一集按钮
  2159. this.showFrontNext();
  2160. setTimeout(function() {
  2161. thisTemp.elementCoordinate(); //调整中间暂停按钮/loading的位置/error的位置
  2162. },
  2163. 100);
  2164. this.checkBarWidth();
  2165. var resize = function() {
  2166. thisTemp.elementCoordinate();
  2167. thisTemp.timeUpdateHandler();
  2168. thisTemp.changeLoad();
  2169. thisTemp.checkBarWidth();
  2170. thisTemp.changeElementCoor(); //修改新加元件的坐标
  2171. thisTemp.changePrompt();
  2172. thisTemp.adPauseCoor();
  2173. thisTemp.adOtherCoor();
  2174. };
  2175. this.addListenerInside('resize', resize, window);
  2176. },
  2177. /*
  2178. 内部函数
  2179. 创建按钮,使用canvas画布
  2180. */
  2181. newCanvas: function(id, width, height) {
  2182. return '<canvas class="' + id + '-canvas" width="' + width + '" height="' + height + '"></canvas>';
  2183. },
  2184. /*
  2185. 内部函数
  2186. 注册按钮,音量调节框,进度操作框事件
  2187. */
  2188. addButtonEvent: function() {
  2189. var thisTemp = this;
  2190. //定义按钮的单击事件
  2191. var playClick = function(event) {
  2192. thisTemp.videoPlay();
  2193. thisTemp.sendJS('clickEvent', 'actionScript->videoPlay');
  2194. };
  2195. this.addListenerInside('click', playClick, this.CB['play']);
  2196. this.addListenerInside('click', playClick, this.CB['pauseCenter']);
  2197. var pauseClick = function(event) {
  2198. thisTemp.videoPause();
  2199. thisTemp.sendJS('clickEvent', 'actionScript->videoPause');
  2200. };
  2201. this.addListenerInside('click', pauseClick, this.CB['pause']);
  2202. var frontClick = function(event) {
  2203. if (thisTemp.vars['front']) {
  2204. eval(thisTemp.vars['front'] + '()');
  2205. thisTemp.sendJS('clickEvent', 'actionScript->' + thisTemp.vars['front']);
  2206. }
  2207. };
  2208. this.addListenerInside('click', frontClick, this.CB['front']);
  2209. var nextClick = function(event) {
  2210. if (thisTemp.vars['next']) {
  2211. eval(thisTemp.vars['next'] + '()');
  2212. thisTemp.sendJS('clickEvent', 'actionScript->' + thisTemp.vars['next']);
  2213. }
  2214. };
  2215. this.addListenerInside('click', nextClick, this.CB['next']);
  2216. var muteClick = function(event) {
  2217. thisTemp.videoMute();
  2218. thisTemp.sendJS('clickEvent', 'actionScript->videoMute');
  2219. };
  2220. this.addListenerInside('click', muteClick, this.CB['mute']);
  2221. var escMuteClick = function(event) {
  2222. thisTemp.videoEscMute();
  2223. thisTemp.sendJS('clickEvent', 'actionScript->videoEscMute');
  2224. };
  2225. this.addListenerInside('click', escMuteClick, this.CB['escMute']);
  2226. var fullClick = function(event) {
  2227. thisTemp.fullScreen();
  2228. thisTemp.sendJS('clickEvent', 'actionScript->fullScreen');
  2229. };
  2230. this.addListenerInside('click', fullClick, this.CB['full']);
  2231. var escFullClick = function(event) {
  2232. thisTemp.quitFullScreen();
  2233. thisTemp.sendJS('clickEvent', 'actionScript->quitFullScreen');
  2234. };
  2235. this.addListenerInside('click', escFullClick, this.CB['escFull']);
  2236. var adSkipClick = function(event) {
  2237. if (thisTemp.CB['adSkip'].innerHTML == thisTemp.language['skipAd']) {
  2238. thisTemp.runFunction(thisTemp.config['adSkipClick']);
  2239. }
  2240. };
  2241. this.addListenerInside('click', adSkipClick, this.CB['adSkip']);
  2242. var adMuteClick = function(event) {
  2243. thisTemp.adMuteFunction();
  2244. };
  2245. this.addListenerInside('click', adMuteClick, this.CB['adMute']);
  2246. var adEscMuteClick = function(event) {
  2247. thisTemp.adEscMuteFunction();
  2248. };
  2249. this.addListenerInside('click', adEscMuteClick, this.CB['adEscMute']);
  2250. var adPauseCloseClick = function(event) {
  2251. thisTemp.adPauseCloseFunction();
  2252. };
  2253. this.addListenerInside('click', adPauseCloseClick, this.CB['adPauseClose']);
  2254. //定义各个按钮的鼠标经过/离开事件
  2255. var promptHide = function(event) {
  2256. thisTemp.promptShow(false);
  2257. };
  2258. var playOver = function(event) {
  2259. thisTemp.promptShow(thisTemp.CB['play']);
  2260. };
  2261. this.addListenerInside('mouseover', playOver, this.CB['play']);
  2262. this.addListenerInside('mouseout', promptHide, this.CB['play']);
  2263. var pauseOver = function(event) {
  2264. thisTemp.promptShow(thisTemp.CB['pause']);
  2265. };
  2266. this.addListenerInside('mouseover', pauseOver, this.CB['pause']);
  2267. this.addListenerInside('mouseout', promptHide, this.CB['pause']);
  2268. var frontOver = function(event) {
  2269. thisTemp.promptShow(thisTemp.CB['front']);
  2270. };
  2271. this.addListenerInside('mouseover', frontOver, this.CB['front']);
  2272. this.addListenerInside('mouseout', promptHide, this.CB['front']);
  2273. var nextOver = function(event) {
  2274. thisTemp.promptShow(thisTemp.CB['next']);
  2275. };
  2276. this.addListenerInside('mouseover', nextOver, this.CB['next']);
  2277. this.addListenerInside('mouseout', promptHide, this.CB['next']);
  2278. var muteOver = function(event) {
  2279. thisTemp.promptShow(thisTemp.CB['mute']);
  2280. };
  2281. this.addListenerInside('mouseover', muteOver, this.CB['mute']);
  2282. this.addListenerInside('mouseout', promptHide, this.CB['mute']);
  2283. var escMuteOver = function(event) {
  2284. thisTemp.promptShow(thisTemp.CB['escMute']);
  2285. };
  2286. this.addListenerInside('mouseover', escMuteOver, this.CB['escMute']);
  2287. this.addListenerInside('mouseout', promptHide, this.CB['escMute']);
  2288. var fullOver = function(event) {
  2289. thisTemp.promptShow(thisTemp.CB['full']);
  2290. };
  2291. this.addListenerInside('mouseover', fullOver, this.CB['full']);
  2292. this.addListenerInside('mouseout', promptHide, this.CB['full']);
  2293. var escFullOver = function(event) {
  2294. thisTemp.promptShow(thisTemp.CB['escFull']);
  2295. };
  2296. this.addListenerInside('mouseover', escFullOver, this.CB['escFull']);
  2297. this.addListenerInside('mouseout', promptHide, this.CB['escFull']);
  2298. var definitionOver = function(event) {
  2299. thisTemp.promptShow(thisTemp.CB['definition']);
  2300. };
  2301. this.addListenerInside('mouseover', definitionOver, this.CB['definition']);
  2302. this.addListenerInside('mouseout', promptHide, this.CB['definition']);
  2303. var playbackrateOver = function(event) {
  2304. thisTemp.promptShow(thisTemp.CB['playbackrate']);
  2305. };
  2306. this.addListenerInside('mouseover', playbackrateOver, this.CB['playbackrate']);
  2307. this.addListenerInside('mouseout', promptHide, this.CB['playbackrate']);
  2308. var subtitlesOver = function(event) {
  2309. thisTemp.promptShow(thisTemp.CB['subtitles']);
  2310. };
  2311. this.addListenerInside('mouseover', subtitlesOver, this.CB['subtitles']);
  2312. this.addListenerInside('mouseout', promptHide, this.CB['subtitles']);
  2313. //定义音量和进度按钮的滑块事件
  2314. var volumePrompt = function(vol) {
  2315. var volumeBOXY = thisTemp.getCoor(thisTemp.CB['volumeBO']);
  2316. var promptObj = {
  2317. title: thisTemp.language['volume'] + vol + '%',
  2318. x: volumeBOXY['x'] + thisTemp.CB['volumeBO'].offsetWidth * 0.5,
  2319. y: volumeBOXY['y']
  2320. };
  2321. thisTemp.promptShow(false, promptObj);
  2322. };
  2323. var volumeObj = {
  2324. slider: this.CB['volumeBO'],
  2325. follow: this.CB['volumeUp'],
  2326. refer: this.CB['volumeBg'],
  2327. grossValue: 'volume',
  2328. pd: true,
  2329. startFun: function(vol) {},
  2330. monitorFun: function(vol) {
  2331. thisTemp.changeVolume(vol * 0.01, false, false);
  2332. volumePrompt(vol);
  2333. },
  2334. endFun: function(vol) {},
  2335. overFun: function(vol) {
  2336. volumePrompt(vol);
  2337. }
  2338. };
  2339. this.slider(volumeObj);
  2340. var volumeClickObj = {
  2341. refer: this.CB['volumeBg'],
  2342. grossValue: 'volume',
  2343. fun: function(vol) {
  2344. thisTemp.changeVolume(vol * 0.01, true, true);
  2345. }
  2346. };
  2347. this.progressClick(volumeClickObj);
  2348. this.timeButtonMouseDown(); //用单击的函数来判断是否需要建立控制栏监听
  2349. //鼠标经过/离开音量调节框时的
  2350. var volumeBgMove = function(event) {
  2351. var volumeBgXY = thisTemp.getCoor(thisTemp.CB['volumeBg']);
  2352. var eventX = thisTemp.client(event)['x'];
  2353. var eventVolume = parseInt((eventX - volumeBgXY['x']) * 100 / thisTemp.CB['volumeBg'].offsetWidth);
  2354. var buttonPromptObj = {
  2355. title: thisTemp.language['volume'] + eventVolume + '%',
  2356. x: eventX,
  2357. y: volumeBgXY['y']
  2358. };
  2359. thisTemp.promptShow(false, buttonPromptObj);
  2360. };
  2361. this.addListenerInside('mousemove', volumeBgMove, this.CB['volumeBg']);
  2362. this.addListenerInside('mouseout', promptHide, this.CB['volumeBg']);
  2363. this.addListenerInside('mouseout', promptHide, this.CB['volumeBO']);
  2364. //注册清晰度相关事件
  2365. this.addDefListener();
  2366. //注册倍速相关事件
  2367. this.addPlaybackrate();
  2368. //注册多字幕事件
  2369. this.addSubtitles();
  2370. },
  2371. /*
  2372. 内部函数
  2373. 注册单击视频动作
  2374. */
  2375. videoClick: function() {
  2376. var thisTemp = this;
  2377. var clearTimerClick = function() {
  2378. if (thisTemp.timerClick != null) {
  2379. if (thisTemp.timerClick.runing) {
  2380. thisTemp.timerClick.stop();
  2381. }
  2382. thisTemp.timerClick = null;
  2383. }
  2384. };
  2385. var timerClickFun = function() {
  2386. clearTimerClick();
  2387. thisTemp.isClick = false;
  2388. thisTemp.sendJS('videoClick',thisTemp.videoClickXy);
  2389. if (thisTemp.adPlayerPlay) {
  2390. var ad = thisTemp.getNowAdvertisements();
  2391. try {
  2392. if (ad['link'] != '') {
  2393. window.open(ad['link']);
  2394. }
  2395. thisTemp.ajaxSuccessNull(ad['clickMonitor']);
  2396. } catch(event) {}
  2397. } else {
  2398. if (thisTemp.ckplayerConfig['config']['click']) {
  2399. thisTemp.playOrPause();
  2400. }
  2401. }
  2402. };
  2403. clearTimerClick();
  2404. if (this.isClick) {
  2405. this.isClick = false;
  2406. thisTemp.sendJS('videoDoubleClick',thisTemp.videoClickXy);
  2407. if (thisTemp.ckplayerConfig['config']['doubleClick']) {
  2408. if (!this.full) {
  2409. thisTemp.fullScreen();
  2410. } else {
  2411. thisTemp.quitFullScreen();
  2412. }
  2413. }
  2414. } else {
  2415. this.isClick = true;
  2416. this.timerClick = new this.timer(300, timerClickFun, 1)
  2417. //this.timerClick.start();
  2418. }
  2419. },
  2420. /*
  2421. 内部函数
  2422. 注册鼠标经过进度滑块的事件
  2423. */
  2424. timeButtonMouseDown: function() {
  2425. var thisTemp = this;
  2426. var timePrompt = function(time) {
  2427. if (isNaN(time)) {
  2428. time = 0;
  2429. }
  2430. var timeButtonXY = thisTemp.getCoor(thisTemp.CB['timeButton']);
  2431. var promptObj = {
  2432. title: thisTemp.formatTime(time),
  2433. x: timeButtonXY['x'] - thisTemp.pdCoor['x'] + thisTemp.CB['timeButton'].offsetWidth * 0.5,
  2434. y: timeButtonXY['y'] - thisTemp.pdCoor['y']
  2435. };
  2436. thisTemp.promptShow(false, promptObj);
  2437. };
  2438. var timeObj = {
  2439. slider: this.CB['timeButton'],
  2440. follow: this.CB['timeProgress'],
  2441. refer: this.CB['timeBoBg'],
  2442. grossValue: 'time',
  2443. pd: false,
  2444. startFun: function(time) {
  2445. thisTemp.isTimeButtonMove = false;
  2446. },
  2447. monitorFun: function(time) {},
  2448. endFun: function(time) {
  2449. if (thisTemp.V) {
  2450. if (thisTemp.V.duration > 0) {
  2451. thisTemp.needSeek = 0;
  2452. thisTemp.videoSeek(parseInt(time));
  2453. }
  2454. }
  2455. },
  2456. overFun: function(time) {
  2457. timePrompt(time);
  2458. }
  2459. };
  2460. var timeClickObj = {
  2461. refer: this.CB['timeBoBg'],
  2462. grossValue: 'time',
  2463. fun: function(time) {
  2464. if (thisTemp.V) {
  2465. if (thisTemp.V.duration > 0) {
  2466. thisTemp.needSeek = 0;
  2467. thisTemp.videoSeek(parseInt(time));
  2468. }
  2469. }
  2470. }
  2471. };
  2472. var timeBoBgmousemove = function(event) {
  2473. var timeBoBgXY = thisTemp.getCoor(thisTemp.CB['timeBoBg']);
  2474. var eventX = thisTemp.client(event)['x'];
  2475. var duration=thisTemp.V.duration;
  2476. if (isNaN(duration) || parseInt(duration) < 0.2) {
  2477. duration = thisTemp.vars['duration'];
  2478. }
  2479. if(thisTemp.vars['forceduration']>0){
  2480. duration=thisTemp.vars['forceduration'];
  2481. }
  2482. var eventTime = parseInt((eventX - timeBoBgXY['x']) * duration / thisTemp.CB['timeBoBg'].offsetWidth);
  2483. var buttonPromptObj = {
  2484. title: thisTemp.formatTime(eventTime),
  2485. x: eventX,
  2486. y: timeBoBgXY['y']
  2487. };
  2488. thisTemp.promptShow(false, buttonPromptObj);
  2489. var def = false;
  2490. if (!thisTemp.isUndefined(thisTemp.CB['definitionP'])) {
  2491. if (thisTemp.css(thisTemp.CB['definitionP'], 'display') != 'block') {
  2492. def = true;
  2493. }
  2494. }
  2495. if (thisTemp.vars['preview'] != null && def) {
  2496. buttonPromptObj['time'] = eventTime;
  2497. thisTemp.preview(buttonPromptObj);
  2498. }
  2499. };
  2500. var promptHide = function(event) {
  2501. thisTemp.promptShow(false);
  2502. if (thisTemp.previewDiv != null) {
  2503. thisTemp.css([thisTemp.previewDiv, thisTemp.previewTop], 'display', 'none');
  2504. }
  2505. };
  2506. if (!this.vars['live']) { //如果不是直播
  2507. this.isTimeButtonDown = true;
  2508. this.addListenerInside('mousemove', timeBoBgmousemove, this.CB['timeBoBg']);
  2509. this.addListenerInside('mouseout', promptHide, this.CB['timeBoBg']);
  2510. } else {
  2511. this.isTimeButtonDown = false;
  2512. timeObj['removeListenerInside'] = true;
  2513. timeClickObj['removeListenerInside'] = true;
  2514. }
  2515. this.slider(timeObj);
  2516. this.progressClick(timeClickObj);
  2517. },
  2518. /*
  2519. 内部函数
  2520. 注册调节框上单击事件,包含音量调节框和播放时度调节框
  2521. */
  2522. progressClick: function(obj) {
  2523. /*
  2524. refer:参考对象
  2525. fun:返回函数
  2526. refer:参考元素,即背景
  2527. grossValue:调用的参考值类型
  2528. pd:
  2529. */
  2530. //建立参考元素的mouseClick事件,用来做为鼠标在其上按下时触发的状态
  2531. var thisTemp = this;
  2532. var referMouseClick = function(event) {
  2533. var referX = thisTemp.client(event)['x'] - thisTemp.getCoor(obj['refer'])['x'];
  2534. var rWidth = obj['refer'].offsetWidth;
  2535. var grossValue = 0;
  2536. if (obj['grossValue'] == 'volume') {
  2537. grossValue = 100;
  2538. } else {
  2539. if (thisTemp.V) {
  2540. grossValue = thisTemp.V.duration;
  2541. if (isNaN(grossValue) || parseInt(grossValue) < 0.2) {
  2542. grossValue = thisTemp.vars['duration'];
  2543. }
  2544. if(thisTemp.vars['forceduration']>0){
  2545. grossValue=thisTemp.vars['forceduration'];
  2546. }
  2547. }
  2548. }
  2549. var nowZ = parseInt(referX * grossValue / rWidth);
  2550. if (obj['fun']) {
  2551. if (obj['grossValue'] === 'time') {
  2552. var sliderXY = thisTemp.getCoor(thisTemp.CB['timeButton']);
  2553. sliderLeft = sliderXY['x'];
  2554. if (!thisTemp.checkSlideLeft(referX, sliderLeft, rWidth)) {
  2555. return;
  2556. }
  2557. var bimeButtonWB = thisTemp.CB['timeButton'].offsetWidth * 0.5;
  2558. thisTemp.css(thisTemp.CB['timeButton'], 'left', (referX - bimeButtonWB) + 'px');
  2559. thisTemp.css(thisTemp.CB['timeProgress'], 'width', (referX) + 'px');
  2560. }
  2561. obj['fun'](nowZ);
  2562. }
  2563. };
  2564. if (this.isUndefined(obj['removeListenerInside'])) {
  2565. this.addListenerInside('click', referMouseClick, obj['refer']);
  2566. } else {
  2567. this.removeListenerInside('click', referMouseClick, obj['refer']);
  2568. }
  2569. },
  2570. /*
  2571. 内部函数
  2572. 共用的注册滑块事件
  2573. */
  2574. slider: function(obj) {
  2575. /*
  2576. obj={
  2577. slider:滑块元素
  2578. follow:跟随滑块的元素
  2579. refer:参考元素,即背景
  2580. grossValue:调用的参考值类型
  2581. startFun:开始调用的元素
  2582. monitorFun:监听函数
  2583. endFun:结束调用的函数
  2584. overFun:鼠标放上去后调用的函数
  2585. pd:是否需要修正
  2586. }
  2587. */
  2588. var thisTemp = this;
  2589. var clientX = 0,
  2590. criterionWidth = 0,
  2591. sliderLeft = 0,
  2592. referLeft = 0;
  2593. var value = 0;
  2594. var calculation = function() { //根据滑块的left计算百分比
  2595. var sLeft = parseInt(thisTemp.css(obj['slider'], 'left'));
  2596. var rWidth = obj['refer'].offsetWidth - obj['slider'].offsetWidth;
  2597. var grossValue = 0;
  2598. if (thisTemp.isUndefined(sLeft) || isNaN(sLeft)) {
  2599. sLeft = 0;
  2600. }
  2601. if (obj['grossValue'] == 'volume') {
  2602. grossValue = 100;
  2603. } else {
  2604. if (thisTemp.V) {
  2605. grossValue = thisTemp.V.duration;
  2606. }
  2607. }
  2608. return parseInt(sLeft * grossValue / rWidth);
  2609. };
  2610. var mDown = function(event) {
  2611. thisTemp.addListenerInside('mousemove', mMove, document);
  2612. thisTemp.addListenerInside('mouseup', mUp, document);
  2613. var referXY = thisTemp.getCoor(obj['refer']);
  2614. var sliderXY = thisTemp.getCoor(obj['slider']);
  2615. clientX = thisTemp.client(event)['x'];
  2616. referLeft = referXY['x'];
  2617. sliderLeft = sliderXY['x'];
  2618. criterionWidth = clientX - sliderLeft;
  2619. if (obj['startFun']) {
  2620. obj['startFun'](calculation());
  2621. }
  2622. };
  2623. var mMove = function(event) {
  2624. clientX = thisTemp.client(event)['x'];
  2625. var newX = clientX - criterionWidth - referLeft;
  2626. if (newX < 0) {
  2627. newX = 0;
  2628. }
  2629. if (newX > obj['refer'].offsetWidth - obj['slider'].offsetWidth) {
  2630. newX = obj['refer'].offsetWidth - obj['slider'].offsetWidth;
  2631. }
  2632. if (obj['slider'] === thisTemp.CB['timeButton']) {
  2633. if (!thisTemp.checkSlideLeft(newX, sliderLeft, obj['refer'].offsetWidth)) {
  2634. return;
  2635. }
  2636. }
  2637. thisTemp.css(obj['slider'], 'left', newX + 'px');
  2638. thisTemp.css(obj['follow'], 'width', (newX + obj['slider'].offsetWidth * 0.5) + 'px');
  2639. var nowZ = calculation();
  2640. if (obj['monitorFun']) {
  2641. obj['monitorFun'](nowZ);
  2642. }
  2643. };
  2644. var mUp = function(event) {
  2645. thisTemp.removeListenerInside('mousemove', mMove, document);
  2646. thisTemp.removeListenerInside('mouseup', mUp, document);
  2647. if (obj['endFun']) {
  2648. obj['endFun'](calculation());
  2649. }
  2650. };
  2651. var mOver = function(event) {
  2652. if (obj['overFun']) {
  2653. obj['overFun'](calculation());
  2654. }
  2655. };
  2656. if (this.isUndefined(obj['removeListenerInside'])) {
  2657. this.addListenerInside('mousedown', mDown, obj['slider']);
  2658. this.addListenerInside('mouseover', mOver, obj['slider']);
  2659. } else {
  2660. this.removeListenerInside('mousedown', mDown, obj['slider']);
  2661. this.removeListenerInside('mouseover', mOver, obj['slider']);
  2662. }
  2663. },
  2664. /*
  2665. 内部函数
  2666. 判断是否可以拖动进度按钮或点击进度栏
  2667. */
  2668. checkSlideLeft: function(newX, sliderLeft, refer) {
  2669. var timeSA = this.ckplayerConfig['config']['timeScheduleAdjust'];
  2670. switch (timeSA) {
  2671. case 0:
  2672. return false;
  2673. break;
  2674. case 2:
  2675. if (newX < sliderLeft) {
  2676. return false;
  2677. }
  2678. break;
  2679. case 3:
  2680. if (newX > sliderLeft) {
  2681. return false;
  2682. }
  2683. break;
  2684. case 4:
  2685. if (!this.timeSliderLeftTemp) {
  2686. this.timeSliderLeftTemp = sliderLeft / refer;
  2687. }
  2688. if (newX < this.timeSliderLeftTemp * refer) {
  2689. return false;
  2690. }
  2691. break;
  2692. case 5:
  2693. if (!this.timeSliderLeftTemp) {
  2694. this.timeSliderLeftTemp = sliderLeft / refer;
  2695. } else {
  2696. var timeSliderMax = sliderLeft / refer;
  2697. if (timeSliderMax > this.timeSliderLeftTemp) {
  2698. this.timeSliderLeftTemp = timeSliderMax;
  2699. }
  2700. }
  2701. if (newX > this.timeSliderLeftTemp * refer) {
  2702. return false;
  2703. }
  2704. break;
  2705. default:
  2706. return true;
  2707. break;
  2708. }
  2709. return true;
  2710. },
  2711. /*
  2712. 内部函数
  2713. 显示loading
  2714. */
  2715. loadingStart: function(rot) {
  2716. var thisTemp = this;
  2717. if (this.isUndefined(rot)) {
  2718. rot = true;
  2719. }
  2720. if (this.showFace) {
  2721. this.css(thisTemp.CB['loading'], 'display', 'none');
  2722. }
  2723. if (this.timerLoading != null) {
  2724. if (this.timerLoading.runing) {
  2725. this.timerLoading.stop();
  2726. }
  2727. this.timerLoading = null;
  2728. }
  2729. var buffer = 0;
  2730. var loadingFun = function() {
  2731. var nowRotate = '0';
  2732. try {
  2733. nowRotate = thisTemp.css(thisTemp.CB['loadingCanvas'], 'transform') || thisTemp.css(thisTemp.CB['loadingCanvas'], '-ms-transform') || thisTemp.css(thisTemp.CB['loadingCanvas'], '-moz-transform') || thisTemp.css(thisTemp.CB['loadingCanvas'], '-webkit-transform') || thisTemp.css(thisTemp.CB['loadingCanvas'], '-o-transform') || '0';
  2734. } catch(event) {}
  2735. nowRotate = parseInt(nowRotate.replace('rotate(', '').replace('deg);', ''));
  2736. nowRotate += 4;
  2737. if (nowRotate > 360) {
  2738. nowRotate = 0;
  2739. }
  2740. if (thisTemp.showFace) {
  2741. thisTemp.css(thisTemp.CB['loadingCanvas'], {
  2742. transform: 'rotate(' + nowRotate + 'deg)',
  2743. msTransform: 'rotate(' + nowRotate + 'deg)',
  2744. mozTransform: 'rotate(' + nowRotate + 'deg)',
  2745. webkitTransform: 'rotate(' + nowRotate + 'deg)',
  2746. oTransform: 'rotate(' + nowRotate + 'deg)'
  2747. });
  2748. }
  2749. buffer++;
  2750. if (buffer >= 99) {
  2751. buffer = 99;
  2752. }
  2753. thisTemp.sendJS('buffer', buffer);
  2754. };
  2755. if (rot) {
  2756. this.timerLoading = new this.timer(10, loadingFun);
  2757. //this.timerLoading.start();
  2758. if (this.showFace) {
  2759. this.css(thisTemp.CB['loading'], 'display', 'block');
  2760. }
  2761. } else {
  2762. thisTemp.sendJS('buffer', 100);
  2763. }
  2764. },
  2765. /*
  2766. 内部函数
  2767. 判断是否需要显示上一集和下一集
  2768. */
  2769. showFrontNext: function() {
  2770. if (!this.showFace) {
  2771. return;
  2772. }
  2773. if (this.vars['front']) {
  2774. this.css([this.CB['front'], this.CB['frontLine']], 'display', 'block');
  2775. } else {
  2776. this.css([this.CB['front'], this.CB['frontLine']], 'display', 'none');
  2777. }
  2778. if (this.vars['next']) {
  2779. this.css([this.CB['next'], this.CB['nextLine']], 'display', 'block');
  2780. } else {
  2781. this.css([this.CB['next'], this.CB['nextLine']], 'display', 'none');
  2782. }
  2783. },
  2784. /*
  2785. 内部函数
  2786. 显示提示语
  2787. */
  2788. promptShow: function(ele, data) {
  2789. if (!this.showFace) {
  2790. return;
  2791. }
  2792. var obj = {};
  2793. if (ele || data) {
  2794. if (!this.isUndefined(data)) {
  2795. obj = data;
  2796. } else {
  2797. var offsetCoor = this.getCoor(ele);
  2798. obj = {
  2799. title: this.getDataset(ele, 'title'),
  2800. x: offsetCoor['x'] + ele.offsetWidth * 0.5,
  2801. y: offsetCoor['y']
  2802. };
  2803. }
  2804. this.CB['prompt'].innerHTML = obj['title'];
  2805. this.css(this.CB['prompt'], 'display', 'block');
  2806. var promoptWidth = this.getStringLen(obj['title']) * 10;
  2807. this.css(this.CB['promptBg'], 'width', promoptWidth + 'px');
  2808. this.css(this.CB['prompt'], 'width', promoptWidth + 'px');
  2809. promoptWidth += 10;
  2810. var x = obj['x'] - (promoptWidth * 0.5);
  2811. var y = this.PD.offsetHeight - obj['y'] + 8;
  2812. if (x < 0) {
  2813. x = 0;
  2814. }
  2815. if (x > this.PD.offsetWidth - promoptWidth) {
  2816. x = this.PD.offsetWidth - promoptWidth;
  2817. }
  2818. this.css([this.CB['promptBg'], this.CB['prompt']], {
  2819. display: 'block',
  2820. left: x + 'px',
  2821. bottom: y + 'px'
  2822. });
  2823. } else {
  2824. this.css([this.CB['promptBg'], this.CB['prompt']], {
  2825. display: 'none'
  2826. });
  2827. }
  2828. },
  2829. /*
  2830. 内部函数
  2831. 监听错误
  2832. */
  2833. timerErrorFun: function() {
  2834. var thisTemp = this;
  2835. this.errorSend = false;
  2836. var clearIntervalError = function(event) {
  2837. if (thisTemp.timerError != null) {
  2838. if (thisTemp.timerError.runing) {
  2839. thisTemp.timerError.stop();
  2840. }
  2841. thisTemp.timerError = null;
  2842. }
  2843. };
  2844. var errorFun = function(event) {
  2845. clearIntervalError();
  2846. thisTemp.error = true;
  2847. //提取错误播放地址
  2848. thisTemp.errorUrl = thisTemp.getVideoUrl();
  2849. //提取错误播放地址结束
  2850. if (!thisTemp.errorSend) {
  2851. thisTemp.errorSend = true;
  2852. thisTemp.sendJS('error');
  2853. }
  2854. if (thisTemp.showFace) {
  2855. thisTemp.css(thisTemp.CB['errorText'], 'display', 'block');
  2856. thisTemp.css(thisTemp.CB['pauseCenter'], 'display', 'none');
  2857. thisTemp.css(thisTemp.CB['loading'], 'display', 'none');
  2858. }
  2859. thisTemp.V.removeAttribute('poster');
  2860. thisTemp.resetPlayer();
  2861. };
  2862. var errorListenerFun = function(event) {
  2863. setTimeout(function() {
  2864. if (isNaN(thisTemp.V.duration)) {
  2865. errorFun(event);
  2866. }
  2867. },
  2868. 500);
  2869. };
  2870. if (!this.errorAdd) {
  2871. this.errorAdd = true;
  2872. this.addListenerInside('error', errorListenerFun, this.V);
  2873. }
  2874. clearIntervalError();
  2875. var timerErrorFun = function() {
  2876. if (thisTemp.V && parseInt(thisTemp.V.networkState) == 3) {
  2877. errorFun();
  2878. }
  2879. };
  2880. this.timerError = new this.timer(this.config['errorTime'], timerErrorFun);
  2881. //this.timerError.start();
  2882. },
  2883. /*
  2884. 内部函数
  2885. 构建判断全屏还是非全屏的判断
  2886. */
  2887. judgeFullScreen: function() {
  2888. var thisTemp = this;
  2889. if (this.timerFull != null) {
  2890. if (this.timerFull.runing) {
  2891. this.timerFull.stop();
  2892. }
  2893. this.timerFull = null;
  2894. }
  2895. var fullFun = function() {
  2896. thisTemp.isFullScreen();
  2897. };
  2898. this.timerFull = new this.timer(20, fullFun);
  2899. },
  2900. /*
  2901. 内部函数
  2902. 判断是否是全屏
  2903. */
  2904. isFullScreen: function() {
  2905. if (!this.showFace) {
  2906. return;
  2907. }
  2908. var fullState = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement;
  2909. if (fullState && !this.full) {
  2910. this.full = true;
  2911. this.sendJS('full', true);
  2912. this.elementCoordinate();
  2913. this.css(this.CB['full'], 'display', 'none');
  2914. this.css(this.CB['escFull'], 'display', 'block');
  2915. if (this.vars['live'] == 0) {
  2916. this.timeUpdateHandler();
  2917. }
  2918. this.PD.appendChild(this.CB['menu']);
  2919. }
  2920. if (!fullState && this.full) {
  2921. this.full = false;
  2922. this.sendJS('full', false);
  2923. this.elementCoordinate();
  2924. this.css(this.CB['full'], 'display', 'block');
  2925. this.css(this.CB['escFull'], 'display', 'none');
  2926. if (this.timerFull != null) {
  2927. if (this.timerFull.runing) {
  2928. this.timerFull.stop();
  2929. }
  2930. this.timerFull = null;
  2931. }
  2932. if (this.vars['live'] == 0) {
  2933. this.timeUpdateHandler();
  2934. }
  2935. this.body.appendChild(this.CB['menu']);
  2936. }
  2937. },
  2938. /*
  2939. 内部函数
  2940. 构建右键内容及注册相关动作事件
  2941. */
  2942. newMenu: function() {
  2943. var thisTemp = this;
  2944. var i = 0;
  2945. this.css(this.CB['menu'], {
  2946. backgroundColor: '#FFFFFF',
  2947. padding: '5px',
  2948. position: 'absolute',
  2949. left: '10px',
  2950. top: '20px',
  2951. display: 'none',
  2952. zIndex: '999',
  2953. color: '#A1A9BE',
  2954. boxShadow: '2px 2px 3px #AAAAAA'
  2955. });
  2956. var mArr = this.contextMenu;
  2957. var cMenu = this.ckplayerConfig['menu'];
  2958. if (cMenu['name']) {
  2959. if (cMenu['link']) {
  2960. mArr[0] = [cMenu['name'], 'link', cMenu['link']];
  2961. } else {
  2962. mArr[0] = [cMenu['name'], 'default'];
  2963. }
  2964. }
  2965. if (cMenu['version']) {
  2966. mArr[1] = [cMenu['version'], 'default', 'line'];
  2967. }
  2968. if (cMenu['more']) {
  2969. if (typeof(cMenu['more']) == 'object') {
  2970. if (cMenu['more'].length > 0) {
  2971. var moreArr = cMenu['more'];
  2972. for (i = 0; i < moreArr.length; i++) {
  2973. var mTemp = moreArr[i];
  2974. var arrTemp = [];
  2975. if (mTemp['name']) {
  2976. arrTemp.push(mTemp['name']);
  2977. }
  2978. if (mTemp['clickEvent'] && mTemp['clickEvent'] != 'none') {
  2979. var eveObj = this.clickEvent(mTemp['clickEvent']);
  2980. arrTemp.push(eveObj['type']);
  2981. if (eveObj['fun']) {
  2982. arrTemp.push(eveObj['fun']);
  2983. }
  2984. if (eveObj['link']) {
  2985. arrTemp.push(eveObj['link']);
  2986. }
  2987. if (eveObj['target']) {
  2988. arrTemp.push(' target="' + eveObj['target'] + '"');
  2989. }
  2990. }
  2991. if (mTemp['separatorBefore']) {
  2992. arrTemp.push('line');
  2993. }
  2994. mArr.push(arrTemp);
  2995. }
  2996. }
  2997. }
  2998. }
  2999. var html = '';
  3000. for (i = 0; i < mArr.length; i++) {
  3001. var me = mArr[i];
  3002. switch (me[1]) {
  3003. case 'default':
  3004. html += '<p>' + me[0] + '</p>';
  3005. break;
  3006. case 'link':
  3007. if (me[3]) {
  3008. me[3] = 'target="' + me[3] + '"';
  3009. }
  3010. html += '<p><a href="' + me[2] + '"' + me[3] + '>' + me[0] + '</a></p>';
  3011. break;
  3012. case 'javaScript':
  3013. html += '<p><a href="javascript:' + me[2] + '">' + me[0] + '</a></p>';
  3014. break;
  3015. case 'actionScript':
  3016. html += '<p><a href="javascript:' + this.vars['variable'] + me[2].replace('thisTemp', '') + '">' + me[0] + '</a></p>';
  3017. break;
  3018. default:
  3019. break;
  3020. }
  3021. }
  3022. this.CB['menu'].innerHTML = html;
  3023. var pArr = this.CB['menu'].childNodes;
  3024. for (i = 0; i < pArr.length; i++) {
  3025. this.css(pArr[i], {
  3026. height: '30px',
  3027. lineHeight: '30px',
  3028. margin: '0px',
  3029. fontFamily: this.fontFamily,
  3030. fontSize: '12px',
  3031. paddingLeft: '10px',
  3032. paddingRight: '30px'
  3033. });
  3034. if (mArr[i][mArr[i].length - 1] == 'line') {
  3035. this.css(pArr[i], 'borderBottom', '1px solid #e9e9e9');
  3036. }
  3037. var aArr = pArr[i].childNodes;
  3038. for (var n = 0; n < aArr.length; n++) {
  3039. if (aArr[n].localName == 'a') {
  3040. this.css(aArr[n], {
  3041. color: '#000000',
  3042. textDecoration: 'none'
  3043. });
  3044. }
  3045. }
  3046. }
  3047. this.PD.oncontextmenu = function(event) {
  3048. var eve = event || window.event;
  3049. var client = thisTemp.client(event);
  3050. if (eve.button == 2) {
  3051. eve.returnvalue = false;
  3052. var x = client['x'] + thisTemp.pdCoor['x'] - 2;
  3053. var y = client['y'] + thisTemp.pdCoor['y'] - 2;
  3054. thisTemp.css(thisTemp.CB['menu'], {
  3055. display: 'block',
  3056. left: x + 'px',
  3057. top: y + 'px'
  3058. });
  3059. return false;
  3060. }
  3061. return true;
  3062. };
  3063. var setTimeOutPClose = function() {
  3064. if (setTimeOutP) {
  3065. window.clearTimeout(setTimeOutP);
  3066. setTimeOutP = null;
  3067. }
  3068. };
  3069. var setTimeOutP = null;
  3070. var mouseOut = function(event) {
  3071. setTimeOutPClose();
  3072. setTimeOutP = setTimeout(function(event) {
  3073. thisTemp.css(thisTemp.CB['menu'], 'display', 'none');
  3074. },
  3075. 500);
  3076. };
  3077. this.addListenerInside('mouseout', mouseOut, thisTemp.CB['menu']);
  3078. var mouseOver = function(event) {
  3079. setTimeOutPClose();
  3080. };
  3081. this.addListenerInside('mouseover', mouseOver, thisTemp.CB['menu']);
  3082. },
  3083. /*
  3084. 内部函数
  3085. 构建控制栏隐藏事件
  3086. */
  3087. controlBarHide: function(hide) {
  3088. var thisTemp = this;
  3089. var client = {
  3090. x: 0,
  3091. y: 0
  3092. },
  3093. oldClient = {
  3094. x: 0,
  3095. y: 0
  3096. };
  3097. var cShow = true,
  3098. force = false;
  3099. var oldCoor = [0, 0];
  3100. var controlBarShow = function(show) {
  3101. if (show && !cShow && thisTemp.controlBarIsShow) {
  3102. cShow = true;
  3103. thisTemp.sendJS('controlBar', true);
  3104. thisTemp.css(thisTemp.CB['controlBarBg'], 'display', 'block');
  3105. thisTemp.css(thisTemp.CB['controlBar'], 'display', 'block');
  3106. thisTemp.css(thisTemp.CB['timeProgressBg'], 'display', 'block');
  3107. thisTemp.css(thisTemp.CB['timeBoBg'], 'display', 'block');
  3108. thisTemp.changeVolume(thisTemp.volume);
  3109. thisTemp.changeLoad();
  3110. if (!thisTemp.timerBuffer) {
  3111. thisTemp.bufferEdHandler();
  3112. }
  3113. } else {
  3114. if (cShow) {
  3115. cShow = false;
  3116. var paused = thisTemp.getMetaDate()['paused'];
  3117. if (force) {
  3118. paused = false;
  3119. }
  3120. if (!paused) {
  3121. thisTemp.sendJS('controlBar', false);
  3122. thisTemp.css(thisTemp.CB['controlBarBg'], 'display', 'none');
  3123. thisTemp.css(thisTemp.CB['controlBar'], 'display', 'none');
  3124. thisTemp.css(thisTemp.CB['timeProgressBg'], 'display', 'none');
  3125. thisTemp.css(thisTemp.CB['timeBoBg'], 'display', 'none');
  3126. thisTemp.promptShow(false);
  3127. }
  3128. }
  3129. }
  3130. };
  3131. var cbarFun = function(event) {
  3132. if (client['x'] == oldClient['x'] && client['y'] == oldClient['y']) {
  3133. var cdH = parseInt(thisTemp.CD.offsetHeight);
  3134. if ((client['y'] < cdH - 50 || client['y'] > cdH - 2) && cShow && !thisTemp.getMetaDate()['paused']) {
  3135. controlBarShow(false);
  3136. }
  3137. } else {
  3138. if (!cShow) {
  3139. controlBarShow(true);
  3140. }
  3141. }
  3142. oldClient = {
  3143. x: client['x'],
  3144. y: client['y']
  3145. }
  3146. };
  3147. this.timerCBar = new this.timer(2000, cbarFun);
  3148. var cdMove = function(event) {
  3149. var getClient = thisTemp.client(event);
  3150. client['x'] = getClient['x'];
  3151. client['y'] = getClient['y'];
  3152. if (!cShow) {
  3153. controlBarShow(true);
  3154. }
  3155. };
  3156. this.addListenerInside('mousemove', cdMove, thisTemp.CD);
  3157. this.addListenerInside('ended', cdMove);
  3158. this.addListenerInside('resize', cdMove, window);
  3159. if (hide === true) {
  3160. cShow = true;
  3161. force = true;
  3162. controlBarShow(false);
  3163. }
  3164. if (hide === false) {
  3165. cShow = false;
  3166. force = true;
  3167. controlBarShow(true);
  3168. }
  3169. },
  3170. /*
  3171. 内部函数
  3172. 注册键盘按键事件
  3173. */
  3174. keypress: function() {
  3175. var thisTemp = this;
  3176. var keyDown = function(eve) {
  3177. var keycode = eve.keyCode || eve.which;
  3178. if (thisTemp.adPlayerPlay) {
  3179. return;
  3180. }
  3181. switch (keycode) {
  3182. case 32:
  3183. thisTemp.playOrPause();
  3184. break;
  3185. case 37:
  3186. thisTemp.fastBack();
  3187. break;
  3188. case 39:
  3189. thisTemp.fastNext();
  3190. break;
  3191. case 38:
  3192. now = thisTemp.volume + thisTemp.ckplayerConfig['config']['volumeJump'];
  3193. thisTemp.changeVolume(now > 1 ? 1 : now);
  3194. break;
  3195. case 40:
  3196. now = thisTemp.volume - thisTemp.ckplayerConfig['config']['volumeJump'];
  3197. thisTemp.changeVolume(now < 0 ? 0 : now);
  3198. break;
  3199. default:
  3200. break;
  3201. }
  3202. };
  3203. this.addListenerInside('keydown', keyDown, window || document);
  3204. },
  3205. /*
  3206. 内部函数
  3207. 注册倍速相关
  3208. */
  3209. playbackRate: function() {
  3210. if (!this.showFace || !this.ckplayerConfig['config']['playbackRate']) {
  3211. return;
  3212. }
  3213. var thisTemp = this;
  3214. var vArr = this.playbackRateArr;
  3215. var html = '';
  3216. var nowD = ''; //当前的倍速
  3217. var i = 0;
  3218. if (!nowD) {
  3219. nowD = vArr[this.playbackRateDefault][1];
  3220. }
  3221. if (vArr.length > 1) {
  3222. var zlen = 0;
  3223. for (i = 0; i < vArr.length; i++) {
  3224. html = '<p>' + vArr[i][1] + '</p>' + html;
  3225. var dlen = this.getStringLen(vArr[i][1]);
  3226. if (dlen > zlen) {
  3227. zlen = dlen;
  3228. }
  3229. }
  3230. if (html) {
  3231. html += '<p>' + nowD + '</p>';
  3232. }
  3233. this.CB['playbackrate'].innerHTML = nowD;
  3234. this.CB['playbackrateP'].innerHTML = html;
  3235. this.css([this.CB['playbackrate'], this.CB['playbackrateLine']], 'display', 'block');
  3236. var pArr = this.CB['playbackrateP'].childNodes;
  3237. for (var i = 0; i < pArr.length; i++) {
  3238. var fontColor = '#FFFFFF';
  3239. if (pArr[i].innerHTML == nowD) {
  3240. fontColor = '#0782F5';
  3241. }
  3242. this.css(pArr[i], {
  3243. color: fontColor,
  3244. margin: '0px',
  3245. padding: '0px',
  3246. fontSize: '14px',
  3247. textAlign:'center'
  3248. });
  3249. if (i < pArr.length - 1) {
  3250. this.css(pArr[i], 'borderBottom', '1px solid #282828')
  3251. }
  3252. var defClick = function(event) {
  3253. if (nowD != this.innerHTML) {
  3254. thisTemp.css(thisTemp.CB['playbackrateP'], 'display', 'none');
  3255. thisTemp.newPlaybackrate(this.innerHTML);
  3256. thisTemp.sendJS('clickEvent', 'actionScript->newPlaybackrate');
  3257. }
  3258. };
  3259. this.addListenerInside('click', defClick, pArr[i]);
  3260. }
  3261. var pW = (zlen * 10) + 10;
  3262. this.css(this.CB['playbackrateP'], {
  3263. width: pW + 'px'
  3264. });
  3265. this.css(this.CB['playbackrate'], {
  3266. width: pW + 'px'
  3267. });
  3268. this.buttonWidth['playbackrate'] = this.CB['playbackrate'].offsetWidth;
  3269. } else {
  3270. this.CB['playbackrate'].innerHTML = '';
  3271. this.CB['playbackrateP'].innerHTML = '';
  3272. this.css([this.CB['playbackrate'], this.CB['playbackrateLine']], 'display', 'none');
  3273. }
  3274. },
  3275. /*
  3276. 内部函数
  3277. 注册切换倍速播放相关事件
  3278. */
  3279. addPlaybackrate: function() {
  3280. var thisTemp = this;
  3281. var setTimeOutP = null;
  3282. var defClick = function(event) {
  3283. thisTemp.css(thisTemp.CB['playbackrateP'], {
  3284. left: thisTemp.getCoor(thisTemp.CB['playbackrate'])['x'] + 'px',
  3285. display: 'block'
  3286. });
  3287. };
  3288. this.addListenerInside('click', defClick, this.CB['playbackrate']);
  3289. var defMouseOut = function(event) {
  3290. if (setTimeOutP) {
  3291. window.clearTimeout(setTimeOutP);
  3292. setTimeOutP = null;
  3293. }
  3294. setTimeOutP = setTimeout(function(event) {
  3295. thisTemp.css(thisTemp.CB['playbackrateP'], 'display', 'none');
  3296. },
  3297. 500);
  3298. };
  3299. this.addListenerInside('mouseout', defMouseOut, thisTemp.CB['playbackrateP']);
  3300. var defMouseOver = function(event) {
  3301. if (setTimeOutP) {
  3302. window.clearTimeout(setTimeOutP);
  3303. setTimeOutP = null;
  3304. }
  3305. };
  3306. this.addListenerInside('mouseover', defMouseOver, thisTemp.CB['playbackrateP']);
  3307. },
  3308. /*
  3309. 内部函数
  3310. 切换倍速后发生的动作
  3311. */
  3312. newPlaybackrate: function(title) {
  3313. var vArr = this.playbackRateArr;
  3314. var nVArr = [];
  3315. var i = 0;
  3316. for (i = 0; i < vArr.length; i++) {
  3317. var v = vArr[i];
  3318. if (v[1] == title) {
  3319. this.playbackRateDefault = i;
  3320. this.V.playbackRate = v[0];
  3321. if (this.showFace) {
  3322. this.CB['playbackrate'].innerHTML = v[1];
  3323. this.playbackRate();
  3324. }
  3325. this.sendJS('playbackRate', v);
  3326. this.playbackRateTemp=v[0];
  3327. }
  3328. }
  3329. },
  3330. /*
  3331. 内部函数
  3332. 注册多字幕切换相关
  3333. */
  3334. subtitleSwitch: function() {
  3335. if (!this.showFace || !this.ckplayerConfig['config']['subtitle']) {
  3336. return;
  3337. }
  3338. var thisTemp = this;
  3339. var vArr = this.vars['cktrack'];//字幕数组
  3340. if(this.typeString(vArr)!='array'){
  3341. return;
  3342. }
  3343. if(vArr[0][1]==''){
  3344. return;
  3345. }
  3346. var html = '';
  3347. var nowD = ''; //当前的字幕
  3348. var i = 0;
  3349. if (!nowD) {
  3350. if(this.subtitlesTemp==-1){
  3351. var indexN=0;
  3352. for(var i=0;i<vArr.length;i++){
  3353. var li=vArr[i];
  3354. if(li.length==3 && li[2]>indexN){
  3355. indexN=li[2];
  3356. this.subtitlesTemp=i;
  3357. }
  3358. }
  3359. }
  3360. nowD = vArr[this.subtitlesTemp][1];
  3361. }
  3362. if (vArr.length > 1) {
  3363. var zlen = 0;
  3364. for (i = 0; i < vArr.length; i++) {
  3365. html += '<p>' + vArr[i][1] + '</p>';
  3366. var dlen = this.getStringLen(vArr[i][1]);
  3367. if (dlen > zlen) {
  3368. zlen = dlen;
  3369. }
  3370. }
  3371. if (html) {
  3372. html += '<p>' + nowD + '</p>';
  3373. }
  3374. this.CB['subtitles'].innerHTML = nowD;
  3375. this.CB['subtitlesP'].innerHTML = html;
  3376. this.css([this.CB['subtitles'], this.CB['subtitlesLine']], 'display', 'block');
  3377. var pArr = this.CB['subtitlesP'].childNodes;
  3378. for (var i = 0; i < pArr.length; i++) {
  3379. var fontColor = '#FFFFFF';
  3380. if (pArr[i].innerHTML == nowD) {
  3381. fontColor = '#0782F5';
  3382. }
  3383. this.css(pArr[i], {
  3384. color: fontColor,
  3385. margin: '0px',
  3386. padding: '0px',
  3387. fontSize: '14px'
  3388. });
  3389. if (i < pArr.length - 1) {
  3390. this.css(pArr[i], 'borderBottom', '1px solid #282828')
  3391. }
  3392. var defClick = function(event) {
  3393. if (nowD != this.innerHTML) {
  3394. thisTemp.css(thisTemp.CB['subtitlesP'], 'display', 'none');
  3395. thisTemp.newSubtitles(this.innerHTML);
  3396. thisTemp.sendJS('clickEvent', 'actionScript->newPlaybackrate');
  3397. }
  3398. };
  3399. this.addListenerInside('click', defClick, pArr[i]);
  3400. }
  3401. var pW = (zlen * 10) + 10;
  3402. this.css(this.CB['subtitlesP'], {
  3403. width: pW + 'px'
  3404. });
  3405. this.css(this.CB['subtitles'], {
  3406. width: pW + 'px'
  3407. });
  3408. this.buttonWidth['subtitles'] = this.CB['subtitles'].offsetWidth;
  3409. } else {
  3410. this.CB['subtitles'].innerHTML = '';
  3411. this.CB['subtitlesP'].innerHTML = '';
  3412. this.css([this.CB['subtitles'], this.CB['subtitlesLine']], 'display', 'none');
  3413. }
  3414. },
  3415. /*
  3416. 内部函数
  3417. 注册多字幕切换事件
  3418. */
  3419. addSubtitles:function(){
  3420. var thisTemp = this;
  3421. var setTimeOutP = null;
  3422. var defClick = function(event) {
  3423. thisTemp.css(thisTemp.CB['subtitlesP'], {
  3424. left: thisTemp.getCoor(thisTemp.CB['subtitles'])['x'] + 'px',
  3425. display: 'block'
  3426. });
  3427. };
  3428. this.addListenerInside('click', defClick, this.CB['subtitles']);
  3429. var defMouseOut = function(event) {
  3430. if (setTimeOutP) {
  3431. window.clearTimeout(setTimeOutP);
  3432. setTimeOutP = null;
  3433. }
  3434. setTimeOutP = setTimeout(function(event) {
  3435. thisTemp.css(thisTemp.CB['subtitlesP'], 'display', 'none');
  3436. },
  3437. 500);
  3438. };
  3439. this.addListenerInside('mouseout', defMouseOut, thisTemp.CB['subtitlesP']);
  3440. var defMouseOver = function(event) {
  3441. if (setTimeOutP) {
  3442. window.clearTimeout(setTimeOutP);
  3443. setTimeOutP = null;
  3444. }
  3445. };
  3446. this.addListenerInside('mouseover', defMouseOver, thisTemp.CB['subtitlesP']);
  3447. },
  3448. /*
  3449. 接口函数:修改字幕,按数组编号来
  3450. 提供给外部api
  3451. */
  3452. changeSubtitles: function(n) {
  3453. if (!this.loaded || n < 0) {
  3454. return;
  3455. }
  3456. var vArr = this.vars['cktrack'];//字幕数组
  3457. if(this.typeString(vArr)!='array'){
  3458. return;
  3459. }
  3460. if (this.playerType == 'flashplayer') {
  3461. this.V.changeSubtitles(n);
  3462. return;
  3463. }
  3464. if (vArr.length > n) {
  3465. var arr = vArr[n];
  3466. if (arr.length > 2) {
  3467. var title = arr[1];
  3468. if (title) {
  3469. this.newSubtitles(title);
  3470. }
  3471. }
  3472. }
  3473. },
  3474. /*
  3475. 接口函数:修改字幕大小
  3476. 提供给外部api
  3477. */
  3478. changeSubtitlesSize:function(n,m){
  3479. if (!this.loaded || n < 0) {
  3480. return;
  3481. }
  3482. if (this.playerType == 'flashplayer') {
  3483. this.V.changeSubtitlesSize(n,m);
  3484. return;
  3485. }
  3486. this.trackFontSize=n;
  3487. if(!this.isUndefined(m)){
  3488. this.trackLineHeight=m;
  3489. }
  3490. this.trackShowAgain();
  3491. },
  3492. /*
  3493. 当切换字幕时的动作
  3494. */
  3495. newSubtitles:function(title){
  3496. var vArr = this.vars['cktrack'];//字幕数组
  3497. var i = 0;
  3498. for (i = 0; i < vArr.length; i++) {
  3499. var v = vArr[i];
  3500. if (v[1] == title) {
  3501. this.subtitlesTemp=i;
  3502. if (this.showFace) {
  3503. this.CB['subtitles'].innerHTML = v[1];
  3504. this.subtitleSwitch();
  3505. this.loadTrack(i);
  3506. }
  3507. this.sendJS('subtitles', v);
  3508. }
  3509. }
  3510. },
  3511. /*
  3512. 内部函数
  3513. 构建清晰度按钮及切换事件(Click事件)
  3514. */
  3515. definition: function() {
  3516. if (!this.showFace || !this.ckplayerConfig['config']['definition']) {
  3517. return;
  3518. }
  3519. var thisTemp = this;
  3520. var vArr = this.VA;
  3521. var dArr = [];
  3522. var html = '';
  3523. var nowD = ''; //当前的清晰度
  3524. var i = 0;
  3525. for (i = 0; i < vArr.length; i++) {
  3526. var d = vArr[i][2];
  3527. if (dArr.indexOf(d) == -1) {
  3528. dArr.push(d);
  3529. }
  3530. if (this.V) {
  3531. if (vArr[i][0] == this.V.currentSrc) {
  3532. nowD = d;
  3533. }
  3534. }
  3535. }
  3536. if (!nowD) {
  3537. nowD = dArr[0];
  3538. }
  3539. if (dArr.length > 1) {
  3540. var zlen = 0;
  3541. for (i = dArr.length - 1; i > -1; i--) {
  3542. html = '<p>' + dArr[i] + '</p>' + html;
  3543. var dlen = this.getStringLen(dArr[i]);
  3544. if (dlen > zlen) {
  3545. zlen = dlen;
  3546. }
  3547. }
  3548. if (html) {
  3549. html += '<p>' + nowD + '</p>';
  3550. }
  3551. this.CB['definition'].innerHTML = nowD;
  3552. this.CB['definitionP'].innerHTML = html;
  3553. this.css([this.CB['definition'], this.CB['definitionLine']], 'display', 'block');
  3554. var pArr = this.CB['definitionP'].childNodes;
  3555. for (var i = 0; i < pArr.length; i++) {
  3556. var fontColor = '#FFFFFF';
  3557. if (pArr[i].innerHTML == nowD) {
  3558. fontColor = '#0782F5';
  3559. }
  3560. this.css(pArr[i], {
  3561. color: fontColor,
  3562. margin: '0px',
  3563. padding: '0px',
  3564. fontSize: '14px'
  3565. });
  3566. if (i < pArr.length - 1) {
  3567. this.css(pArr[i], 'borderBottom', '1px solid #282828')
  3568. }
  3569. var defClick = function() {
  3570. if (nowD != this.innerHTML) {
  3571. thisTemp.css(thisTemp.CB['definitionP'], 'display', 'none');
  3572. thisTemp.newDefinition(this.innerHTML);
  3573. }
  3574. };
  3575. this.addListenerInside('click', defClick, pArr[i]);
  3576. }
  3577. var pW = (zlen * 10) + 10;
  3578. this.css(this.CB['definitionP'], {
  3579. width: pW + 'px'
  3580. });
  3581. this.css(this.CB['definition'], {
  3582. width: pW + 'px'
  3583. });
  3584. this.buttonWidth['definition'] = this.CB['definition'].offsetWidth;
  3585. } else {
  3586. this.CB['definition'].innerHTML = '';
  3587. this.CB['definitionP'].innerHTML = '';
  3588. this.css([this.CB['definition'], this.CB['definitionLine']], 'display', 'none');
  3589. }
  3590. },
  3591. /*
  3592. 内部函数
  3593. 注册清晰度相关事件
  3594. */
  3595. addDefListener: function() {
  3596. var thisTemp = this;
  3597. var setTimeOutP = null;
  3598. var defClick = function(event) {
  3599. thisTemp.css(thisTemp.CB['definitionP'], {
  3600. left: thisTemp.getCoor(thisTemp.CB['definition'])['x'] + 'px',
  3601. display: 'block'
  3602. });
  3603. };
  3604. this.addListenerInside('click', defClick, this.CB['definition']);
  3605. var defMouseOut = function(event) {
  3606. if (setTimeOutP) {
  3607. window.clearTimeout(setTimeOutP);
  3608. setTimeOutP = null;
  3609. }
  3610. setTimeOutP = setTimeout(function(event) {
  3611. thisTemp.css(thisTemp.CB['definitionP'], 'display', 'none');
  3612. },
  3613. 500);
  3614. };
  3615. this.addListenerInside('mouseout', defMouseOut, thisTemp.CB['definitionP']);
  3616. var defMouseOver = function(event) {
  3617. if (setTimeOutP) {
  3618. window.clearTimeout(setTimeOutP);
  3619. setTimeOutP = null;
  3620. }
  3621. };
  3622. this.addListenerInside('mouseover', defMouseOver, thisTemp.CB['definitionP']);
  3623. },
  3624. /*
  3625. 接口函数
  3626. 提供给外部api
  3627. */
  3628. changeDefinition: function(n) {
  3629. if (!this.loaded || n < 0) {
  3630. return;
  3631. }
  3632. if (this.playerType == 'flashplayer') {
  3633. this.V.changeDefinition(n);
  3634. return;
  3635. }
  3636. if (this.VA.length > n) {
  3637. var arr = this.VA[n];
  3638. if (arr.length > 3) {
  3639. var title = arr[2];
  3640. if (title) {
  3641. this.newDefinition(title);
  3642. }
  3643. }
  3644. }
  3645. },
  3646. /*
  3647. 内部函数
  3648. 切换清晰度后发生的动作
  3649. */
  3650. newDefinition: function(title) {
  3651. var vArr = this.VA;
  3652. var nVArr = [];
  3653. var i = 0;
  3654. for (i = 0; i < vArr.length; i++) {
  3655. var v = vArr[i];
  3656. if (v[2] == title) {
  3657. nVArr.push(v);
  3658. this.sendJS('definitionChange', i + '');
  3659. }
  3660. }
  3661. if (nVArr.length < 1) {
  3662. return;
  3663. }
  3664. if (this.V != null && this.needSeek == 0) {
  3665. this.needSeek = this.V.currentTime;
  3666. }
  3667. if (this.getFileExt(nVArr[0][0]) != '.m3u8') {
  3668. this.isM3u8 = false;
  3669. }
  3670. if (!this.isM3u8) {
  3671. if (nVArr.length == 1) {
  3672. this.V.innerHTML = '';
  3673. this.V.src = nVArr[0][0];
  3674. this.V.currentSrc = nVArr[0][0];
  3675. } else {
  3676. var source = '';
  3677. nVArr = this.arrSort(nVArr);
  3678. for (i = 0; i < nVArr.length; i++) {
  3679. var type = '';
  3680. var va = nVArr[i];
  3681. if (va[1]) {
  3682. type = ' type="' + va[1] + '"';
  3683. }
  3684. source += '<source src="' + va[0] + '"' + type + '>';
  3685. }
  3686. this.V.removeAttribute('src');
  3687. this.V.innerHTML = source;
  3688. this.V.currentSrc = nVArr[0][0];
  3689. }
  3690. } else {
  3691. this.embedHls(vArr[0][0], this.vars['autoplay']);
  3692. }
  3693. this.V.autoplay = 'autoplay';
  3694. this.V.load();
  3695. if (this.playbackRateTemp!=1) {
  3696. this.V.playbackRate = this.playbackRateTemp; //定义倍速
  3697. }
  3698. this.timerErrorFun();
  3699. },
  3700. /*
  3701. 内置函数
  3702. 播放hls
  3703. */
  3704. embedHls: function(url, autoplay) {
  3705. var thisTemp = this;
  3706. thisTemp.hlsAutoPlay=autoplay;
  3707. if (Hls.isSupported()) {
  3708. var hls = new Hls();
  3709. hls.loadSource(url);
  3710. hls.attachMedia(this.V);
  3711. hls.on(Hls.Events.MANIFEST_PARSED,
  3712. function() {
  3713. thisTemp.playerLoad();
  3714. if (autoplay) {
  3715. thisTemp.videoPlay();
  3716. }
  3717. });
  3718. }
  3719. },
  3720. /*
  3721. 内部函数
  3722. 构建提示点
  3723. */
  3724. prompt: function() {
  3725. if (!this.showFace) {
  3726. return;
  3727. }
  3728. var thisTemp = this;
  3729. var prompt = this.vars['promptSpot'];
  3730. if (prompt == null || this.promptArr.length > 0) {
  3731. return;
  3732. }
  3733. var showPrompt = function(event) {
  3734. if (thisTemp.promptElement == null) {
  3735. var random2 = 'prompte' + thisTemp.randomString(5);
  3736. var ele2 = document.createElement('div');
  3737. ele2.className = random2;
  3738. thisTemp.PD.appendChild(ele2);
  3739. thisTemp.promptElement = thisTemp.getByElement(random2);
  3740. thisTemp.css(thisTemp.promptElement, {
  3741. overflowX: 'hidden',
  3742. lineHeight: '22px',
  3743. fontSize: '14px',
  3744. color: '#FFFFFF',
  3745. position: 'absolute',
  3746. display: 'block',
  3747. zIndex: '90'
  3748. });
  3749. }
  3750. var pcon = thisTemp.getPromptTest();
  3751. var pW = pcon['pW'],
  3752. pT = pcon['pT'],
  3753. pL = parseInt(thisTemp.css(this, 'left')) - parseInt(pW * 0.5);
  3754. if (pcon['pL'] > 10) {
  3755. pL = pcon['pL'];
  3756. }
  3757. if (pL < 0) {
  3758. pL = 0;
  3759. }
  3760. thisTemp.css(thisTemp.promptElement, {
  3761. width: pW + 'px',
  3762. left: ( - pW - 10) + 'px',
  3763. display: 'block'
  3764. });
  3765. thisTemp.promptElement.innerHTML = thisTemp.getDataset(this, 'words');
  3766. thisTemp.css(thisTemp.promptElement, {
  3767. left: pL + 'px',
  3768. top: (pT - thisTemp.promptElement.offsetHeight - 10) + 'px'
  3769. });
  3770. };
  3771. var hidePrompt = function(event) {
  3772. if (thisTemp.promptElement != null) {
  3773. thisTemp.css(thisTemp.promptElement, {
  3774. display: 'none'
  3775. });
  3776. }
  3777. };
  3778. var i = 0;
  3779. for (i = 0; i < prompt.length; i++) {
  3780. var pr = prompt[i];
  3781. var words = pr['words'];
  3782. var time = pr['time'];
  3783. var random = 'prompt' + this.randomString(5);
  3784. var ele = document.createElement('div');
  3785. ele.className = random;
  3786. this.CB['timeBoBg'].appendChild(ele);
  3787. var div = this.getByElement(random);
  3788. div.setAttribute('data-time', time);
  3789. div.setAttribute('data-words', words);
  3790. this.css(div, {
  3791. width: '6px',
  3792. height: '6px',
  3793. backgroundColor: '#FFFFFF',
  3794. position: 'absolute',
  3795. top: '4px',
  3796. left: '-100px',
  3797. display: 'none',
  3798. zIndex: '1',
  3799. borderRadius: '6px'
  3800. });
  3801. this.addListenerInside('mouseover', showPrompt, div);
  3802. this.addListenerInside('mouseout', hidePrompt, div);
  3803. this.promptArr.push(div);
  3804. }
  3805. this.changePrompt();
  3806. },
  3807. /*
  3808. 内部函数
  3809. 计算提示文本的位置
  3810. */
  3811. getPromptTest: function() {
  3812. var pW = this.previewWidth,
  3813. pT = this.getCoor(this.CB['timeButton'])['y'],
  3814. pL = 0;
  3815. if (this.previewTop != null) {
  3816. pT -= parseInt(this.css(this.previewTop, 'height'));
  3817. pL = parseInt(this.css(this.previewTop, 'left'));
  3818. } else {
  3819. pT -= 35;
  3820. }
  3821. pL += 2;
  3822. if (pL < 0) {
  3823. pL = 0;
  3824. }
  3825. if (pL > this.PD.offsetWidth - pW) {
  3826. pL = this.PD.offsetWidth - pW;
  3827. }
  3828. return {
  3829. pW: pW,
  3830. pT: pT,
  3831. pL: pL
  3832. };
  3833. },
  3834. /*
  3835. 内部函数
  3836. 删除提示点
  3837. */
  3838. deletePrompt: function() {
  3839. var arr = this.promptArr;
  3840. if (arr.length > 0) {
  3841. for (var i = 0; i < arr.length; i++) {
  3842. if (arr[i]) {
  3843. this.deleteChild(arr[i]);
  3844. }
  3845. }
  3846. }
  3847. this.promptArr = [];
  3848. },
  3849. /*
  3850. 内部函数
  3851. 计算提示点坐标
  3852. */
  3853. changePrompt: function() {
  3854. if (this.promptArr.length == 0) {
  3855. return;
  3856. }
  3857. var arr = this.promptArr;
  3858. var duration = this.getMetaDate()['duration'];
  3859. var bw = this.CB['timeBoBg'].offsetWidth;
  3860. for (var i = 0; i < arr.length; i++) {
  3861. var time = parseInt(this.getDataset(arr[i], 'time'));
  3862. var left = parseInt(time * bw / duration) - parseInt(arr[i].offsetWidth * 0.5);
  3863. if (left < 0) {
  3864. left = 0;
  3865. }
  3866. if (left > bw - parseInt(arr[i].offsetWidth * 0.5)) {
  3867. left = bw - parseInt(arr[i].offsetWidth * 0.5);
  3868. }
  3869. this.css(arr[i], {
  3870. left: left + 'px',
  3871. display: 'block'
  3872. });
  3873. }
  3874. },
  3875. /*
  3876. 内部函数
  3877. 构建预览图片效果
  3878. */
  3879. preview: function(obj) {
  3880. var thisTemp = this;
  3881. var preview = {
  3882. file: null,
  3883. scale: 0
  3884. };
  3885. preview = this.standardization(preview, this.vars['preview']);
  3886. if (preview['file'] == null || preview['scale'] <= 0) {
  3887. return;
  3888. }
  3889. var srcArr = preview['file'];
  3890. if (this.previewStart == 0) { //如果还没有构建,则先进行构建
  3891. this.previewStart = 1;
  3892. if (srcArr.length > 0) {
  3893. var i = 0;
  3894. var imgW = 0,
  3895. imgH = 0;
  3896. var random = thisTemp.randomString(10);
  3897. var loadNum = 0;
  3898. var loadImg = function(i) {
  3899. srcArr[i] = thisTemp.getNewUrl(srcArr[i]);
  3900. var n = 0;
  3901. var img = new Image();
  3902. img.src = srcArr[i];
  3903. img.className = random + i;
  3904. img.onload = function(event) {
  3905. loadNum++;
  3906. if (thisTemp.previewDiv == null) { //如果没有建立DIV,则建
  3907. imgW = img.width;
  3908. imgH = img.height;
  3909. thisTemp.previewWidth = parseInt(imgW * 0.1);
  3910. var ele = document.createElement('div');
  3911. ele.className = random;
  3912. thisTemp.PD.appendChild(ele);
  3913. thisTemp.previewDiv = thisTemp.getByElement(random);
  3914. var eleTop = (obj['y'] - parseInt(imgH * 0.1) + 2);
  3915. thisTemp.css(thisTemp.previewDiv, {
  3916. width: srcArr.length * imgW * 10 + 'px',
  3917. height: parseInt(imgH * 0.1) + 'px',
  3918. backgroundColor: '#000000',
  3919. position: 'absolute',
  3920. left: '0px',
  3921. top: eleTop + 'px',
  3922. display: 'none',
  3923. zIndex: '80'
  3924. });
  3925. ele.setAttribute('data-x', '0');
  3926. ele.setAttribute('data-y', eleTop);
  3927. var ele2 = document.createElement('div');
  3928. ele2.className = random + 'd2';
  3929. thisTemp.PD.appendChild(ele2);
  3930. thisTemp.previewTop = thisTemp.getByElement(ele2.className);
  3931. thisTemp.css(thisTemp.previewTop, {
  3932. width: parseInt(imgW * 0.1) + 'px',
  3933. height: parseInt(imgH * 0.1) + 'px',
  3934. position: 'absolute',
  3935. border: '5px solid ' + thisTemp.css(thisTemp.CB['timeProgress'], 'backgroundColor'),
  3936. left: '0px',
  3937. top: (obj['y'] - parseInt(imgH * 0.1) + 2) + 'px',
  3938. display: 'none',
  3939. zIndex: '81'
  3940. });
  3941. var html = '';
  3942. for (n = 0; n < srcArr.length; n++) {
  3943. html += thisTemp.newCanvas(random + n, imgW * 10, parseInt(imgH * 0.1))
  3944. }
  3945. thisTemp.previewDiv.innerHTML = html;
  3946. }
  3947. thisTemp.previewDiv.appendChild(img);
  3948. var cimg = thisTemp.getByElement(img.className);
  3949. var canvas = thisTemp.getByElement(img.className + '-canvas');
  3950. var context = canvas.getContext('2d');
  3951. var sx = 0,
  3952. sy = 0,
  3953. x = 0,
  3954. h = parseInt(imgH * 0.1);
  3955. for (n = 0; n < 100; n++) {
  3956. x = parseInt(n * imgW * 0.1);
  3957. context.drawImage(cimg, sx, sy, parseInt(imgW * 0.1), h, x, 0, parseInt(imgW * 0.1), h);
  3958. sx += parseInt(imgW * 0.1);
  3959. if (sx >= imgW) {
  3960. sx = 0;
  3961. sy += h;
  3962. }
  3963. thisTemp.css(cimg, 'display', 'none');
  3964. }
  3965. if (loadNum == srcArr.length) {
  3966. thisTemp.previewStart = 2;
  3967. } else {
  3968. i++;
  3969. loadImg(i);
  3970. }
  3971. };
  3972. };
  3973. }
  3974. loadImg(i);
  3975. return;
  3976. }
  3977. if (this.previewStart == 2) {
  3978. var isTween = true;
  3979. var nowNum = parseInt(obj['time'] / this.vars['preview']['scale']);
  3980. var numTotal = parseInt(thisTemp.getMetaDate()['duration'] / this.vars['preview']['scale']);
  3981. if (thisTemp.css(thisTemp.previewDiv, 'display') == 'none') {
  3982. isTween = false;
  3983. }
  3984. thisTemp.css(thisTemp.previewDiv, 'display', 'block');
  3985. var imgWidth = thisTemp.previewDiv.offsetWidth * 0.01 / srcArr.length;
  3986. var left = (imgWidth * nowNum) - obj['x'] + parseInt(imgWidth * 0.5),
  3987. top = obj['y'] - thisTemp.previewDiv.offsetHeight;
  3988. thisTemp.css(thisTemp.previewDiv, 'top', top + 2 + 'px');
  3989. var topLeft = obj['x'] - parseInt(imgWidth * 0.5);
  3990. var timepieces = 0;
  3991. if (topLeft < 0) {
  3992. topLeft = 0;
  3993. timepieces = obj['x'] - topLeft - imgWidth * 0.5;
  3994. }
  3995. if (topLeft > thisTemp.PD.offsetWidth - imgWidth) {
  3996. topLeft = thisTemp.PD.offsetWidth - imgWidth;
  3997. timepieces = obj['x'] - topLeft - imgWidth * 0.5;
  3998. }
  3999. if (left < 0) {
  4000. left = 0;
  4001. }
  4002. if (left > numTotal * imgWidth - thisTemp.PD.offsetWidth) {
  4003. left = numTotal * imgWidth - thisTemp.PD.offsetWidth;
  4004. }
  4005. thisTemp.css(thisTemp.previewTop, {
  4006. left: topLeft + 'px',
  4007. top: top + 2 + 'px',
  4008. display: 'block'
  4009. });
  4010. if (thisTemp.previewTop.offsetHeight > thisTemp.previewDiv.offsetHeight) {
  4011. thisTemp.css(thisTemp.previewTop, {
  4012. height: thisTemp.previewDiv.offsetHeight - (thisTemp.previewTop.offsetHeight - thisTemp.previewDiv.offsetHeight) + 'px'
  4013. });
  4014. }
  4015. if (this.previewTween != null) {
  4016. this.animatePause(this.previewTween);
  4017. this.previewTween = null
  4018. }
  4019. var nowLeft = parseInt(thisTemp.css(thisTemp.previewDiv, 'left'));
  4020. var leftC = nowLeft + left;
  4021. if (nowLeft == -(left + timepieces)) {
  4022. return;
  4023. }
  4024. if (isTween) {
  4025. var obj = {
  4026. element: thisTemp.previewDiv,
  4027. start: null,
  4028. end: -(left + timepieces),
  4029. speed: 0.3
  4030. };
  4031. this.previewTween = this.animate(obj);
  4032. } else {
  4033. thisTemp.css(thisTemp.previewDiv, 'left', -(left + timepieces) + 'px')
  4034. }
  4035. }
  4036. },
  4037. /*
  4038. 内部函数
  4039. 删除预览图节点
  4040. */
  4041. deletePreview: function() {
  4042. if (this.previewDiv != null) {
  4043. this.deleteChild(this.previewDiv);
  4044. this.previewDiv = null;
  4045. this.previewStart = 0;
  4046. }
  4047. },
  4048. /*
  4049. 内部函数
  4050. 修改视频地址,属性
  4051. */
  4052. changeVideo: function() {
  4053. if (!this.html5Video) {
  4054. this.getVarsObject();
  4055. this.V.newVideo(this.vars);
  4056. return;
  4057. }
  4058. var vArr = this.VA;
  4059. var v = this.vars;
  4060. var i = 0;
  4061. if (vArr.length < 1) {
  4062. return;
  4063. }
  4064. if (this.V != null && this.needSeek == 0) {
  4065. this.needSeek = this.V.currentTime;
  4066. }
  4067. if (v['poster']) {
  4068. this.V.poster = v['poster'];
  4069. } else {
  4070. this.V.removeAttribute('poster');
  4071. }
  4072. if (v['loop']) {
  4073. this.V.loop = 'loop';
  4074. } else {
  4075. this.V.removeAttribute('loop');
  4076. }
  4077. if (v['seek'] > 0) {
  4078. this.needSeek = v['seek'];
  4079. } else {
  4080. this.needSeek = 0;
  4081. }
  4082. if (this.getFileExt(vArr[0][0]) != '.m3u8') {
  4083. this.isM3u8 = false;
  4084. }
  4085. if (!this.isM3u8) {
  4086. if (vArr.length == 1) {
  4087. this.V.innerHTML = '';
  4088. this.V.src = vArr[0][0];
  4089. } else {
  4090. var source = '';
  4091. vArr = this.arrSort(vArr);
  4092. for (i = 0; i < vArr.length; i++) {
  4093. var type = '';
  4094. var va = vArr[i];
  4095. if (va[1]) {
  4096. type = ' type="' + va[1] + '"';
  4097. }
  4098. source += '<source src="' + va[0] + '"' + type + '>';
  4099. }
  4100. this.V.removeAttribute('src');
  4101. this.V.innerHTML = source;
  4102. }
  4103. //分析视频地址结束
  4104. if (v['autoplay']) {
  4105. this.V.autoplay = 'autoplay';
  4106. } else {
  4107. this.V.removeAttribute('autoplay');
  4108. }
  4109. this.V.load();
  4110. } else {
  4111. this.embedHls(vArr[0][0], v['autoplay']);
  4112. }
  4113. if (!this.isUndefined(v['volume'])) {
  4114. this.changeVolume(v['volume']);
  4115. }
  4116. this.resetPlayer(); //重置界面元素
  4117. this.timerErrorFun();
  4118. //如果存在字幕则加载
  4119. if (this.vars['cktrack']) {
  4120. this.loadTrack();
  4121. }
  4122. },
  4123. /*
  4124. 内部函数
  4125. 调整中间暂停按钮,缓冲loading,错误提示文本框的位置
  4126. */
  4127. elementCoordinate: function() {
  4128. this.pdCoor = this.getXY(this.PD);
  4129. try {
  4130. this.css(this.CB['pauseCenter'], {
  4131. left: parseInt((this.PD.offsetWidth - 80) * 0.5) + 'px',
  4132. top: parseInt((this.PD.offsetHeight - 80) * 0.5) + 'px'
  4133. });
  4134. } catch(event) {}
  4135. try {
  4136. this.css(this.CB['loading'], {
  4137. left: parseInt((this.PD.offsetWidth - 60) * 0.5) + 'px',
  4138. top: parseInt((this.PD.offsetHeight - 60) * 0.5) + 'px'
  4139. });
  4140. } catch(event) {}
  4141. try {
  4142. this.css(this.CB['errorText'], {
  4143. left: parseInt((this.PD.offsetWidth - 120) * 0.5) + 'px',
  4144. top: parseInt((this.PD.offsetHeight - 30) * 0.5) + 'px'
  4145. });
  4146. } catch(event) {}
  4147. try {
  4148. this.css(this.CB['logo'], {
  4149. left: parseInt(this.PD.offsetWidth - this.CB['logo'].offsetWidth - 20) + 'px',
  4150. top: '20px'
  4151. });
  4152. } catch(event) {}
  4153. this.checkBarWidth();
  4154. },
  4155. /*
  4156. 内部函数
  4157. 当播放器尺寸变化时,显示和隐藏相关节点
  4158. */
  4159. checkBarWidth: function() {
  4160. if (!this.showFace) {
  4161. return;
  4162. }
  4163. var controlBarW = this.CB['controlBar'].offsetWidth;
  4164. var ele = [];
  4165. ele.push([[this.CB['full'], this.CB['escFull'], this.CB['fullLine']], this.buttonWidth['full'] + 2, 'full']);
  4166. if (this.vars['front'] != '') {
  4167. ele.push([[this.CB['front'], this.CB['frontLine']], this.buttonWidth['front'] + 2]);
  4168. }
  4169. if (this.vars['next'] != '') {
  4170. ele.push([[this.CB['next'], this.CB['nextLine']], this.buttonWidth['next'] + 2]);
  4171. }
  4172. if (this.CB['definition'].innerHTML != '') {
  4173. ele.push([[this.CB['definition'], this.CB['definitionLine']], this.buttonWidth['definition'] + 2]);
  4174. }
  4175. if ((this.ckplayerConfig['config']['mobileVolumeBarShow'] || !this.isMobile()) && this.css(this.CB['volume'], 'display') != 'none') {
  4176. ele.push([[this.CB['volume']], this.buttonWidth['volume']]);
  4177. ele.push([[this.CB['mute'], this.CB['escMute'], this.CB['muteLine']], this.buttonWidth['mute'] + 2, 'mute']);
  4178. }
  4179. ele.push([[this.CB['timeText']], this.buttonWidth['timeText']]);
  4180. ele.push([[this.CB['play'], this.CB['pause'], this.CB['playLine']], this.buttonWidth['play'] + 2, 'play']);
  4181. var i = 0;
  4182. var len = 0;
  4183. var isc = true;
  4184. //计算所有要显示的节点的总宽度
  4185. for (var i = 0; i < ele.length; i++) {
  4186. var nlen = ele[i][1];
  4187. if (nlen > 2) {
  4188. len += nlen;
  4189. } else {
  4190. isc = false;
  4191. }
  4192. }
  4193. if (isc) {
  4194. this.buttonLen = len;
  4195. this.buttonArr = ele;
  4196. }
  4197. len = this.buttonLen;
  4198. ele = this.buttonArr;
  4199. for (var i = 0; i < ele.length; i++) {
  4200. if (len > controlBarW) {
  4201. len -= ele[i][1];
  4202. this.css(ele[i][0], 'display', 'none');
  4203. } else {
  4204. this.css(ele[i][0], 'display', 'block');
  4205. if (ele[i].length == 3) {
  4206. var name = ele[i][2];
  4207. switch (name) {
  4208. case 'mute':
  4209. if (this.volume == 0) {
  4210. this.css(this.CB['mute'], 'display', 'none');
  4211. } else {
  4212. this.css(this.CB['escMute'], 'display', 'none');
  4213. }
  4214. break;
  4215. case 'play':
  4216. this.playShow(this.V.paused ? false: true);
  4217. break;
  4218. case 'full':
  4219. if (this.full) {
  4220. this.css(this.CB['full'], 'display', 'none');
  4221. } else {
  4222. this.css(this.CB['escFull'], 'display', 'none');
  4223. }
  4224. break;
  4225. }
  4226. }
  4227. }
  4228. }
  4229. },
  4230. /*
  4231. 内部函数
  4232. 初始化暂停或播放按钮
  4233. */
  4234. initPlayPause: function() {
  4235. if (!this.showFace) {
  4236. return;
  4237. }
  4238. if (this.vars['autoplay']) {
  4239. this.css([this.CB['play'], this.CB['pauseCenter']], 'display', 'none');
  4240. this.css(this.CB['pause'], 'display', 'block');
  4241. } else {
  4242. this.css(this.CB['play'], 'display', 'block');
  4243. if (this.css(this.CB['errorText'], 'display') == 'none') {
  4244. this.css(this.CB['pauseCenter'], 'display', 'block');
  4245. }
  4246. this.css(this.CB['pause'], 'display', 'none');
  4247. }
  4248. },
  4249. /*
  4250. 下面为监听事件
  4251. 内部函数
  4252. 监听元数据已加载
  4253. */
  4254. loadedHandler: function() {
  4255. this.loaded = true;
  4256. if (this.vars['loaded'] != '') {
  4257. try {
  4258. eval(this.vars['loaded'] + '()');
  4259. } catch(event) {
  4260. this.log(event);
  4261. }
  4262. }
  4263. },
  4264. /*
  4265. 内部函数
  4266. 监听播放
  4267. */
  4268. playingHandler: function() {
  4269. this.playShow(true);
  4270. //如果是第一次播放
  4271. if (this.isFirstTimePlay && !this.isUndefined(this.advertisements['front'])) {
  4272. this.isFirstTimePlay = false;
  4273. //调用播放前置广告组件
  4274. this.adI = 0;
  4275. this.adType = 'front';
  4276. this.adMuteInto();
  4277. this.adIsVideoTime = true;
  4278. this.adPlayStart = true;
  4279. this.adVideoPlay = false;
  4280. this.videoPause();
  4281. this.advertisementsTime();
  4282. this.advertisementsPlay();
  4283. this.adSkipButtonShow();
  4284. //调用播放前置广告组件结束
  4285. return;
  4286. }
  4287. if (this.adPlayerPlay) {
  4288. return;
  4289. }
  4290. //判断第一次播放结束
  4291. if (this.needSeek > 0) {
  4292. this.videoSeek(this.needSeek);
  4293. this.needSeek = 0;
  4294. }
  4295. if (this.animatePauseArray.length > 0) {
  4296. this.animateResume('pause');
  4297. }
  4298. if (this.playerType == 'html5video' && this.V != null && this.config['videoDrawImage']) {
  4299. this.sendVCanvas();
  4300. }
  4301. if (!this.isUndefined(this.advertisements['pause']) && !this.adPlayStart) { //如果存在暂停广告
  4302. this.adPauseCloseFunction();
  4303. }
  4304. },
  4305. /*暂停时播放暂停广告*/
  4306. adPausePlayer: function() {
  4307. this.adI = 0;
  4308. this.adType = 'pause';
  4309. this.adPauseShow = true;
  4310. this.loadAdPause();
  4311. },
  4312. loadAdPause: function() {
  4313. var ad = this.getNowAdvertisements();
  4314. var type = ad['type'];
  4315. var thisTemp = this;
  4316. var width = this.PD.offsetWidth,
  4317. height = this.PD.offsetHeight;
  4318. if (this.isStrImage(type) && this.adPauseShow) {
  4319. this.css(this.CB['adElement'], 'display', 'block');
  4320. var imgClass = 'adimg' + this.randomString(10);
  4321. var imgHtml = '<img src="' + ad['file'] + '" class="' + imgClass + '">';
  4322. if (ad['link']) {
  4323. imgHtml = '<a href="' + ad['link'] + '" target="_blank">' + imgHtml + '</a>';
  4324. }
  4325. this.CB['adElement'].innerHTML = imgHtml;
  4326. this.addListenerInside('load',
  4327. function() {
  4328. var imgObj = new Image();
  4329. imgObj.src = this.src;
  4330. var imgWH = thisTemp.adjustmentWH(imgObj.width, imgObj.height);
  4331. thisTemp.css([thisTemp.getByElement(imgClass), thisTemp.CB['adElement']], {
  4332. width: imgWH['width'] + 'px',
  4333. height: imgWH['height'] + 'px',
  4334. border: '0px'
  4335. });
  4336. if (thisTemp.ckplayerConfig['style']['advertisement']['closeButtonShow'] && thisTemp.adPauseShow) {
  4337. thisTemp.css(thisTemp.CB['adPauseClose'], {
  4338. display: 'block'
  4339. });
  4340. }
  4341. thisTemp.ajaxSuccessNull(ad['exhibitionMonitor']);
  4342. thisTemp.adPauseCoor();
  4343. },
  4344. this.getByElement(imgClass));
  4345. this.addListenerInside('click',
  4346. function() {
  4347. thisTemp.ajaxSuccessNull(ad['clickMonitor']);
  4348. },
  4349. this.CB['adElement']);
  4350. var newI = this.adI;
  4351. if (this.adI < this.advertisements['pause'].length - 1) {
  4352. newI++;
  4353. } else {
  4354. newI = 0;
  4355. }
  4356. if (ad['time'] > 0) {
  4357. setTimeout(function() {
  4358. if (thisTemp.adPauseShow) {
  4359. thisTemp.adI = newI;
  4360. thisTemp.loadAdPause();
  4361. }
  4362. },
  4363. ad['time'] * 1000);
  4364. }
  4365. }
  4366. },
  4367. /*调整暂停广告的位置*/
  4368. adPauseCoor: function() {
  4369. if (this.css(this.CB['adElement'], 'display') == 'block') {
  4370. var w = this.CB['adElement'].offsetWidth,
  4371. h = this.CB['adElement'].offsetHeight;
  4372. var pw = this.PD.offsetWidth,
  4373. ph = this.PD.offsetHeight;
  4374. this.css(this.CB['adElement'], {
  4375. top: (ph - h) * 0.5 + 'px',
  4376. left: (pw - w) * 0.5 + 'px'
  4377. });
  4378. if (this.css(this.CB['adPauseClose'], 'display') == 'block') {
  4379. this.css(this.CB['adPauseClose'], {
  4380. top: (ph - h) * 0.5 - 10 + 'px',
  4381. left: (pw - w) * 0.5 + w - 10 + 'px'
  4382. });
  4383. }
  4384. }
  4385. },
  4386. /*
  4387. 关闭暂停广告
  4388. */
  4389. adPauseCloseFunction: function() {
  4390. this.CB['adElement'].innerHTML = '';
  4391. this.css([this.CB['adElement'], this.CB['adPauseClose']], 'display', 'none');
  4392. this.adPauseShow = false;
  4393. },
  4394. /*计算广告时间*/
  4395. advertisementsTime: function(nt) {
  4396. if (this.isUndefined(nt)) {
  4397. nt = 0;
  4398. }
  4399. var ad = this.advertisements[this.adType];
  4400. if (nt > 0) {
  4401. ad[this.adI]['time'] = Math.ceil(nt);
  4402. }
  4403. this.adTimeAllTotal = 0;
  4404. for (var i = this.adI; i < ad.length; i++) {
  4405. if (!this.isUndefined(ad[i]['time'])) {
  4406. this.adTimeAllTotal += Math.ceil(ad[i]['time']);
  4407. }
  4408. }
  4409. if (this.adTimeAllTotal > 0) {
  4410. this.CB['adTime'].innerHTML = this.language['adTime'].replace('{$second}', this.adTimeAllTotal > 9 ? this.adTimeAllTotal: '0' + this.adTimeAllTotal);
  4411. }
  4412. if (this.adPauseShow) {
  4413. this.adPauseCloseFunction();
  4414. }
  4415. this.adOtherCloseAll();
  4416. this.adTimeTotal = -1;
  4417. },
  4418. /*判断是否需要显示跳过广告按钮*/
  4419. adSkipButtonShow: function() {
  4420. var thisTemp = this;
  4421. var skipConfig = this.ckplayerConfig['style']['advertisement'];
  4422. var delayTimeTemp = skipConfig[this.adType + 'SkipButtonDelay'];
  4423. var timeFun = function() {
  4424. if (delayTimeTemp >= 0) {
  4425. thisTemp.CB['adSkip'].innerHTML = thisTemp.language['skipAdTime'].replace('{$second}', delayTimeTemp > 9 ? delayTimeTemp: '0' + delayTimeTemp);
  4426. setTimeout(timeFun, 1000);
  4427. } else {
  4428. thisTemp.CB['adSkip'].innerHTML = thisTemp.language['skipAd'];
  4429. }
  4430. delayTimeTemp--;
  4431. };
  4432. if (skipConfig['skipButtonShow']) {
  4433. this.css(thisTemp.CB['adSkip'], 'display', 'block');
  4434. if (skipConfig[this.adType + 'SkipButtonDelay'] > 0 && this.isUndefined(this.adSkipButtonTime)) {
  4435. timeFun();
  4436. } else {
  4437. thisTemp.css(thisTemp.CB['adSkip'], 'display', 'block');
  4438. thisTemp.CB['adSkip'].innerHTML = this.language['skipAd'];
  4439. }
  4440. }
  4441. },
  4442. /*播放广告*/
  4443. advertisementsPlay: function() {
  4444. this.css([this.CB['adBackground'], this.CB['adElement'], this.CB['adBar'], this.CB['adLink']], 'display', 'none');
  4445. this.adPlayerPlay = false;
  4446. var ad = this.advertisements[this.adType];
  4447. if (this.adI == 0 && (this.adType == 'front' || this.adType == 'insert' || this.adType == 'end')) {
  4448. this.sendJS('process', this.adType + ' ad play')
  4449. }
  4450. this.trackHide();
  4451. if (this.adI < ad.length) {
  4452. if (!this.isUndefined(ad[this.adI]['time'])) {
  4453. this.adTimeTotal = parseInt(ad[this.adI]['time']);
  4454. }
  4455. this.loadAdvertisements();
  4456. } else {
  4457. this.adEnded();
  4458. }
  4459. },
  4460. /*清除当前所有广告*/
  4461. eliminateAd: function() {
  4462. if (this.adType) {
  4463. var ad = this.advertisements[this.adType];
  4464. this.adI = ad.length;
  4465. this.advertisementsPlay();
  4466. }
  4467. },
  4468. /*广告播放结束*/
  4469. adEnded: function() {
  4470. var thisTemp = this;
  4471. this.adPlayStart = false;
  4472. if(this.adType=='front'){
  4473. this.time=0;
  4474. }
  4475. this.adPlayerPlay = false;
  4476. if (this.adVideoPlay) {
  4477. if (this.videoTemp['src'] != '') {
  4478. this.V.src = this.videoTemp['src'];
  4479. } else {
  4480. if (this.V.src) {
  4481. this.V.removeAttribute('src');
  4482. }
  4483. }
  4484. if (this.videoTemp['source'] != '') {
  4485. this.V.innerHTML = this.videoTemp['source'];
  4486. }
  4487. if (this.videoTemp['currentSrc'] != '') {
  4488. this.V.src = this.videoTemp['currentSrc'];
  4489. this.V.currentSrc = this.videoTemp['currentSrc'];
  4490. }
  4491. if (this.videoTemp['loop']) {
  4492. this.V.loop = true;
  4493. this.videoTemp['loop'] = false;
  4494. }
  4495. if (this.adType == 'end') {
  4496. this.endedHandler();
  4497. } else {
  4498. this.videoPlay();
  4499. }
  4500. } else {
  4501. this.videoPlay();
  4502. }
  4503. this.changeVolume(this.vars['volume']);
  4504. this.sendJS('process', this.adType + ' ad ended');
  4505. this.changeControlBarShow(true);
  4506. },
  4507. /*加载广告*/
  4508. loadAdvertisements: function() {
  4509. //this.videoTemp
  4510. var ad = this.getNowAdvertisements();
  4511. var type = ad['type'];
  4512. var thisTemp = this;
  4513. var width = this.PD.offsetWidth,
  4514. height = this.PD.offsetHeight;
  4515. this.changeControlBarShow(false);
  4516. this.adPlayerPlay = true;
  4517. if (this.isStrImage(type)) {
  4518. this.css([this.CB['adBackground'], this.CB['adElement'], this.CB['adBar']], 'display', 'block');
  4519. this.css([this.CB['adMute'], this.CB['adEscMute']], 'display', 'none');
  4520. var imgClass = 'adimg' + this.randomString(10);
  4521. var imgHtml = '<img src="' + ad['file'] + '" class="' + imgClass + '">';
  4522. if (ad['link']) {
  4523. imgHtml = '<a href="' + ad['link'] + '" target="_blank">' + imgHtml + '</a>';
  4524. }
  4525. this.CB['adElement'].innerHTML = imgHtml;
  4526. this.addListenerInside('load',
  4527. function() {
  4528. var imgObj = new Image();
  4529. imgObj.src = this.src;
  4530. var imgWH = thisTemp.adjustmentWH(imgObj.width, imgObj.height);
  4531. thisTemp.css(thisTemp.getByElement(imgClass), {
  4532. width: imgWH['width'] + 'px',
  4533. height: imgWH['height'] + 'px',
  4534. border: '0px'
  4535. });
  4536. thisTemp.css(thisTemp.CB['adElement'], {
  4537. width: imgWH['width'] + 'px',
  4538. height: imgWH['height'] + 'px',
  4539. top: (height - imgWH['height']) * 0.5 + 'px',
  4540. left: (width - imgWH['width']) * 0.5 + 'px'
  4541. });
  4542. thisTemp.ajaxSuccessNull(ad['exhibitionMonitor']);
  4543. },
  4544. this.getByElement(imgClass));
  4545. this.addListenerInside('click',
  4546. function() {
  4547. thisTemp.ajaxSuccessNull(ad['clickMonitor']);
  4548. },
  4549. this.CB['adElement']);
  4550. if (!this.isUndefined(ad['time'])) {
  4551. this.adCountDown();
  4552. }
  4553. } else {
  4554. this.css(this.CB['adBar'], 'display', 'block');
  4555. //判断是否静音
  4556. if (this.adVideoMute) {
  4557. this.css(this.CB['adEscMute'], 'display', 'block');
  4558. this.css(this.CB['adMute'], 'display', 'none');
  4559. } else {
  4560. this.css(this.CB['adEscMute'], 'display', 'none');
  4561. this.css(this.CB['adMute'], 'display', 'block');
  4562. }
  4563. this.CB['adElement'].innerHTML = '';
  4564. if (this.videoTemp['currentSrc'] == '') {
  4565. this.videoTemp['currentSrc'] = this.getCurrentSrc();
  4566. }
  4567. if (this.V.loop) {
  4568. this.videoTemp['loop'] = true;
  4569. this.V.loop = false;
  4570. }
  4571. if (this.V != null && this.V.currentTime > 0 && this.adIsVideoTime && this.adType!='front') { //当有视频广告时而又没有记录下已播放的时间则进行记录
  4572. this.adIsVideoTime = false;
  4573. this.needSeek = this.V.currentTime;
  4574. }
  4575. this.V.src = ad['file'];
  4576. this.V.currentSrc = ad['file'];
  4577. this.V.innerHTML = '';
  4578. this.V.play();
  4579. this.adVideoPlay = true;
  4580. this.ajaxSuccessNull(ad['exhibitionMonitor']);
  4581. if (!this.adVideoMute) {
  4582. this.adEscMuteFunction();
  4583. }
  4584. }
  4585. if (ad['link']) {
  4586. this.css(this.CB['adLink'], 'display', 'block');
  4587. var link = '<a href="' + ad['link'] + '" target="_blank" class="ckadmorelink">' + this.language['adLink'] + '</a>';
  4588. this.CB['adLink'].innerHTML = link;
  4589. this.css(this.getByElement('ckadmorelink'), {
  4590. color: '#FFFFFF',
  4591. textDecoration: 'none'
  4592. });
  4593. this.addListenerInside('click',
  4594. function() {
  4595. thisTemp.ajaxSuccessNull(ad['clickMonitor']);
  4596. },
  4597. this.CB['adLink']);
  4598. } else {
  4599. this.css(this.CB['adLink'], 'display', 'none');
  4600. }
  4601. },
  4602. /*普通广告倒计时*/
  4603. adCountDown: function() {
  4604. var thisTemp = this;
  4605. if (this.adTimeTotal > 0) {
  4606. if (!this.adIsPause) {
  4607. this.adTimeTotal--;
  4608. this.showAdTime();
  4609. this.adCountDownObj = null;
  4610. this.adCountDownObj = setTimeout(function() {
  4611. thisTemp.adCountDown();
  4612. },
  4613. 1000);
  4614. }
  4615. } else {
  4616. this.adI++;
  4617. this.advertisementsPlay();
  4618. }
  4619. },
  4620. /*视频广告倒计时*/
  4621. adPlayerTimeHandler: function(time) {
  4622. var ad = this.getNowAdvertisements();
  4623. var type = ad['type'];
  4624. if (this.isStrImage(type)) {
  4625. return;
  4626. }
  4627. if (this.adTimeTotal != parseInt(time)) {
  4628. this.adTimeTotal = parseInt(time);
  4629. this.showAdTime();
  4630. }
  4631. },
  4632. /*格式化广告倒计时显示*/
  4633. showAdTime: function() {
  4634. this.adTimeAllTotal--;
  4635. var n = this.adTimeAllTotal;
  4636. if (n < 0) {
  4637. n = 0;
  4638. }
  4639. this.CB['adTime'].innerHTML = this.language['adTime'].replace('{$second}', n < 10 ? '0' + n: n);
  4640. },
  4641. /*
  4642. 单独监听其它广告
  4643. */
  4644. checkAdOther: function(t) {
  4645. if (this.adPlayerPlay) {
  4646. return;
  4647. }
  4648. var adTime = this.advertisements['othertime'];
  4649. var adPlay = this.advertisements['otherPlay'];
  4650. for (var i = 0; i < adTime.length; i++) {
  4651. if (t >= adTime[i] && !adPlay[i]) { //如果播放时间大于广告时间而该广告还没有播放,则开始播放
  4652. adPlay[i] = true;
  4653. this.newAdOther(i);
  4654. }
  4655. }
  4656. },
  4657. /*
  4658. 新建其它广告
  4659. */
  4660. newAdOther: function(i) {
  4661. var thisTemp = this;
  4662. var ad = this.advertisements['other'][i];
  4663. var randomS = this.randomString(10); //获取一个随机字符串
  4664. var adDivID = 'adother' + randomS; //广告容器
  4665. imgClassName = 'adimgother' + randomS;
  4666. var adDiv = document.createElement('div');
  4667. adDiv.className = adDivID;
  4668. this.PD.appendChild(adDiv);
  4669. ad['div'] = adDivID;
  4670. ad['element'] = imgClassName;
  4671. var adHtml='<img src="' + ad['file'] + '" class="' + imgClassName + '">';
  4672. if(ad['link']){
  4673. adHtml='<a href="' + ad['link'] + '" target="blank">'+adHtml+'</a>';
  4674. }
  4675. this.getByElement(adDivID).innerHTML =adHtml;
  4676. this.css(adDivID, {
  4677. position: 'absolute',
  4678. overflow: 'hidden',
  4679. zIndex: '996',
  4680. top: '60px',
  4681. left: '30px',
  4682. cursor: 'pointer'
  4683. });
  4684. if (this.ckplayerConfig['style']['advertisement']['closeOtherButtonShow']) {
  4685. var closeAdDivID = 'adotherclose' + randomS; //广告容器
  4686. var closeAdDiv = document.createElement('div');
  4687. closeAdDiv.className = closeAdDivID;
  4688. this.PD.appendChild(closeAdDiv);
  4689. this.getByElement(closeAdDivID).innerHTML = this.newCanvas(closeAdDivID, 20, 20);
  4690. ad['closeDiv'] = closeAdDivID;
  4691. ad['close'] = false;
  4692. this.css(closeAdDivID, {
  4693. backgroundColor: '#f7f7f7',
  4694. //f8f7f7
  4695. widht: '20px',
  4696. height: '20px',
  4697. position: 'absolute',
  4698. overflow: 'hidden',
  4699. zIndex: '997',
  4700. top: '60px',
  4701. left: '30px',
  4702. borderRadius: '20px',
  4703. cursor: 'pointer'
  4704. });
  4705. var adOtherClose = this.getByElement(closeAdDivID + '-canvas').getContext('2d');
  4706. var adOtherCloseFillRect = function() {
  4707. thisTemp.canvasFill(adOtherClose, [[4, 6], [6, 6], [16, 15], [14, 15]]);
  4708. thisTemp.canvasFill(adOtherClose, [[14, 6], [16, 6], [6, 15], [4, 15]]);
  4709. };
  4710. adOtherClose.fillStyle = '#404856';
  4711. adOtherCloseFillRect();
  4712. var adOtherCloseOver = function() {
  4713. adOtherClose.clearRect(0, 0, 20, 20);
  4714. adOtherClose.fillStyle = '#0782F5';
  4715. adOtherCloseFillRect();
  4716. };
  4717. var adOtherCloseOut = function() {
  4718. adOtherClose.clearRect(0, 0, 20, 20);
  4719. adOtherClose.fillStyle = '#404856';
  4720. adOtherCloseFillRect();
  4721. };
  4722. this.addListenerInside('mouseover', adOtherCloseOver, this.getByElement(closeAdDivID + '-canvas'));
  4723. this.addListenerInside('mouseout', adOtherCloseOut, this.getByElement(closeAdDivID + '-canvas'));
  4724. }
  4725. this.addListenerInside('load',
  4726. function() {
  4727. var imgObj = new Image();
  4728. imgObj.src = this.src;
  4729. var imgWH = thisTemp.adjustmentWH(imgObj.width, imgObj.height);
  4730. thisTemp.css([thisTemp.getByElement(imgClassName), thisTemp.getByElement(adDivID)], {
  4731. width: imgWH['width'] + 'px',
  4732. height: imgWH['height'] + 'px',
  4733. border: '0px'
  4734. });
  4735. thisTemp.advertisements['other'][i] = ad;
  4736. thisTemp.ajaxSuccessNull(ad['exhibitionMonitor']);
  4737. thisTemp.adOtherCoor();
  4738. },
  4739. this.getByElement(imgClassName));
  4740. this.addListenerInside('click',
  4741. function() {
  4742. thisTemp.adOtherClose(i);
  4743. },
  4744. this.getByElement(closeAdDivID));
  4745. this.addListenerInside('click',
  4746. function() {
  4747. thisTemp.ajaxSuccessNull(ad['clickMonitor']);
  4748. },
  4749. this.getByElement(imgClassName));
  4750. if (ad['time'] > 0) {
  4751. setTimeout(function() {
  4752. thisTemp.adOtherClose(i);
  4753. },
  4754. ad['time'] * 1000);
  4755. }
  4756. },
  4757. /*
  4758. 关闭其它广告
  4759. */
  4760. adOtherClose: function(i) {
  4761. var ad = this.advertisements['other'][i];
  4762. if (!this.isUndefined(ad['close'])) {
  4763. if (!ad['close']) {
  4764. ad['close'] = true;
  4765. this.PD.removeChild(this.getByElement(ad['div']));
  4766. this.PD.removeChild(this.getByElement(ad['closeDiv']));
  4767. }
  4768. }
  4769. },
  4770. adOtherCloseAll: function() {
  4771. if (!this.isUndefined(this.advertisements['other'])) {
  4772. var ad = this.advertisements['other'];
  4773. for (var i = 0; i < ad.length; i++) {
  4774. this.adOtherClose(i);
  4775. }
  4776. }
  4777. },
  4778. /*
  4779. 计算其它广告的坐标
  4780. */
  4781. adOtherCoor: function() {
  4782. if (!this.isUndefined(this.advertisements['other'])) {
  4783. var arr = this.advertisements['other'];
  4784. for (var i = 0; i < arr.length; i++) {
  4785. var ad = arr[i];
  4786. if (!this.isUndefined(ad['close'])) {
  4787. if (!ad['close']) {
  4788. var coor = this.getPosition(ad);
  4789. var x = coor['x'],
  4790. y = coor['y'],
  4791. cx = x + this.getByElement(ad['div']).offsetWidth - 10,
  4792. cy = y - 10;
  4793. this.css(this.getByElement(ad['div']), {
  4794. left: x + 'px',
  4795. top: y + 'px'
  4796. });
  4797. if (!this.isUndefined(ad['closeDiv'])) {
  4798. this.css(this.getByElement(ad['closeDiv']), {
  4799. left: cx + 'px',
  4800. top: cy + 'px'
  4801. });
  4802. }
  4803. }
  4804. }
  4805. }
  4806. }
  4807. },
  4808. /*
  4809. 单独监听中间插入广告
  4810. */
  4811. checkAdInsert: function(t) {
  4812. if (this.adPlayerPlay) {
  4813. return;
  4814. }
  4815. var adTime = this.advertisements['inserttime'];
  4816. var adPlay = this.advertisements['insertPlay'];
  4817. var duration = this.getMetaDate()['duration'];
  4818. for (var i = adTime.length - 1; i > -1; i--) {
  4819. if (t >= adTime[i] && t < duration - 2 && t > 1 && !adPlay[i]) { //如果播放时间大于广告时间而该广告还没有播放,则开始播放
  4820. this.adI = 0;
  4821. this.adType = 'insert';
  4822. this.adMuteInto();
  4823. this.adIsVideoTime = true;
  4824. this.adPlayStart = true;
  4825. this.adVideoPlay = false;
  4826. this.videoPause();
  4827. this.advertisementsTime();
  4828. this.advertisementsPlay();
  4829. this.adSkipButtonShow();
  4830. adPlay[i] = true;
  4831. for (var n = 0; n < i + 1; n++) {
  4832. adPlay[n] = true;
  4833. }
  4834. break;
  4835. }
  4836. }
  4837. },
  4838. /*格式化中间插入广告的播放时间*/
  4839. formatInserttime: function(duration) {
  4840. if (!this.isUndefined(this.advertisements['inserttime'])) {
  4841. var arr = this.advertisements['inserttime'];
  4842. var newArr = [];
  4843. for (var i = 0; i < arr.length; i++) {
  4844. if (arr[i].toString().substr( - 1) == '%') {
  4845. newArr.push(parseInt(duration * parseInt(arr[i]) * 0.01));
  4846. } else {
  4847. newArr.push(parseInt(arr[i]));
  4848. }
  4849. }
  4850. this.advertisements['inserttime'] = newArr;
  4851. }
  4852. },
  4853. /*获取当前的广告*/
  4854. getNowAdvertisements: function() {
  4855. if (this.adI == -1) {
  4856. return {
  4857. file: '',
  4858. time: 0,
  4859. link: ''
  4860. };
  4861. }
  4862. return this.advertisements[this.adType][this.adI];
  4863. },
  4864. /*根据元件尺寸和播放器尺寸调整大小*/
  4865. adjustmentWH: function(w, h) {
  4866. var width = this.PD.offsetWidth,
  4867. height = this.PD.offsetHeight;
  4868. var nw = 0,
  4869. nh = 0;
  4870. if (w >= width || h >= height) {
  4871. if (width / w > height / h) {
  4872. nh = height - 20;
  4873. nw = w * nh / h;
  4874. } else {
  4875. nw = width - 20;
  4876. nh = h * nw / w;
  4877. }
  4878. } else {
  4879. nw = w;
  4880. nh = h;
  4881. }
  4882. return {
  4883. width: nw,
  4884. height: nh
  4885. }
  4886. },
  4887. /*单独请求一次地址,但不处理返回的数据*/
  4888. ajaxSuccessNull: function(url) {
  4889. if (!this.isUndefined(url)) {
  4890. var ajaxObj = {
  4891. url: url,
  4892. success: function(data) {}
  4893. };
  4894. this.ajax(ajaxObj);
  4895. }
  4896. },
  4897. /*
  4898. 内部函数
  4899. 运行指定函数
  4900. */
  4901. runFunction: function(s) {
  4902. try {
  4903. var arr = s.split('->');
  4904. switch (arr[0]) {
  4905. case 'javaScript':
  4906. eval(arr[1] + '()');
  4907. break;
  4908. case 'actionScript':
  4909. eval('this.' + arr[1] + '()');
  4910. break;
  4911. }
  4912. } catch(event) {}
  4913. },
  4914. /*
  4915. 内部函数
  4916. 使用画布附加视频
  4917. */
  4918. sendVCanvas: function() {
  4919. if (this.timerVCanvas == null) {
  4920. this.css(this.V, 'display', 'none');
  4921. this.css(this.MD, 'display', 'block');
  4922. var thisTemp = this;
  4923. var videoCanvas = function() {
  4924. if (thisTemp.MDCX.width != thisTemp.PD.offsetWidth) {
  4925. thisTemp.MDC.width = thisTemp.PD.offsetWidth;
  4926. }
  4927. if (thisTemp.MDCX.height != thisTemp.PD.offsetHeight) {
  4928. thisTemp.MDC.height = thisTemp.PD.offsetHeight;
  4929. }
  4930. thisTemp.MDCX.clearRect(0, 0, thisTemp.MDCX.width, thisTemp.MDCX.height);
  4931. var coor = thisTemp.getProportionCoor(thisTemp.PD.offsetWidth, thisTemp.PD.offsetHeight, thisTemp.V.videoWidth, thisTemp.V.videoHeight);
  4932. thisTemp.MDCX.drawImage(thisTemp.V, 0, 0, thisTemp.V.videoWidth, thisTemp.V.videoHeight, coor['x'], coor['y'], coor['width'], coor['height']);
  4933. };
  4934. this.timerVCanvas = new this.timer(0, videoCanvas);
  4935. }
  4936. },
  4937. /*
  4938. 内部函数
  4939. 监听暂停
  4940. */
  4941. pauseHandler: function() {
  4942. var thisTemp = this;
  4943. this.playShow(false);
  4944. if (this.animatePauseArray.length > 0) {
  4945. this.animatePause('pause');
  4946. }
  4947. if (this.playerType == 'html5video' && this.V != null && this.config['videoDrawImage']) {
  4948. this.stopVCanvas();
  4949. }
  4950. if (!this.isUndefined(this.advertisements['pause']) && !this.adPlayStart && !this.adPauseShow) { //如果存在暂停广告
  4951. setTimeout(function() {
  4952. if (!thisTemp.isUndefined(thisTemp.advertisements['pause']) && !thisTemp.adPlayStart && !thisTemp.adPauseShow && thisTemp.time > 1) { //如果存在暂停广告
  4953. thisTemp.adPausePlayer();
  4954. }
  4955. },
  4956. 300);
  4957. }
  4958. },
  4959. /*
  4960. 内部函数
  4961. 停止画布
  4962. */
  4963. stopVCanvas: function() {
  4964. if (this.timerVCanvas != null) {
  4965. this.css(this.V, 'display', 'block');
  4966. this.css(this.MD, 'display', 'none');
  4967. if (this.timerVCanvas.runing) {
  4968. this.timerVCanvas.stop();
  4969. }
  4970. this.timerVCanvas = null;
  4971. }
  4972. },
  4973. /*
  4974. 内部函数
  4975. 根据当前播放还是暂停确认图标显示
  4976. */
  4977. playShow: function(b) {
  4978. if (!this.showFace) {
  4979. return;
  4980. }
  4981. if (b) {
  4982. this.css(this.CB['play'], 'display', 'none');
  4983. this.css(this.CB['pauseCenter'], 'display', 'none');
  4984. this.css(this.CB['pause'], 'display', 'block');
  4985. } else {
  4986. this.css(this.CB['play'], 'display', 'block');
  4987. if (this.css(this.CB['errorText'], 'display') == 'none') {
  4988. if (!this.adPlayerPlay) {
  4989. this.css(this.CB['pauseCenter'], 'display', 'block');
  4990. }
  4991. } else {
  4992. this.css(this.CB['pauseCenter'], 'display', 'none');
  4993. }
  4994. this.css(this.CB['pause'], 'display', 'none');
  4995. }
  4996. },
  4997. /*
  4998. 内部函数
  4999. 监听seek结束
  5000. */
  5001. seekedHandler: function() {
  5002. this.resetTrack();
  5003. this.isTimeButtonMove = true;
  5004. if (this.V.paused) {
  5005. if(this.hlsAutoPlay){
  5006. this.videoPlay();
  5007. }
  5008. else{
  5009. this.hlsAutoPlay=true;
  5010. }
  5011. }
  5012. },
  5013. /*
  5014. 内部函数
  5015. 监听播放结束
  5016. */
  5017. endedHandler: function() {
  5018. if (this.adPlayerPlay) {
  5019. this.adI++;
  5020. this.advertisementsPlay();
  5021. return;
  5022. }
  5023. if (!this.endAdPlay && !this.isUndefined(this.advertisements['end'])) {
  5024. this.endAdPlay = true;
  5025. this.adI = 0;
  5026. this.adType = 'end';
  5027. this.adMuteInto();
  5028. this.adIsVideoTime = true;
  5029. this.adPlayStart = true;
  5030. this.adVideoPlay = false;
  5031. this.videoPause();
  5032. this.advertisementsTime();
  5033. this.advertisementsPlay();
  5034. this.adSkipButtonShow();
  5035. this.adReset = true;
  5036. return;
  5037. }
  5038. this.sendJS('ended');
  5039. this.endedAdReset();
  5040. if (this.vars['loop']) {
  5041. this.videoSeek(0);
  5042. }
  5043. },
  5044. /*
  5045. 重置结束后相关的设置
  5046. */
  5047. endedAdReset: function() {
  5048. var arr = [];
  5049. var i = 0;
  5050. if (!this.isUndefined(this.advertisements['insertPlay'])) {
  5051. arr = this.advertisements['insertPlay'];
  5052. for (i = 0; i < arr.length; i++) {
  5053. this.advertisements['insertPlay'][i] = false;
  5054. }
  5055. }
  5056. if (!this.isUndefined(this.advertisements['otherPlay'])) {
  5057. arr = this.advertisements['otherPlay'];
  5058. for (i = 0; i < arr.length; i++) {
  5059. this.advertisements['otherPlay'][i] = false;
  5060. }
  5061. }
  5062. //this.endAdPlay=false;
  5063. },
  5064. /*
  5065. 内部函数
  5066. 监听音量改变
  5067. */
  5068. volumechangeHandler: function() {
  5069. if (!this.showFace) {
  5070. return;
  5071. }
  5072. if ((this.ckplayerConfig['config']['mobileVolumeBarShow'] || !this.isMobile()) && this.css(this.CB['volume'], 'display') != 'none') {
  5073. try {
  5074. var volume=this.volume || this.V.volume;
  5075. if (volume > 0) {
  5076. this.css(this.CB['mute'], 'display', 'block');
  5077. this.css(this.CB['escMute'], 'display', 'none');
  5078. } else {
  5079. this.css(this.CB['mute'], 'display', 'none');
  5080. this.css(this.CB['escMute'], 'display', 'block');
  5081. }
  5082. } catch(event) {}
  5083. }
  5084. },
  5085. /*
  5086. 内部函数
  5087. 监听播放时间调节进度条
  5088. */
  5089. timeUpdateHandler: function() {
  5090. var duration = 0;
  5091. if (this.playerType == 'html5video') {
  5092. try {
  5093. duration = this.V.duration;
  5094. } catch(event) {}
  5095. }
  5096. if (isNaN(duration) || parseInt(duration) < 0.2) {
  5097. duration = this.vars['duration'];
  5098. }
  5099. if(this.vars['forceduration']>0){
  5100. duration=this.vars['forceduration'];
  5101. }
  5102. if (duration > 0) {
  5103. this.time = this.V.currentTime;
  5104. this.timeTextHandler();
  5105. this.trackShowHandler();
  5106. if (this.isTimeButtonMove) {
  5107. this.timeProgress(this.time, duration);
  5108. }
  5109. }
  5110. },
  5111. /*
  5112. 内部函数
  5113. 按时间改变进度条
  5114. */
  5115. timeProgress: function(time, duration) {
  5116. if (!this.showFace) {
  5117. return;
  5118. }
  5119. var timeProgressBgW = this.CB['timeProgressBg'].offsetWidth;
  5120. var timeBOW = parseInt((time * timeProgressBgW / duration) - (this.CB['timeButton'].offsetWidth * 0.5));
  5121. if (timeBOW > timeProgressBgW - this.CB['timeButton'].offsetWidth) {
  5122. timeBOW = timeProgressBgW - this.CB['timeButton'].offsetWidth;
  5123. }
  5124. if (timeBOW < 0) {
  5125. timeBOW = 0;
  5126. }
  5127. this.css(this.CB['timeProgress'], 'width', timeBOW + 'px');
  5128. this.css(this.CB['timeButton'], 'left', parseInt(timeBOW) + 'px');
  5129. },
  5130. /*
  5131. 内部函数
  5132. 监听播放时间改变时间显示文本框
  5133. */
  5134. timeTextHandler: function() { //显示时间/总时间
  5135. if (!this.showFace) {
  5136. return;
  5137. }
  5138. var duration = this.V.duration;
  5139. var time = this.V.currentTime;
  5140. if (isNaN(duration) || parseInt(duration) < 0.2) {
  5141. duration = this.vars['duration'];
  5142. }
  5143. if(this.vars['forceduration']>0){
  5144. duration=this.vars['forceduration'];
  5145. }
  5146. this.CB['timeText'].innerHTML = this.formatTime(time) + ' / ' + this.formatTime(duration);
  5147. if (this.CB['timeText'].offsetWidth > 0) {
  5148. this.buttonWidth['timeText'] = this.CB['timeText'].offsetWidth;
  5149. }
  5150. },
  5151. /*
  5152. 内部函数
  5153. 监听是否是缓冲状态
  5154. */
  5155. bufferEdHandler: function() {
  5156. if (!this.showFace || this.playerType == 'flashplayer') {
  5157. return;
  5158. }
  5159. var thisTemp = this;
  5160. var clearTimerBuffer = function() {
  5161. if (thisTemp.timerBuffer != null) {
  5162. if (thisTemp.timerBuffer.runing) {
  5163. thisTemp.sendJS('buffer', 100);
  5164. thisTemp.timerBuffer.stop();
  5165. }
  5166. thisTemp.timerBuffer = null;
  5167. }
  5168. };
  5169. clearTimerBuffer();
  5170. var bufferFun = function() {
  5171. if (!thisTemp.isUndefined(thisTemp.V) && thisTemp.V.buffered.length > 0) {
  5172. var duration = thisTemp.V.duration;
  5173. var len = thisTemp.V.buffered.length;
  5174. var bufferStart = thisTemp.V.buffered.start(len - 1);
  5175. var bufferEnd = thisTemp.V.buffered.end(len - 1);
  5176. var loadTime = bufferStart + bufferEnd;
  5177. var loadProgressBgW = thisTemp.CB['timeProgressBg'].offsetWidth;
  5178. var timeButtonW = thisTemp.CB['timeButton'].offsetWidth;
  5179. var loadW = parseInt((loadTime * loadProgressBgW / duration) + timeButtonW);
  5180. if (loadW >= loadProgressBgW) {
  5181. loadW = loadProgressBgW;
  5182. clearTimerBuffer();
  5183. }
  5184. thisTemp.changeLoad(loadTime);
  5185. }
  5186. };
  5187. this.timerBuffer = new this.timer(200, bufferFun);
  5188. },
  5189. /*
  5190. 内部函数
  5191. 单独计算加载进度
  5192. */
  5193. changeLoad: function(loadTime) {
  5194. if (this.V == null) {
  5195. return;
  5196. }
  5197. if (!this.showFace) {
  5198. return;
  5199. }
  5200. var loadProgressBgW = this.CB['timeProgressBg'].offsetWidth;
  5201. var timeButtonW = this.CB['timeButton'].offsetWidth;
  5202. var duration = this.V.duration;
  5203. if (isNaN(duration) || parseInt(duration) < 0.2) {
  5204. duration = this.vars['duration'];
  5205. }
  5206. if(this.vars['forceduration']>0){
  5207. duration=this.vars['forceduration'];
  5208. }
  5209. if (this.isUndefined(loadTime)) {
  5210. loadTime = this.loadTime;
  5211. } else {
  5212. this.loadTime = loadTime;
  5213. }
  5214. var loadW = parseInt((loadTime * loadProgressBgW / duration) + timeButtonW);
  5215. this.css(this.CB['loadProgress'], 'width', loadW + 'px');
  5216. this.sendJS('loadTime',loadTime);
  5217. this.loadTimeTemp=loadTime;
  5218. },
  5219. /*
  5220. 内部函数
  5221. 判断是否是直播
  5222. */
  5223. judgeIsLive: function() {
  5224. var thisTemp = this;
  5225. if (this.timerError != null) {
  5226. if (this.timerError.runing) {
  5227. this.timerError.stop();
  5228. }
  5229. this.timerError = null;
  5230. }
  5231. this.error = false;
  5232. if (this.showFace) {
  5233. this.css(this.CB['errorText'], 'display', 'none');
  5234. }
  5235. var timeupdate = function(event) {
  5236. thisTemp.timeUpdateHandler();
  5237. };
  5238. if (!this.vars['live']) {
  5239. if (this.V != null && this.playerType == 'html5video') {
  5240. this.addListenerInside('timeupdate', timeupdate);
  5241. thisTemp.timeTextHandler();
  5242. thisTemp.prompt(); //添加提示点
  5243. setTimeout(function() {
  5244. thisTemp.bufferEdHandler();
  5245. },
  5246. 200);
  5247. }
  5248. } else {
  5249. this.removeListenerInside('timeupdate', timeupdate);
  5250. if (this.timerTime != null) {
  5251. window.clearInterval(this.timerTime);
  5252. timerTime = null;
  5253. }
  5254. if (this.timerTime != null) {
  5255. if (this.timerTime.runing) {
  5256. this.timerTime.stop();
  5257. }
  5258. this.timerTime = null;
  5259. }
  5260. var timeFun = function() {
  5261. if (thisTemp.V != null && !thisTemp.V.paused && thisTemp.showFace) {
  5262. thisTemp.CB['timeText'].innerHTML = thisTemp.getNowDate();
  5263. }
  5264. };
  5265. this.timerTime = new this.timer(1000, timeFun);
  5266. //timerTime.start();
  5267. }
  5268. this.definition();
  5269. },
  5270. /*
  5271. 内部函数
  5272. 加载字幕
  5273. */
  5274. loadTrack: function(def) {
  5275. if (this.playerType == 'flashplayer' || this.vars['flashplayer'] == true) {
  5276. return;
  5277. }
  5278. if(this.isUndefined(def)){
  5279. def=-1;
  5280. }
  5281. var track = this.vars['cktrack'];
  5282. var loadTrackUrl='';
  5283. var type=this.typeString(track);
  5284. var thisTemp = this;
  5285. if(type=='array'){
  5286. if(def==-1){
  5287. var index=0;
  5288. var indexN=0;
  5289. for(var i=0;i<track.length;i++){
  5290. var li=track[i];
  5291. if(li.length==3 && li[2]>indexN){
  5292. indexN=li[2];
  5293. index=i;
  5294. }
  5295. }
  5296. }
  5297. else{
  5298. index=def;
  5299. }
  5300. loadTrackUrl=track[index][0];
  5301. }
  5302. else{
  5303. loadTrackUrl=track;
  5304. }
  5305. var obj = {
  5306. method: 'get',
  5307. dataType: 'text',
  5308. url: loadTrackUrl,
  5309. charset: 'utf-8',
  5310. success: function(data) {
  5311. if(data){
  5312. thisTemp.track = thisTemp.parseSrtSubtitles(data);
  5313. thisTemp.trackIndex = 0;
  5314. thisTemp.nowTrackShow = {
  5315. sn: ''
  5316. }
  5317. }
  5318. }
  5319. };
  5320. this.ajax(obj);
  5321. },
  5322. /*
  5323. 内部函数
  5324. 重置字幕
  5325. */
  5326. resetTrack: function() {
  5327. this.trackIndex = 0;
  5328. this.nowTrackShow = {
  5329. sn: ''
  5330. };
  5331. },
  5332. /*
  5333. 内部函数
  5334. 根据时间改变读取显示字幕
  5335. */
  5336. trackShowHandler: function() {
  5337. if (!this.showFace || this.adPlayerPlay) {
  5338. return;
  5339. }
  5340. if (this.track.length < 1) {
  5341. return;
  5342. }
  5343. if (this.trackIndex >= this.track.length) {
  5344. this.trackIndex = 0;
  5345. }
  5346. var nowTrack = this.track[this.trackIndex]; //当前编号对应的字幕内容
  5347. /*
  5348. this.nowTrackShow=当前显示在界面上的内容
  5349. 如果当前时间正好在nowTrack时间内,则需要判断
  5350. */
  5351. if (this.time >= nowTrack['startTime'] && this.time <= nowTrack['endTime']) {
  5352. /*
  5353. 如果当前显示的内容不等于当前需要显示的内容时,则需要显示正确的内容
  5354. */
  5355. var nowShow = this.nowTrackShow;
  5356. if (nowShow['sn'] != nowTrack['sn']) {
  5357. this.trackHide();
  5358. this.trackShow(nowTrack);
  5359. this.nowTrackTemp=nowTrack;
  5360. }
  5361. } else {
  5362. /*
  5363. * 如果当前播放时间不在当前编号字幕内,则需要先清空当前的字幕内容,再显示新的字幕内容
  5364. */
  5365. this.trackHide();
  5366. this.checkTrack();
  5367. }
  5368. },
  5369. trackShowAgain:function(){
  5370. this.trackHide();
  5371. this.trackShow(this.nowTrackTemp);
  5372. },
  5373. /*
  5374. 内部函数
  5375. 显示字幕内容
  5376. */
  5377. trackShow: function(track) {
  5378. this.nowTrackShow = track;
  5379. var arr = track['content'];
  5380. for (var i = 0; i < arr.length; i++) {
  5381. var obj = {
  5382. list: [{
  5383. type: 'text',
  5384. text: arr[i],
  5385. color: '#FFFFFF',
  5386. size: this.trackFontSize,
  5387. font: this.fontFamily,
  5388. lineHeight: this.trackLineHeight+'px'
  5389. }],
  5390. position: [1, 2, null, -(arr.length - i) * this.trackLineHeight - 50]
  5391. };
  5392. var ele = this.addElement(obj);
  5393. this.trackElement.push(ele);
  5394. }
  5395. },
  5396. /*
  5397. 内部函数
  5398. 隐藏字字幕内容
  5399. */
  5400. trackHide: function() {
  5401. for (var i = 0; i < this.trackElement.length; i++) {
  5402. this.deleteElement(this.trackElement[i]);
  5403. }
  5404. this.trackElement = [];
  5405. },
  5406. /*
  5407. 内部函数
  5408. 重新计算字幕的编号
  5409. */
  5410. checkTrack: function() {
  5411. var num = this.trackIndex;
  5412. var arr = this.track;
  5413. var i = 0;
  5414. for (i = num; i < arr.length; i++) {
  5415. if (this.time >= arr[i]['startTime'] && this.time <= arr[i]['endTime']) {
  5416. this.trackIndex = i;
  5417. break;
  5418. }
  5419. }
  5420. },
  5421. /*
  5422. -----------------------------------------------------------------------------接口函数开始
  5423. 接口函数
  5424. 在播放和暂停之间切换
  5425. */
  5426. playOrPause: function() {
  5427. if (!this.loaded) {
  5428. return;
  5429. }
  5430. if (this.V == null) {
  5431. return;
  5432. }
  5433. if (this.playerType == 'flashplayer') {
  5434. this.V.playOrPause();
  5435. return;
  5436. }
  5437. if (this.V.paused) {
  5438. this.videoPlay();
  5439. } else {
  5440. this.videoPause();
  5441. }
  5442. },
  5443. /*
  5444. 接口函数
  5445. 播放动作
  5446. */
  5447. videoPlay: function() {
  5448. if (!this.loaded) {
  5449. return;
  5450. }
  5451. if (this.playerType == 'flashplayer') {
  5452. this.V.videoPlay();
  5453. return;
  5454. }
  5455. if (this.adPlayerPlay) {
  5456. this.eliminateAd(); //清除广告
  5457. return;
  5458. }
  5459. try {
  5460. if (this.V.currentSrc) {
  5461. this.V.play();
  5462. }
  5463. } catch(event) {}
  5464. },
  5465. /*
  5466. 接口函数
  5467. 暂停动作
  5468. */
  5469. videoPause: function() {
  5470. if (!this.loaded) {
  5471. return;
  5472. }
  5473. if (this.playerType == 'flashplayer') {
  5474. this.V.videoPause();
  5475. return;
  5476. }
  5477. try {
  5478. this.V.pause();
  5479. } catch(event) {}
  5480. },
  5481. /*
  5482. 接口函数
  5483. 跳转时间动作
  5484. */
  5485. videoSeek: function(time) {
  5486. if (!this.loaded) {
  5487. return;
  5488. }
  5489. if (this.playerType == 'flashplayer') {
  5490. this.V.videoSeek(time);
  5491. return;
  5492. }
  5493. var duration = this.V.duration>0.2?this.V.duration:this.getMetaDate()['duration'];
  5494. if (duration > 0 && time > duration) {
  5495. if(this.vars['forceduration']>0){
  5496. time=0;
  5497. this.sendJS('ended');
  5498. }
  5499. else{
  5500. time = duration-0.1;
  5501. }
  5502. }
  5503. if (time >= 0) {
  5504. this.V.currentTime = time;
  5505. this.sendJS('seekTime', time);
  5506. }
  5507. },
  5508. /*
  5509. 接口函数
  5510. 调节音量/获取音量
  5511. */
  5512. changeVolume: function(vol, bg, button) {
  5513. if (this.loaded) {
  5514. if (this.playerType == 'flashplayer') {
  5515. this.V.changeVolume(vol);
  5516. return;
  5517. }
  5518. }
  5519. if (isNaN(vol) || this.isUndefined(vol)) {
  5520. vol = 0;
  5521. }
  5522. if (!this.loaded) {
  5523. this.vars['volume'] = vol;
  5524. }
  5525. if (!this.html5Video) {
  5526. this.V.changeVolume(vol);
  5527. return;
  5528. }
  5529. try {
  5530. if (this.isUndefined(bg)) {
  5531. bg = true;
  5532. }
  5533. } catch(e) {}
  5534. try {
  5535. if (this.isUndefined(button)) {
  5536. button = true;
  5537. }
  5538. } catch(e) {}
  5539. if (!vol) {
  5540. vol = 0;
  5541. }
  5542. if (vol < 0) {
  5543. vol = 0;
  5544. }
  5545. if (vol > 1) {
  5546. vol = 1;
  5547. }
  5548. try {
  5549. this.V.volume = vol;
  5550. } catch(error) {}
  5551. this.volume = vol;
  5552. if (bg && this.showFace) {
  5553. var bgW = vol * this.CB['volumeBg'].offsetWidth;
  5554. if (bgW < 0) {
  5555. bgW = 0;
  5556. }
  5557. if (bgW > this.CB['volumeBg'].offsetWidth) {
  5558. bgW = this.CB['volumeBg'].offsetWidth;
  5559. }
  5560. this.css(this.CB['volumeUp'], 'width', bgW + 'px');
  5561. }
  5562. if (button && this.showFace) {
  5563. var buLeft = parseInt(this.CB['volumeUp'].offsetWidth - (this.CB['volumeBO'].offsetWidth * 0.5));
  5564. if (buLeft > this.CB['volumeBg'].offsetWidth - this.CB['volumeBO'].offsetWidth) {
  5565. buLeft = this.CB['volumeBg'].offsetWidth - this.CB['volumeBO'].offsetWidth
  5566. }
  5567. if (buLeft < 0) {
  5568. buLeft = 0;
  5569. }
  5570. this.css(this.CB['volumeBO'], 'left', buLeft + 'px');
  5571. }
  5572. },
  5573. /*
  5574. 接口函数
  5575. 静音
  5576. */
  5577. videoMute: function() {
  5578. if (!this.loaded) {
  5579. return;
  5580. }
  5581. if (this.playerType == 'flashplayer') {
  5582. this.V.videoMute();
  5583. return;
  5584. }
  5585. this.volumeTemp = this.V ? (this.V.volume > 0 ? this.V.volume: this.vars['volume']) : this.vars['volume'];
  5586. this.changeVolume(0);
  5587. },
  5588. /*
  5589. 接口函数
  5590. 取消静音
  5591. */
  5592. videoEscMute: function() {
  5593. if (!this.loaded) {
  5594. return;
  5595. }
  5596. if (this.playerType == 'flashplayer') {
  5597. this.V.videoEscMute();
  5598. return;
  5599. }
  5600. this.changeVolume(this.volumeTemp > 0 ? this.volumeTemp: this.vars['volume']);
  5601. },
  5602. /*
  5603. 接口函数
  5604. 视频广告静音
  5605. */
  5606. adMuteFunction: function() {
  5607. if (!this.loaded) {
  5608. return;
  5609. }
  5610. this.changeVolume(0);
  5611. this.adVideoMute = true;
  5612. this.css(this.CB['adEscMute'], 'display', 'block');
  5613. this.css(this.CB['adMute'], 'display', 'none');
  5614. },
  5615. /*
  5616. 接口函数
  5617. 视频广告取消静音
  5618. */
  5619. adEscMuteFunction: function() {
  5620. if (!this.loaded) {
  5621. return;
  5622. }
  5623. var v = this.ckplayerConfig['style']['advertisement']['videoVolume'];
  5624. this.changeVolume(v);
  5625. this.adMuteInto();
  5626. },
  5627. /*
  5628. 初始化广告的音量按钮
  5629. */
  5630. adMuteInto: function() {
  5631. this.adVideoMute = false;
  5632. this.css(this.CB['adEscMute'], 'display', 'none');
  5633. this.css(this.CB['adMute'], 'display', 'block');
  5634. },
  5635. /*
  5636. 接口函数
  5637. 快退
  5638. */
  5639. fastBack: function() {
  5640. if (!this.loaded) {
  5641. return;
  5642. }
  5643. if (this.playerType == 'flashplayer') {
  5644. this.V.fastBack();
  5645. return;
  5646. }
  5647. var time = this.time - this.ckplayerConfig['config']['timeJump'];
  5648. if (time < 0) {
  5649. time = 0;
  5650. }
  5651. this.videoSeek(time);
  5652. },
  5653. /*
  5654. 接口函数
  5655. 快进
  5656. */
  5657. fastNext: function() {
  5658. if (!this.loaded) {
  5659. return;
  5660. }
  5661. if (this.playerType == 'flashplayer') {
  5662. this.V.fastNext();
  5663. return;
  5664. }
  5665. var time = this.time + this.ckplayerConfig['config']['timeJump'];
  5666. if (time > this.V.duration) {
  5667. time = this.V.duration;
  5668. }
  5669. this.videoSeek(time);
  5670. },
  5671. /*
  5672. 接口函数
  5673. 获取当前播放的地址
  5674. */
  5675. getCurrentSrc: function() {
  5676. if (!this.loaded) {
  5677. return;
  5678. }
  5679. if (this.playerType == 'flashplayer') {
  5680. return this.V.getCurrentSrc();
  5681. }
  5682. return this.V.currentSrc;
  5683. },
  5684. /*
  5685. 内置函数
  5686. 全屏/退出全屏动作,该动作只能是用户操作才可以触发,比如用户点击按钮触发该事件
  5687. */
  5688. switchFull: function() {
  5689. if (this.full) {
  5690. this.quitFullScreen();
  5691. } else {
  5692. this.fullScreen();
  5693. }
  5694. },
  5695. /*
  5696. 内置函数
  5697. 全屏动作,该动作只能是用户操作才可以触发,比如用户点击按钮触发该事件
  5698. */
  5699. fullScreen: function() {
  5700. if (this.html5Video && this.playerType == 'html5video') {
  5701. var element = this.PD;
  5702. if (element.requestFullscreen) {
  5703. element.requestFullscreen();
  5704. } else if (element.mozRequestFullScreen) {
  5705. element.mozRequestFullScreen();
  5706. } else if (element.webkitRequestFullscreen) {
  5707. element.webkitRequestFullscreen();
  5708. } else if (element.msRequestFullscreen) {
  5709. element.msRequestFullscreen();
  5710. } else if (element.oRequestFullscreen) {
  5711. element.oRequestFullscreen();
  5712. }
  5713. this.judgeFullScreen();
  5714. } else {
  5715. //this.V.fullScreen();
  5716. }
  5717. },
  5718. /*
  5719. 接口函数
  5720. 退出全屏动作
  5721. */
  5722. quitFullScreen: function() {
  5723. if (this.html5Video && this.playerType == 'html5video') {
  5724. if (document.exitFullscreen) {
  5725. document.exitFullscreen();
  5726. } else if (document.msExitFullscreen) {
  5727. document.msExitFullscreen();
  5728. } else if (document.mozCancelFullScreen) {
  5729. document.mozCancelFullScreen();
  5730. } else if (document.oRequestFullscreen) {
  5731. document.oCancelFullScreen();
  5732. } else if (document.requestFullscreen) {
  5733. document.requestFullscreen();
  5734. } else if (document.webkitExitFullscreen) {
  5735. document.webkitExitFullscreen();
  5736. } else {
  5737. this.css(document.documentElement, 'cssText', '');
  5738. this.css(document.document.body, 'cssText', '');
  5739. this.css(this.PD, 'cssText', '');
  5740. }
  5741. this.judgeFullScreen();
  5742. }
  5743. },
  5744. /*
  5745. 下面列出只有flashplayer里支持的
  5746. */
  5747. videoRotation: function(n) {
  5748. if (!this.loaded) {
  5749. return;
  5750. }
  5751. if (this.playerType == 'flashplayer') {
  5752. this.V.videoRotation(n);
  5753. return;
  5754. }
  5755. if (this.isUndefined(n)) {
  5756. n = 0;
  5757. }
  5758. var tf = this.css(this.V, 'transform');
  5759. if (this.isUndefined(tf) && !tf) {
  5760. tf = 'rotate(0deg)';
  5761. }
  5762. var reg = tf.match(/rotate\([^)]+\)/);
  5763. reg = reg ? reg[0].replace('rotate(', '').replace('deg)', '') : '';
  5764. if (reg == '') {
  5765. reg = 0;
  5766. } else {
  5767. reg = parseInt(reg);
  5768. }
  5769. if (n == -1) {
  5770. reg -= 90;
  5771. } else if (n == 1) {
  5772. reg += 90;
  5773. } else {
  5774. if (n != 90 && n != 180 && n != 270 && n != -90 && n != -180 && n != -270) {
  5775. reg = 0;
  5776. } else {
  5777. reg = n;
  5778. }
  5779. }
  5780. n = reg;
  5781. var y90 = n % 90,
  5782. y180 = n % 180,
  5783. y270 = n % 270;
  5784. var ys = false;
  5785. if (y90 == 0 && y180 == 90 && y270 == 90) {
  5786. ys = true;
  5787. }
  5788. if (y90 == 0 && y180 == 90 && y270 == 0) {
  5789. ys = true;
  5790. }
  5791. if (y90 == -0 && y180 == -90 && y270 == -90) {
  5792. ys = true;
  5793. }
  5794. if (y90 == -0 && y180 == -90 && y270 == -0) {
  5795. ys = true;
  5796. }
  5797. tf = tf.replace(/rotate\([^)]+\)/, '').replace(/scale\([^)]+\)/, '') + ' rotate(' + n + 'deg)';
  5798. var cdW = this.CD.offsetWidth,
  5799. cdH = this.CD.offsetHeight,
  5800. vW = this.V.videoWidth,
  5801. vH = this.V.videoHeight;
  5802. if (vW > 0 && vH > 0) {
  5803. if (ys) {
  5804. if (cdW / cdH > vH / vW) {
  5805. nH = cdH;
  5806. nW = vH * nH / vW;
  5807. } else {
  5808. nW = cdW;
  5809. nH = vW * nW / vH;
  5810. }
  5811. this.css(this.V, 'transform', 'rotate(0deg)');
  5812. this.css(this.V, 'transform', 'scale(' + nH / cdW + ',' + nW / cdH + ')' + tf);
  5813. } else {
  5814. this.css(this.V, 'transform', tf);
  5815. }
  5816. } else {
  5817. this.css(this.V, 'transform', tf);
  5818. }
  5819. return;
  5820. },
  5821. videoBrightness: function(n) {
  5822. if (!this.loaded) {
  5823. return;
  5824. }
  5825. if (this.playerType == 'flashplayer') {
  5826. this.V.videoBrightness(n);
  5827. return;
  5828. }
  5829. },
  5830. videoContrast: function(n) {
  5831. if (!this.loaded) {
  5832. return;
  5833. }
  5834. if (this.playerType == 'flashplayer') {
  5835. this.V.videoContrast(n);
  5836. return;
  5837. }
  5838. },
  5839. videoSaturation: function(n) {
  5840. if (!this.loaded) {
  5841. return;
  5842. }
  5843. if (this.playerType == 'flashplayer') {
  5844. this.V.videoSaturation(n);
  5845. return;
  5846. }
  5847. },
  5848. videoHue: function(n) {
  5849. if (!this.loaded) {
  5850. return;
  5851. }
  5852. if (this.playerType == 'flashplayer') {
  5853. this.V.videoHue(n);
  5854. return;
  5855. }
  5856. },
  5857. videoZoom: function(n) {
  5858. if (!this.loaded) {
  5859. return;
  5860. }
  5861. if (this.playerType == 'flashplayer') {
  5862. this.V.videoZoom(n);
  5863. return;
  5864. }
  5865. if (this.isUndefined(n)) {
  5866. n = 1;
  5867. }
  5868. if (n < 0) {
  5869. n = 0;
  5870. }
  5871. if (n > 2) {
  5872. n = 2;
  5873. }
  5874. var tf = this.css(this.V, 'transform');
  5875. tf = tf.replace(/scale\([^)]+\)/, '') + ' scale(' + n + ')';
  5876. this.videoScale = n;
  5877. this.css(this.V, 'transform', tf);
  5878. return;
  5879. },
  5880. videoProportion: function(w, h) {
  5881. if (!this.loaded) {
  5882. return;
  5883. }
  5884. if (this.playerType == 'flashplayer') {
  5885. this.V.videoProportion(w, h);
  5886. return;
  5887. }
  5888. },
  5889. adPlay: function() {
  5890. if (!this.loaded) {
  5891. return;
  5892. }
  5893. if (this.playerType == 'flashplayer') {
  5894. this.V.adPlay();
  5895. return;
  5896. }
  5897. if (this.adPlayerPlay) {
  5898. this.adIsPause = false;
  5899. var ad = this.getNowAdvertisements();
  5900. var type = ad['type'];
  5901. if (this.isStrImage(type)) {
  5902. this.adCountDown();
  5903. } else {
  5904. this.V.play();
  5905. }
  5906. }
  5907. },
  5908. adPause: function() {
  5909. if (!this.loaded) {
  5910. return;
  5911. }
  5912. if (this.playerType == 'flashplayer') {
  5913. this.V.adPause();
  5914. return;
  5915. }
  5916. if (this.adPlayerPlay) {
  5917. this.adIsPause = true;
  5918. var ad = this.getNowAdvertisements();
  5919. var type = ad['type'];
  5920. if (type != 'jpg' && type != 'jpeg' && type != 'png' && type != 'svg' && type != 'gif') {
  5921. this.videoPause();
  5922. }
  5923. }
  5924. },
  5925. videoError: function(n) {
  5926. if (!this.loaded) {
  5927. return;
  5928. }
  5929. if (this.playerType == 'flashplayer') {
  5930. this.V.videoError(n);
  5931. return;
  5932. }
  5933. },
  5934. changeConfig: function() {
  5935. if (!this.loaded) {
  5936. return;
  5937. }
  5938. if (this.playerType == 'flashplayer') {
  5939. var args = Array.prototype.slice.call(arguments);
  5940. switch(args.length){
  5941. case 1:
  5942. this.V.changeConfig(args[0]);
  5943. break;
  5944. case 2:
  5945. this.V.changeConfig(args[0],args[1]);
  5946. break;
  5947. case 3:
  5948. this.V.changeConfig(args[0],args[1],args[2]);
  5949. break;
  5950. case 4:
  5951. this.V.changeConfig(args[0],args[1],args[2],args[3]);
  5952. break;
  5953. case 5:
  5954. this.V.changeConfig(args[0],args[1],args[2],args[3],args[4]);
  5955. break;
  5956. case 6:
  5957. this.V.changeConfig(args[0],args[1],args[2],args[3],args[4],args[5]);
  5958. break;
  5959. case 7:
  5960. this.V.changeConfig(args[0],args[1],args[2],args[3],args[4],args[5],args[6]);
  5961. break;
  5962. case 8:
  5963. this.V.changeConfig(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]);
  5964. break;
  5965. case 8:
  5966. this.V.changeConfig(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]);
  5967. break;
  5968. }
  5969. return;
  5970. }
  5971. var obj = this.ckplayerConfig;
  5972. var arg = arguments;
  5973. for (var i = 0; i < arg.length - 1; i++) {
  5974. if (obj.hasOwnProperty(arg[i])) {
  5975. obj = obj[arg[i]];
  5976. } else {
  5977. return;
  5978. }
  5979. }
  5980. var val = arg[arg.length - 1];
  5981. switch (arg.length) {
  5982. case 2:
  5983. this.ckplayerConfig[arg[0]] = val;
  5984. break;
  5985. case 3:
  5986. this.ckplayerConfig[arg[0]][arg[1]] = val;
  5987. break;
  5988. case 4:
  5989. this.ckplayerConfig[arg[0]][arg[1]][arg[2]] = val;
  5990. break;
  5991. case 5:
  5992. this.ckplayerConfig[arg[0]][arg[1]][arg[2]][arg[3]] = val;
  5993. break;
  5994. case 6:
  5995. this.ckplayerConfig[arg[0]][arg[1]][arg[2]][arg[3]][arg[4]] = val;
  5996. break;
  5997. case 7:
  5998. this.ckplayerConfig[arg[0]][arg[1]][arg[2]][arg[3]][arg[4]][arg[5]] = val;
  5999. break;
  6000. case 8:
  6001. this.ckplayerConfig[arg[0]][arg[1]][arg[2]][arg[3]][arg[4]][arg[5]][arg[6]] = val;
  6002. break;
  6003. case 9:
  6004. this.ckplayerConfig[arg[0]][arg[1]][arg[2]][arg[3]][arg[4]][arg[5]][arg[6]][arg[7]] = val;
  6005. break;
  6006. case 10:
  6007. this.ckplayerConfig[arg[0]][arg[1]][arg[2]][arg[3]][arg[4]][arg[5]][arg[6]][arg[7]][arg[8]] = val;
  6008. break;
  6009. default:
  6010. return;
  6011. break;
  6012. }
  6013. this.sendJS('configChange', this.ckplayerConfig);
  6014. },
  6015. custom: function() {
  6016. if (!this.loaded) {
  6017. return;
  6018. }
  6019. if (this.playerType == 'flashplayer') {
  6020. this.V.custom(arguments);
  6021. return;
  6022. }
  6023. },
  6024. getConfig: function() {
  6025. if (!this.loaded) {
  6026. return null;
  6027. }
  6028. if (this.playerType == 'flashplayer') {
  6029. return this.V.getConfig(arguments);
  6030. }
  6031. else{
  6032. var temp=this.ckplayerConfig;
  6033. for(var index in arguments) {
  6034. try{
  6035. temp=temp[arguments[index]];
  6036. }
  6037. catch(error){
  6038. temp=null;
  6039. }
  6040. };
  6041. return temp;
  6042. }
  6043. },
  6044. openUrl: function(n) {
  6045. if (!this.loaded) {
  6046. return;
  6047. }
  6048. if (this.playerType == 'flashplayer') {
  6049. this.V.openUrl(n);
  6050. return;
  6051. }
  6052. },
  6053. /*
  6054. 接口函数
  6055. 清除视频
  6056. */
  6057. videoClear: function() {
  6058. if (!this.loaded) {
  6059. return;
  6060. }
  6061. if (this.playerType == 'flashplayer') {
  6062. this.V.videoClear();
  6063. return;
  6064. }
  6065. },
  6066. /*
  6067. 接口函数
  6068. 向播放器传递新的视频地址
  6069. */
  6070. newVideo: function(c) {
  6071. if (this.playerType == 'flashplayer') {
  6072. this.V.newVideo(c);
  6073. return;
  6074. } else {
  6075. this.embed(c);
  6076. }
  6077. },
  6078. /*
  6079. 接口函数
  6080. 截图
  6081. */
  6082. screenshot: function(obj, save, name) {
  6083. if (!this.loaded) {
  6084. return;
  6085. }
  6086. if (this.playerType == 'flashplayer') {
  6087. try {
  6088. this.V.screenshot(obj, save, name);
  6089. } catch(error) {
  6090. this.log(error);
  6091. }
  6092. return;
  6093. }
  6094. if (obj == 'video') {
  6095. var newCanvas = document.createElement('canvas');
  6096. newCanvas.width = this.V.videoWidth;
  6097. newCanvas.height = this.V.videoHeight;
  6098. newCanvas.getContext('2d').drawImage(this.V, 0, 0, this.V.videoWidth, this.V.videoHeight);
  6099. try {
  6100. var base64 = newCanvas.toDataURL('image/jpeg');
  6101. this.sendJS('screenshot', {
  6102. object: obj,
  6103. save: save,
  6104. name: name,
  6105. base64: base64
  6106. });
  6107. } catch(error) {
  6108. this.log(error);
  6109. }
  6110. }
  6111. },
  6112. /*
  6113. 接口函数
  6114. 改变播放器尺寸
  6115. */
  6116. changeSize: function(w, h) {
  6117. if (this.isUndefined(w)) {
  6118. w = 0;
  6119. }
  6120. if (this.isUndefined(h)) {
  6121. h = 0;
  6122. }
  6123. if (w > 0) {
  6124. this.css(this.CD, 'width', w + 'px');
  6125. }
  6126. if (h > 0) {
  6127. this.css(this.CD, 'height', h + 'px');
  6128. }
  6129. if (this.html5Video) {
  6130. this.elementCoordinate();
  6131. }
  6132. },
  6133. /*
  6134. 接口函数
  6135. 改变视频播放速度
  6136. */
  6137. changePlaybackRate: function(n) {
  6138. if (this.html5Video) {
  6139. var arr = this.playbackRateArr;
  6140. n = parseInt(n);
  6141. if (n < arr.length) {
  6142. this.newPlaybackrate(arr[n][1]);
  6143. }
  6144. }
  6145. },
  6146. /*
  6147. 内部函数
  6148. 注册控制控制栏显示与隐藏函数
  6149. */
  6150. changeControlBarShow: function(show) {
  6151. if (!this.loaded) {
  6152. return;
  6153. }
  6154. if (this.playerType == 'flashplayer') {
  6155. this.V.changeControlBarShow(show);
  6156. return;
  6157. }
  6158. if (show) {
  6159. this.controlBarIsShow = true;
  6160. this.controlBarHide(false);
  6161. } else {
  6162. this.controlBarIsShow = false;
  6163. this.controlBarHide(true);
  6164. }
  6165. },
  6166. /*
  6167. -----------------------------------------------------------------------
  6168. 调用flashplayer
  6169. */
  6170. embedSWF: function() {
  6171. var vid = this.randomString();
  6172. var flashvars = this.getFlashVars();
  6173. var param = this.getFlashplayerParam();
  6174. var flashplayerUrl = 'http://www.macromedia.com/go/getflashplayer';
  6175. var html = '',
  6176. src = javascriptPath + 'ckplayer.swf';
  6177. id = 'id="' + vid + '" name="' + vid + '" ';
  6178. html += '<object pluginspage="' + flashplayerUrl + '" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=11,3,0,0" width="100%" height="100%" ' + id + ' align="middle" wmode="transparent">';
  6179. html += param['v'];
  6180. html += '<param name="movie" value="' + src + '">';
  6181. html += '<param name="flashvars" value="' + flashvars + '">';
  6182. html += '<param name="wmode" value="transparent">';
  6183. html += '<embed wmode="transparent" ' + param['w'] + ' src="' + src + '" flashvars="' + flashvars + '" width="100%" height="100%" ' + id + ' align="middle" type="application/x-shockwave-flash" pluginspage="' + flashplayerUrl + '" />';
  6184. html += '</object>';
  6185. this.PD.innerHTML = html;
  6186. this.V = this.getObjectById(vid); //V:定义播放器对象全局变量
  6187. this.playerType = 'flashplayer';
  6188. //if(!this.checkShockwaveFlash()){
  6189. //this.PD.innerHTML = '<p>'+this.language['noLoadShockwaveFlash']+'</p><p><a href="https://www.flash.cn/" target="_blank" style="color:#FFFFFF">'+this.language['downLoadShockwaveFlash']+'</a></p>';
  6190. //this.css(this.PD,{color:'#FFFFFF',textAlign:'center',paddingTop:'40px'});
  6191. //}
  6192. },
  6193. /*
  6194. 判断浏览器是否支持flashplayer
  6195. */
  6196. checkShockwaveFlash:function(){
  6197. if(window.ActiveXObject) {
  6198. try {
  6199. var s = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
  6200. if(s) {
  6201. return true;
  6202. }
  6203. } catch(e) {}
  6204. } else {
  6205. try {
  6206. var s = navigator.plugins['Shockwave Flash'];
  6207. if(s) {
  6208. return true;
  6209. }
  6210. } catch(e) {}
  6211. }
  6212. return false;
  6213. },
  6214. /*
  6215. 内置函数
  6216. 将vars对象转换成字符
  6217. */
  6218. getFlashVars: function() {
  6219. this.getVarsObject();
  6220. var v = this.vars;
  6221. var z = '';
  6222. for (k in v) {
  6223. if (k != 'flashplayer' && k != 'container' && v[k] != '') {
  6224. if (z != '') {
  6225. z += '&';
  6226. }
  6227. var vk = v[k];
  6228. if (vk == true) {
  6229. vk = 1;
  6230. }
  6231. if (vk == false) {
  6232. vk = 0;
  6233. }
  6234. z += k + '=' + vk;
  6235. }
  6236. }
  6237. if (!v.hasOwnProperty('volume') || !v['volume']) {
  6238. if (z != '') {
  6239. z += '&';
  6240. }
  6241. z += 'volume=0';
  6242. }
  6243. return z;
  6244. },
  6245. /*判断字符串是否是图片*/
  6246. isStrImage: function(s) {
  6247. if (s == 'jpg' || s == 'jpeg' || s == 'png' || s == 'svg' || s == 'gif') {
  6248. return true;
  6249. }
  6250. return false;
  6251. },
  6252. /*
  6253. 内置函数
  6254. 将vars格式化成flash能接受的对象。再由getFlashVars函数转化成字符串或由newVideo直接使用
  6255. */
  6256. getVarsObject: function() {
  6257. var v = this.vars;
  6258. var f = '',
  6259. d = '',
  6260. w = ''; //f=视频地址,d=清晰度地址,w=权重,z=最终地址
  6261. var arr = this.VA;
  6262. var prompt = v['promptSpot'];
  6263. var i = 0;
  6264. var video = this.vars['video'];
  6265. if (typeof(video) == 'object') { //对象或数组
  6266. if (!this.isUndefined(typeof(video.length))) { //说明是数组
  6267. var arr = video;
  6268. for (i = 0; i < arr.length; i++) {
  6269. var arr2 = arr[i];
  6270. if (arr2) {
  6271. if (f != '') {
  6272. f += this.ckplayerConfig['config']['split'];
  6273. d += ',';
  6274. w += ',';
  6275. v['type'] += this.ckplayerConfig['config']['split'];
  6276. }
  6277. f += encodeURIComponent(decodeURIComponent(arr2[0]));
  6278. d += arr2[2];
  6279. w += arr2[3];
  6280. v['type'] += arr2[1].replace('video/', '');
  6281. }
  6282. }
  6283. } else {
  6284. f = encodeURIComponent(decodeURIComponent(video['file']));
  6285. if (!this.isUndefined(video['type'])) {
  6286. v['type'] = video['type'];
  6287. }
  6288. d = '';
  6289. w = '';
  6290. }
  6291. } else {
  6292. f = encodeURIComponent(decodeURIComponent(video));
  6293. }
  6294. if (v['preview'] != null) {
  6295. v['previewscale'] = v['preview']['scale'];
  6296. v['preview'] = v['preview']['file'].join(',');
  6297. }
  6298. if (prompt != null) {
  6299. v['promptspot'] = '';
  6300. v['promptspottime'] = '';
  6301. for (i = 0; i < prompt.length; i++) {
  6302. if (v['promptspot'] != '') {
  6303. v['promptspot'] += ',';
  6304. v['promptspottime'] += ',';
  6305. }
  6306. v['promptspot'] += prompt[i]['words'];
  6307. v['promptspottime'] += prompt[i]['time'];
  6308. }
  6309. }
  6310. if (f != '') {
  6311. v['video'] = f;
  6312. v['definition'] = d;
  6313. v['weight'] = w;
  6314. }
  6315. if (!v['volume']) {
  6316. v['volume'] = 0;
  6317. }
  6318. var newV = {};
  6319. for (var k in v) {
  6320. if (v[k] != null) {
  6321. newV[k] = v[k];
  6322. }
  6323. if (k == 'type') {
  6324. newV[k] = v[k].replace('video/m3u8', 'm3u8');
  6325. }
  6326. }
  6327. this.vars = newV;
  6328. },
  6329. /*
  6330. 内置函数
  6331. 将embedSWF里的param的对象进行转换
  6332. */
  6333. getFlashplayerParam: function() {
  6334. var w = '',
  6335. v = '',
  6336. o = {
  6337. allowScriptAccess: 'always',
  6338. allowFullScreen: true,
  6339. quality: 'high',
  6340. bgcolor: '#000'
  6341. };
  6342. for (var e in o) {
  6343. w += e + '="' + o[e] + '" ';
  6344. v += '<param name="' + e + '" value="' + o[e] + '" />';
  6345. }
  6346. w = w.replace('movie=', 'src=');
  6347. return {
  6348. w: w,
  6349. v: v
  6350. };
  6351. },
  6352. /*
  6353. 操作动作结束
  6354. -----------------------------------------------------------------------
  6355. 接口函数
  6356. 获取元数据部分
  6357. */
  6358. getMetaDate: function() {
  6359. if (!this.loaded || this.V == null) {
  6360. return false;
  6361. }
  6362. if (this.playerType == 'html5video') {
  6363. var duration = 0;
  6364. try {
  6365. duration = !isNaN(this.V.duration) ? this.V.duration: 0;
  6366. if (isNaN(duration) || parseInt(duration) < 0.2) {
  6367. if(this.vars['duration']>0){
  6368. duration=this.vars['duration'];
  6369. }
  6370. }
  6371. if(this.vars['forceduration']>0){
  6372. duration=this.vars['forceduration'];
  6373. }
  6374. } catch(event) {
  6375. this.log(event);
  6376. }
  6377. var data = {
  6378. duration: duration,
  6379. volume: this.V.volume,
  6380. playbackRate: this.V.playbackRate,
  6381. width: this.PD.offsetWidth || this.V.offsetWidth || this.V.width,
  6382. height: this.PD.offsetHeight || this.V.offsetHeight || this.V.height,
  6383. streamWidth: this.V.videoWidth,
  6384. streamHeight: this.V.videoHeight,
  6385. videoWidth: this.V.offsetWidth,
  6386. videoHeight: this.V.offsetHeight,
  6387. paused: this.V.paused,
  6388. loadTime:this.loadTimeTemp
  6389. };
  6390. return data;
  6391. } else {
  6392. try {
  6393. return this.V.getMetaDate();
  6394. } catch(event) {
  6395. this.log(event);
  6396. }
  6397. }
  6398. return false;
  6399. },
  6400. /*
  6401. 接口函数
  6402. 取当前提供给播放器播放的视频列表
  6403. */
  6404. getVideoUrl: function() {
  6405. if (this.playerType == 'flashplayer') {
  6406. return this.V.getVideoUrl();
  6407. }
  6408. var arr = [];
  6409. if (this.V.src) {
  6410. arr.push(this.V.src);
  6411. } else {
  6412. var uArr = this.V.childNodes;
  6413. for (var i = 0; i < uArr.length; i++) {
  6414. arr.push(uArr[i].src);
  6415. }
  6416. }
  6417. return arr;
  6418. },
  6419. /*
  6420. 内置函数
  6421. 格式化函数
  6422. */
  6423. clickEvent: function(call) {
  6424. if (call == 'none' || call == '' || call == null) {
  6425. return {
  6426. type: 'none'
  6427. };
  6428. }
  6429. var callArr = call.split('->');
  6430. var type = '',
  6431. fun = '',
  6432. link = '',
  6433. target = '';
  6434. if (callArr.length == 2) {
  6435. var callM = callArr[0];
  6436. var callE = callArr[1];
  6437. if (!callE) {
  6438. return {
  6439. type: 'none'
  6440. };
  6441. }
  6442. var val = '';
  6443. var eArr = [];
  6444. type = callM;
  6445. switch (callM) {
  6446. case 'actionScript':
  6447. //trace(THIS.hasOwnProperty(callE));
  6448. if (callE.indexOf('(') > -1) {
  6449. eArr = callE.split('(');
  6450. callE = eArr[0];
  6451. val = eArr[1].replace(')', '');
  6452. }
  6453. if (val == '') {
  6454. fun = 'thisTemp.' + callE + '()';
  6455. } else {
  6456. fun = 'thisTemp.' + callE + '(' + val + ')';
  6457. }
  6458. break;
  6459. case 'javaScript':
  6460. if (callE.substr(0, 11) == '[flashvars]') {
  6461. callE = callE.substr(11);
  6462. if (this.vars.hasOwnProperty(callE)) {
  6463. callE = this.vars[callE];
  6464. } else {
  6465. break;
  6466. }
  6467. }
  6468. if (callE.indexOf('(') > -1) {
  6469. eArr = callE.split('(');
  6470. callE = eArr[0];
  6471. val = eArr[1].replace(')', '');
  6472. }
  6473. if (val == '') {
  6474. fun = callE + '()';
  6475. } else {
  6476. fun = callE + '(' + val + ')';
  6477. }
  6478. break;
  6479. case "link":
  6480. var callLink = (callE + ',').split(',');
  6481. if (callLink[0].substr(0, 11) == '[flashvars]') {
  6482. var fl = callLink[0].replace('[flashvars]', '');
  6483. if (this.vars.hasOwnProperty(fl)) {
  6484. callLink[0] = this.vars[fl];
  6485. } else {
  6486. break;
  6487. }
  6488. }
  6489. if (!callLink[1]) {
  6490. callLink[1] = '_blank';
  6491. }
  6492. link = callLink[0];
  6493. target = callLink[1];
  6494. break;
  6495. }
  6496. }
  6497. return {
  6498. type: type,
  6499. fun: fun,
  6500. link: link,
  6501. target: target
  6502. }
  6503. },
  6504. /*
  6505. 内置函数
  6506. 根据指定的align,valign,offsetX,offsetY计算坐标
  6507. */
  6508. getPosition: function(obj) {
  6509. /*
  6510. {
  6511. "align": "right",
  6512. "vAlign": "right",
  6513. "offsetX": -60,
  6514. "offsetY": -60
  6515. }
  6516. */
  6517. var pw = this.PD.offsetWidth,
  6518. ph = this.PD.offsetHeight;
  6519. var x = 0,
  6520. y = 0;
  6521. switch (obj['align']) {
  6522. case 'left':
  6523. x = obj['offsetX'];
  6524. break;
  6525. case 'center':
  6526. x = pw * 0.5 + obj['offsetX'];
  6527. break;
  6528. case 'right':
  6529. x = pw + obj['offsetX'];
  6530. break;
  6531. }
  6532. switch (obj['vAlign']) {
  6533. case 'top':
  6534. y = obj['offsetY'];
  6535. break;
  6536. case 'middle':
  6537. y = ph * 0.5 + obj['offsetY'];
  6538. break;
  6539. case 'bottom':
  6540. y = ph + obj['offsetY'];
  6541. break;
  6542. }
  6543. return {
  6544. x: x,
  6545. y: y
  6546. };
  6547. },
  6548. /*
  6549. 内置函数
  6550. 向播放器界面添加一个文本
  6551. */
  6552. addElement: function(attribute) {
  6553. var thisTemp = this;
  6554. if (this.playerType == 'flashplayer') {
  6555. return this.V.addElement(attribute);
  6556. }
  6557. var i = 0;
  6558. var obj = {
  6559. list: null,
  6560. x: '100%',
  6561. y: "50%",
  6562. position: null,
  6563. alpha: 1,
  6564. backgroundColor: '',
  6565. backAlpha: 1,
  6566. backRadius: 0,
  6567. clickEvent: ''
  6568. };
  6569. obj = this.standardization(obj, attribute);
  6570. var list = obj['list'];
  6571. if (list == null) {
  6572. return '';
  6573. }
  6574. var id = 'element' + this.randomString(10);
  6575. var ele = document.createElement('div');
  6576. ele.className = id;
  6577. if (obj['x']) {
  6578. ele.setAttribute('data-x', obj['x']);
  6579. }
  6580. if (obj['y']) {
  6581. ele.setAttribute('data-y', obj['y']);
  6582. }
  6583. if (obj['position'] != null) {
  6584. ele.setAttribute('data-position', obj['position'].join(','));
  6585. }
  6586. this.PD.appendChild(ele);
  6587. var eid = this.getByElement(id);
  6588. this.css(eid, {
  6589. position: 'absolute',
  6590. filter: 'alpha(opacity:' + obj['alpha'] + ')',
  6591. opacity: obj['alpha'].toString(),
  6592. width: '800px',
  6593. zIndex: '20'
  6594. });
  6595. var bgid = 'elementbg' + this.randomString(10);
  6596. var bgAlpha = obj['alpha'].toString();
  6597. var bgColor = obj['backgroundColor'].replace('0x', '#');
  6598. var html = '';
  6599. var idArr = [];
  6600. var clickArr = [];
  6601. if (!this.isUndefined(list) && list.length > 0) {
  6602. var textObj, returnObj, clickEvent;
  6603. for (i = 0; i < list.length; i++) {
  6604. var newEleid = 'elementnew' + this.randomString(10);
  6605. switch (list[i]['type']) {
  6606. case 'image':
  6607. case 'png':
  6608. case 'jpg':
  6609. case 'jpeg':
  6610. case 'gif':
  6611. textObj = {
  6612. type: 'image',
  6613. file: '',
  6614. radius: 0,
  6615. //圆角弧度
  6616. width: 30,
  6617. //定义宽,必需要定义
  6618. height: 30,
  6619. //定义高,必需要定义
  6620. alpha: 1,
  6621. //透明度
  6622. paddingLeft: 0,
  6623. //左边距离
  6624. paddingRight: 0,
  6625. //右边距离
  6626. paddingTop: 0,
  6627. paddingBottom: 0,
  6628. marginLeft: 0,
  6629. marginRight: 0,
  6630. marginTop: 0,
  6631. marginBottom: 0,
  6632. backgroundColor: '',
  6633. clickEvent: ''
  6634. };
  6635. list[i] = this.standardization(textObj, list[i]);
  6636. clickEvent = this.clickEvent(list[i]['clickEvent']);
  6637. clickArr.push(clickEvent);
  6638. if (clickEvent['type'] == 'link') {
  6639. html += '<div class="' + newEleid + '" data-i="' + i + '"><a href="' + clickEvent['link'] + '" target="' + clickEvent['target'] + '"><img class="' + newEleid + '_image" src="' + list[i]['file'] + '" style="border:0;"></a></div>';
  6640. } else {
  6641. html += '<div class="' + newEleid + '" data-i="' + i + '"><img class="' + newEleid + '_image" src="' + list[i]['file'] + '" style="border:0;"></div>';
  6642. }
  6643. break;
  6644. case 'text':
  6645. textObj = {
  6646. type: 'text',
  6647. //说明是文本
  6648. text: '',
  6649. //文本内容
  6650. color: '0xFFFFFF',
  6651. size: 14,
  6652. font: this.fontFamily,
  6653. leading: 0,
  6654. alpha: 1,
  6655. //透明度
  6656. paddingLeft: 0,
  6657. //左边距离
  6658. paddingRight: 0,
  6659. //右边距离
  6660. paddingTop: 0,
  6661. paddingBottom: 0,
  6662. marginLeft: 0,
  6663. marginRight: 0,
  6664. marginTop: 0,
  6665. marginBottom: 0,
  6666. backgroundColor: '',
  6667. backAlpha: 1,
  6668. backRadius: 0,
  6669. //背景圆角弧度,支持数字统一设置,也支持分开设置[30,20,20,50],对应上左,上右,下右,下左
  6670. clickEvent: ''
  6671. };
  6672. list[i] = this.standardization(textObj, list[i]);
  6673. clickEvent = this.clickEvent(list[i]['clickEvent']);
  6674. clickArr.push(clickEvent);
  6675. if (clickEvent['type'] == 'link') {
  6676. html += '<div class="' + newEleid + '" data-i="' + i + '"><div class="' + newEleid + '_bg"></div><div class="' + newEleid + '_text"><a href="' + clickEvent['link'] + '" target="' + clickEvent['target'] + '">' + list[i]['text'] + '</a></div></div>';
  6677. } else {
  6678. html += '<div class="' + newEleid + '" data-i="' + i + '"><div class="' + newEleid + '_bg"></div><div class="' + newEleid + '_text">' + list[i]['text'] + '</div></div>';
  6679. }
  6680. break;
  6681. default:
  6682. break;
  6683. }
  6684. idArr.push(newEleid);
  6685. }
  6686. }
  6687. var objClickEvent = this.clickEvent(obj['clickEvent']);
  6688. /*if(objClickEvent['type']=='link'){
  6689. html = '<a href="'+objClickEvent['link']+'" target="'+objClickEvent['target']+'">' + html + '</a>';
  6690. }*/
  6691. eid.innerHTML = '<div class="' + bgid + '"></div><div class="' + bgid + '_c">' + html + '</div>';
  6692. if (objClickEvent['type'] == 'javaScript' || objClickEvent['type'] == 'actionScript') {
  6693. var objClickHandler = function() {
  6694. eval(objClickEvent['fun']);
  6695. thisTemp.sendJS('clickEvent', clk['type'] + '->' + clk['fun'].replace('thisTemp.', '').replace('()', ''));
  6696. };
  6697. this.addListenerInside('click', objClickHandler, this.getByElement(bgid + '_c'))
  6698. }
  6699. this.css(bgid + '_c', {
  6700. position: 'absolute',
  6701. zIndex: '2'
  6702. });
  6703. for (i = 0; i < idArr.length; i++) {
  6704. var clk = clickArr[i];
  6705. if (clk['type'] == 'javaScript' || clk['type'] == 'actionScript') {
  6706. var clickHandler = function() {
  6707. clk = clickArr[this.getAttribute('data-i')];
  6708. eval(clk['fun']);
  6709. thisTemp.sendJS('clickEvent', clk['type'] + '->' + clk['fun'].replace('thisTemp.', '').replace('()', ''));
  6710. };
  6711. this.addListenerInside('click', clickHandler, this.getByElement(idArr[i]))
  6712. }
  6713. switch (list[i]['type']) {
  6714. case 'image':
  6715. case 'png':
  6716. case 'jpg':
  6717. case 'jpeg':
  6718. case 'gif':
  6719. this.css(idArr[i], {
  6720. float: 'left',
  6721. width: list[i]['width'] + 'px',
  6722. height: list[i]['height'] + 'px',
  6723. filter: 'alpha(opacity:' + list[i]['alpha'] + ')',
  6724. opacity: list[i]['alpha'].toString(),
  6725. marginLeft: list[i]['marginLeft'] + 'px',
  6726. marginRight: list[i]['marginRight'] + 'px',
  6727. marginTop: list[i]['marginTop'] + 'px',
  6728. marginBottom: list[i]['marginBottom'] + 'px',
  6729. borderRadius: list[i]['radius'] + 'px',
  6730. cursor: 'pointer'
  6731. });
  6732. this.css(idArr[i] + '_image', {
  6733. width: list[i]['width'] + 'px',
  6734. height: list[i]['height'] + 'px',
  6735. borderRadius: list[i]['radius'] + 'px'
  6736. });
  6737. break;
  6738. case 'text':
  6739. this.css(idArr[i] + '_text', {
  6740. filter: 'alpha(opacity:' + list[i]['alpha'] + ')',
  6741. opacity: list[i]['alpha'].toString(),
  6742. borderRadius: list[i]['radius'] + 'px',
  6743. fontFamily: list[i]['font'],
  6744. fontSize: list[i]['size'] + 'px',
  6745. color: list[i]['color'].replace('0x', '#'),
  6746. lineHeight: list[i]['leading'] > 0 ? list[i]['leading'] + 'px': '',
  6747. paddingLeft: list[i]['paddingLeft'] + 'px',
  6748. paddingRight: list[i]['paddingRight'] + 'px',
  6749. paddingTop: list[i]['paddingTop'] + 'px',
  6750. paddingBottom: list[i]['paddingBottom'] + 'px',
  6751. whiteSpace: 'nowrap',
  6752. position: 'absolute',
  6753. zIndex: '3',
  6754. cursor: 'pointer'
  6755. });
  6756. this.css(idArr[i], {
  6757. float: 'left',
  6758. width: this.getByElement(idArr[i] + '_text').offsetWidth + 'px',
  6759. height: this.getByElement(idArr[i] + '_text').offsetHeight + 'px',
  6760. marginLeft: list[i]['marginLeft'] + 'px',
  6761. marginRight: list[i]['marginRight'] + 'px',
  6762. marginTop: list[i]['marginTop'] + 'px',
  6763. marginBottom: list[i]['marginBottom'] + 'px'
  6764. });
  6765. this.css(idArr[i] + '_bg', {
  6766. width: this.getByElement(idArr[i] + '_text').offsetWidth + 'px',
  6767. height: this.getByElement(idArr[i] + '_text').offsetHeight + 'px',
  6768. filter: 'alpha(opacity:' + list[i]['backAlpha'] + ')',
  6769. opacity: list[i]['backAlpha'].toString(),
  6770. borderRadius: list[i]['backRadius'] + 'px',
  6771. backgroundColor: list[i]['backgroundColor'].replace('0x', '#'),
  6772. position: 'absolute',
  6773. zIndex: '2'
  6774. });
  6775. break;
  6776. default:
  6777. break;
  6778. }
  6779. }
  6780. this.css(bgid, {
  6781. width: this.getByElement(bgid + '_c').offsetWidth + 'px',
  6782. height: this.getByElement(bgid + '_c').offsetHeight + 'px',
  6783. position: 'absolute',
  6784. filter: 'alpha(opacity:' + bgAlpha + ')',
  6785. opacity: bgAlpha,
  6786. backgroundColor: bgColor.replace('0x', '#'),
  6787. borderRadius: obj['backRadius'] + 'px',
  6788. zIndex: '1'
  6789. });
  6790. this.css(eid, {
  6791. width: this.getByElement(bgid).offsetWidth + 'px',
  6792. height: this.getByElement(bgid).offsetHeight + 'px'
  6793. });
  6794. var eidCoor = this.calculationCoor(eid);
  6795. this.css(eid, {
  6796. left: eidCoor['x'] + 'px',
  6797. top: eidCoor['y'] + 'px'
  6798. });
  6799. this.elementArr.push(eid.className);
  6800. return eid;
  6801. },
  6802. /*
  6803. 内置函数
  6804. 获取元件的属性,包括x,y,width,height,alpha
  6805. */
  6806. getElement: function(element) {
  6807. if (this.playerType == 'flashplayer') {
  6808. return this.V.getElement(element);
  6809. }
  6810. var ele = element;
  6811. if (typeof(element) == 'string') {
  6812. ele = this.getByElement(element);
  6813. }
  6814. var coor = this.getCoor(ele);
  6815. return {
  6816. x: coor['x'],
  6817. y: coor['y'],
  6818. width: ele.offsetWidth,
  6819. height: ele.offsetHeight,
  6820. alpha: !this.isUndefined(this.css(ele, 'opacity')) ? parseFloat(this.css(ele, 'opacity')) : 1,
  6821. show: this.css(ele, 'display') == 'none' ? false: true
  6822. };
  6823. },
  6824. /*
  6825. 内置函数
  6826. 控制元件显示和隐藏
  6827. */
  6828. elementShow: function(element, show) {
  6829. if (this.playerType == 'flashplayer') {
  6830. this.V.elementShow(element, show);
  6831. return;
  6832. }
  6833. if (typeof(element) == 'string') {
  6834. if (element) {
  6835. this.css(ele, 'display', show == true ? 'block': 'none');
  6836. } else {
  6837. var arr = this.elementTempArr;
  6838. for (var i = 0; i < arr.length; i++) {
  6839. this.css(arr[i], 'display', show == true ? 'block': 'none');
  6840. }
  6841. }
  6842. }
  6843. },
  6844. /*
  6845. 内置函数
  6846. 根据节点的x,y计算在播放器里的坐标
  6847. */
  6848. calculationCoor: function(ele) {
  6849. if (this.playerType == 'flashplayer') {
  6850. return this.V.calculationCoor(ele);
  6851. }
  6852. if (ele == []) {
  6853. return;
  6854. }
  6855. var x, y, position = [];
  6856. var w = this.PD.offsetWidth,
  6857. h = this.PD.offsetHeight;
  6858. var ew = ele.offsetWidth,
  6859. eh = ele.offsetHeight;
  6860. if (!this.isUndefined(this.getDataset(ele, 'x'))) {
  6861. x = this.getDataset(ele, 'x');
  6862. }
  6863. if (!this.isUndefined(this.getDataset(ele, 'y'))) {
  6864. y = this.getDataset(ele, 'y');
  6865. }
  6866. if (!this.isUndefined(this.getDataset(ele, 'position'))) {
  6867. try {
  6868. position = this.getDataset(ele, 'position').toString().split(',');
  6869. } catch(event) {}
  6870. }
  6871. if (position.length > 0) {
  6872. position.push(null, null, null, null);
  6873. var i = 0;
  6874. for (i = 0; i < position.length; i++) {
  6875. if (this.isUndefined(position[i]) || position[i] == null || position[i] == 'null' || position[i] == '') {
  6876. position[i] = null;
  6877. } else {
  6878. position[i] = parseFloat(position[i]);
  6879. }
  6880. }
  6881. if (position[2] == null) {
  6882. switch (position[0]) {
  6883. case 0:
  6884. x = 0;
  6885. break;
  6886. case 1:
  6887. x = parseInt((w - ew) * 0.5);
  6888. break;
  6889. default:
  6890. x = w - ew;
  6891. break;
  6892. }
  6893. } else {
  6894. switch (position[0]) {
  6895. case 0:
  6896. x = position[2];
  6897. break;
  6898. case 1:
  6899. x = parseInt(w * 0.5) + position[2];
  6900. break;
  6901. default:
  6902. x = w + position[2];
  6903. break;
  6904. }
  6905. }
  6906. if (position[3] == null) {
  6907. switch (position[1]) {
  6908. case 0:
  6909. y = 0;
  6910. break;
  6911. case 1:
  6912. y = parseInt((h - eh) * 0.5);
  6913. break;
  6914. default:
  6915. y = h - eh;
  6916. break;
  6917. }
  6918. } else {
  6919. switch (position[1]) {
  6920. case 0:
  6921. y = position[3];
  6922. break;
  6923. case 1:
  6924. y = parseInt(h * 0.5) + position[3];
  6925. break;
  6926. default:
  6927. y = h + position[3];
  6928. break;
  6929. }
  6930. }
  6931. } else {
  6932. if (x.substring(x.length - 1, x.length) == '%') {
  6933. x = Math.floor(parseInt(x.substring(0, x.length - 1)) * w * 0.01);
  6934. }
  6935. if (y.substring(y.length - 1, y.length) == '%') {
  6936. y = Math.floor(parseInt(y.substring(0, y.length - 1)) * h * 0.01);
  6937. }
  6938. }
  6939. return {
  6940. x: x,
  6941. y: y
  6942. }
  6943. },
  6944. /*
  6945. 内置函数
  6946. 修改新增元件的坐标
  6947. */
  6948. changeElementCoor: function() {
  6949. for (var i = 0; i < this.elementArr.length; i++) {
  6950. if (this.getByElement(this.elementArr[i]) != []) {
  6951. var c = this.calculationCoor(this.getByElement(this.elementArr[i]));
  6952. if (c['x'] && c['y']) {
  6953. this.css(this.elementArr[i], {
  6954. top: c['y'] + 'px',
  6955. left: c['x'] + 'px'
  6956. });
  6957. }
  6958. }
  6959. }
  6960. },
  6961. /*
  6962. 内置函数
  6963. 缓动效果集
  6964. */
  6965. tween: function() {
  6966. var Tween = {
  6967. None: { //均速运动
  6968. easeIn: function(t, b, c, d) {
  6969. return c * t / d + b;
  6970. },
  6971. easeOut: function(t, b, c, d) {
  6972. return c * t / d + b;
  6973. },
  6974. easeInOut: function(t, b, c, d) {
  6975. return c * t / d + b;
  6976. }
  6977. },
  6978. Quadratic: {
  6979. easeIn: function(t, b, c, d) {
  6980. return c * (t /= d) * t + b;
  6981. },
  6982. easeOut: function(t, b, c, d) {
  6983. return - c * (t /= d) * (t - 2) + b;
  6984. },
  6985. easeInOut: function(t, b, c, d) {
  6986. if ((t /= d / 2) < 1) return c / 2 * t * t + b;
  6987. return - c / 2 * ((--t) * (t - 2) - 1) + b;
  6988. }
  6989. },
  6990. Cubic: {
  6991. easeIn: function(t, b, c, d) {
  6992. return c * (t /= d) * t * t + b;
  6993. },
  6994. easeOut: function(t, b, c, d) {
  6995. return c * ((t = t / d - 1) * t * t + 1) + b;
  6996. },
  6997. easeInOut: function(t, b, c, d) {
  6998. if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
  6999. return c / 2 * ((t -= 2) * t * t + 2) + b;
  7000. }
  7001. },
  7002. Quartic: {
  7003. easeIn: function(t, b, c, d) {
  7004. return c * (t /= d) * t * t * t + b;
  7005. },
  7006. easeOut: function(t, b, c, d) {
  7007. return - c * ((t = t / d - 1) * t * t * t - 1) + b;
  7008. },
  7009. easeInOut: function(t, b, c, d) {
  7010. if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
  7011. return - c / 2 * ((t -= 2) * t * t * t - 2) + b;
  7012. }
  7013. },
  7014. Quintic: {
  7015. easeIn: function(t, b, c, d) {
  7016. return c * (t /= d) * t * t * t * t + b;
  7017. },
  7018. easeOut: function(t, b, c, d) {
  7019. return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
  7020. },
  7021. easeInOut: function(t, b, c, d) {
  7022. if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
  7023. return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
  7024. }
  7025. },
  7026. Sine: {
  7027. easeIn: function(t, b, c, d) {
  7028. return - c * Math.cos(t / d * (Math.PI / 2)) + c + b;
  7029. },
  7030. easeOut: function(t, b, c, d) {
  7031. return c * Math.sin(t / d * (Math.PI / 2)) + b;
  7032. },
  7033. easeInOut: function(t, b, c, d) {
  7034. return - c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
  7035. }
  7036. },
  7037. Exponential: {
  7038. easeIn: function(t, b, c, d) {
  7039. return (t == 0) ? b: c * Math.pow(2, 10 * (t / d - 1)) + b;
  7040. },
  7041. easeOut: function(t, b, c, d) {
  7042. return (t == d) ? b + c: c * ( - Math.pow(2, -10 * t / d) + 1) + b;
  7043. },
  7044. easeInOut: function(t, b, c, d) {
  7045. if (t == 0) return b;
  7046. if (t == d) return b + c;
  7047. if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
  7048. return c / 2 * ( - Math.pow(2, -10 * --t) + 2) + b;
  7049. }
  7050. },
  7051. Circular: {
  7052. easeIn: function(t, b, c, d) {
  7053. return - c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
  7054. },
  7055. easeOut: function(t, b, c, d) {
  7056. return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
  7057. },
  7058. easeInOut: function(t, b, c, d) {
  7059. if ((t /= d / 2) < 1) return - c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
  7060. return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
  7061. }
  7062. },
  7063. Elastic: {
  7064. easeIn: function(t, b, c, d, a, p) {
  7065. if (t == 0) return b;
  7066. if ((t /= d) == 1) return b + c;
  7067. if (!p) p = d * .3;
  7068. if (!a || a < Math.abs(c)) {
  7069. a = c;
  7070. var s = p / 4;
  7071. } else var s = p / (2 * Math.PI) * Math.asin(c / a);
  7072. return - (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
  7073. },
  7074. easeOut: function(t, b, c, d, a, p) {
  7075. if (t == 0) return b;
  7076. if ((t /= d) == 1) return b + c;
  7077. if (!p) p = d * .3;
  7078. if (!a || a < Math.abs(c)) {
  7079. a = c;
  7080. var s = p / 4;
  7081. } else var s = p / (2 * Math.PI) * Math.asin(c / a);
  7082. return (a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b);
  7083. },
  7084. easeInOut: function(t, b, c, d, a, p) {
  7085. if (t == 0) return b;
  7086. if ((t /= d / 2) == 2) return b + c;
  7087. if (!p) p = d * (.3 * 1.5);
  7088. if (!a || a < Math.abs(c)) {
  7089. a = c;
  7090. var s = p / 4;
  7091. } else var s = p / (2 * Math.PI) * Math.asin(c / a);
  7092. if (t < 1) return - .5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
  7093. return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
  7094. }
  7095. },
  7096. Back: {
  7097. easeIn: function(t, b, c, d, s) {
  7098. if (s == undefined) s = 1.70158;
  7099. return c * (t /= d) * t * ((s + 1) * t - s) + b;
  7100. },
  7101. easeOut: function(t, b, c, d, s) {
  7102. if (s == undefined) s = 1.70158;
  7103. return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
  7104. },
  7105. easeInOut: function(t, b, c, d, s) {
  7106. if (s == undefined) s = 1.70158;
  7107. if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
  7108. return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
  7109. }
  7110. },
  7111. Bounce: {
  7112. easeIn: function(t, b, c, d) {
  7113. return c - Tween.Bounce.easeOut(d - t, 0, c, d) + b;
  7114. },
  7115. easeOut: function(t, b, c, d) {
  7116. if ((t /= d) < (1 / 2.75)) {
  7117. return c * (7.5625 * t * t) + b;
  7118. } else if (t < (2 / 2.75)) {
  7119. return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
  7120. } else if (t < (2.5 / 2.75)) {
  7121. return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
  7122. } else {
  7123. return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
  7124. }
  7125. },
  7126. easeInOut: function(t, b, c, d) {
  7127. if (t < d / 2) return Tween.Bounce.easeIn(t * 2, 0, c, d) * .5 + b;
  7128. else return Tween.Bounce.easeOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
  7129. }
  7130. }
  7131. };
  7132. return Tween;
  7133. },
  7134. /*
  7135. 接口函数
  7136. 缓动效果
  7137. ele:Object=需要缓动的对象,
  7138. parameter:String=需要改变的属性:x,y,width,height,alpha,
  7139. effect:String=效果名称,
  7140. start:Int=起始值,
  7141. end:Int=结束值,
  7142. speed:Number=运动的总秒数,支持小数
  7143. */
  7144. animate: function(attribute) {
  7145. if (this.playerType == 'flashplayer') {
  7146. return this.V.animate(attribute);
  7147. }
  7148. var thisTemp = this;
  7149. var animateId = 'animate_' + this.randomString();
  7150. var obj = {
  7151. element: null,
  7152. parameter: 'x',
  7153. static: false,
  7154. effect: 'None.easeIn',
  7155. start: null,
  7156. end: null,
  7157. speed: 0,
  7158. overStop: false,
  7159. pauseStop: false,
  7160. //暂停播放时缓动是否暂停
  7161. callBack: null
  7162. };
  7163. obj = this.standardization(obj, attribute);
  7164. if (obj['element'] == null || obj['speed'] == 0) {
  7165. return false;
  7166. }
  7167. var w = this.PD.offsetWidth,
  7168. h = this.PD.offsetHeight;
  7169. var effArr = (obj['effect'] + '.').split('.');
  7170. var tweenFun = this.tween()[effArr[0]][effArr[1]];
  7171. var eleCoor = {
  7172. x: 0,
  7173. y: 0
  7174. };
  7175. if (this.isUndefined(tweenFun)) {
  7176. return false;
  7177. }
  7178. //先将该元件从元件数组里删除,让其不再跟随播放器的尺寸改变而改变位置
  7179. var def = this.arrIndexOf(this.elementArr, obj['element'].className);
  7180. if (def > -1) {
  7181. this.elementTempArr.push(obj['element'].className);
  7182. this.elementArr.splice(def, 1);
  7183. }
  7184. //var run = true;
  7185. var css = {};
  7186. //对传递的参数进行转化,x和y转化成left,top
  7187. var pm = this.getElement(obj['element']); //包含x,y,width,height,alpha属性
  7188. var t = 0; //当前时间
  7189. var b = 0; //初始值
  7190. var c = 0; //变化量
  7191. var d = obj['speed'] * 1000; //持续时间
  7192. var timerTween = null;
  7193. var tweenObj = null;
  7194. var start = obj['start'] == null ? '': obj['start'].toString();
  7195. var end = obj['end'] == null ? '': obj['end'].toString();
  7196. switch (obj['parameter']) {
  7197. case 'x':
  7198. if (obj['start'] == null) {
  7199. b = pm['x'];
  7200. } else {
  7201. if (start.substring(start.length - 1, start.length) == '%') {
  7202. b = parseInt(start) * w * 0.01;
  7203. } else {
  7204. b = parseInt(start);
  7205. }
  7206. }
  7207. if (obj['end'] == null) {
  7208. c = pm['x'] - b;
  7209. } else {
  7210. if (end.substring(end.length - 1, end.length) == '%') {
  7211. c = parseInt(end) * w * 0.01 - b;
  7212. } else if (end.substring(0, 1) == '-' || end.substring(0, 1) == '+') {
  7213. if (typeof(obj['end']) == 'number') {
  7214. c = parseInt(obj['end']) - b;
  7215. } else {
  7216. c = parseInt(end);
  7217. }
  7218. } else {
  7219. c = parseInt(end) - b;
  7220. }
  7221. }
  7222. break;
  7223. case 'y':
  7224. if (obj['start'] == null) {
  7225. b = pm['y'];
  7226. } else {
  7227. if (start.substring(start.length - 1, start.length) == '%') {
  7228. b = parseInt(start) * h * 0.01;
  7229. } else {
  7230. b = parseInt(start);
  7231. }
  7232. }
  7233. if (obj['end'] == null) {
  7234. c = pm['y'] - b;
  7235. } else {
  7236. if (end.substring(end.length - 1, end.length) == '%') {
  7237. c = parseInt(end) * h * 0.01 - b;
  7238. } else if (end.substring(0, 1) == '-' || end.substring(0, 1) == '+') {
  7239. if (typeof(obj['end']) == 'number') {
  7240. c = parseInt(obj['end']) - b;
  7241. } else {
  7242. c = parseInt(end);
  7243. }
  7244. } else {
  7245. c = parseInt(end) - b;
  7246. }
  7247. }
  7248. break;
  7249. case 'alpha':
  7250. if (obj['start'] == null) {
  7251. b = pm['alpha'] * 100;
  7252. } else {
  7253. if (start.substring(start.length - 1, start.length) == '%') {
  7254. b = parseInt(obj['start']);
  7255. } else {
  7256. b = parseInt(obj['start'] * 100);
  7257. }
  7258. }
  7259. if (obj['end'] == null) {
  7260. c = pm['alpha'] * 100 - b;
  7261. } else {
  7262. if (end.substring(end.length - 1, end.length) == '%') {
  7263. c = parseInt(end) - b;
  7264. } else if (end.substring(0, 1) == '-' || end.substring(0, 1) == '+') {
  7265. if (typeof(obj['end']) == 'number') {
  7266. c = parseInt(obj['end']) * 100 - b;
  7267. } else {
  7268. c = parseInt(obj['end']) * 100;
  7269. }
  7270. } else {
  7271. c = parseInt(obj['end']) * 100 - b;
  7272. }
  7273. }
  7274. break;
  7275. }
  7276. var callBack = function() {
  7277. var index = thisTemp.arrIndexOf(thisTemp.animateElementArray, animateId);
  7278. if (index > -1) {
  7279. thisTemp.animateArray.splice(index, 1);
  7280. thisTemp.animateElementArray.splice(index, 1);
  7281. }
  7282. index = thisTemp.arrIndexOf(thisTemp.animatePauseArray, animateId);
  7283. if (index > -1) {
  7284. thisTemp.animatePauseArray.splice(index, 1);
  7285. }
  7286. if (obj['callBack'] != null && obj['element'] && obj['callBack'] != 'callBack' && obj['callBack'] != 'tweenX' && obj['tweenY'] != 'callBack' && obj['callBack'] != 'tweenAlpha') {
  7287. var cb = eval(obj['callBack']);
  7288. cb(obj['element']);
  7289. obj['callBack'] = null;
  7290. }
  7291. };
  7292. var stopTween = function() {
  7293. if (timerTween != null) {
  7294. if (timerTween.runing) {
  7295. timerTween.stop();
  7296. }
  7297. timerTween = null;
  7298. }
  7299. };
  7300. var tweenX = function() {
  7301. if (t < d) {
  7302. t += 10;
  7303. css = {
  7304. left: Math.ceil(tweenFun(t, b, c, d)) + 'px'
  7305. };
  7306. if (obj['static']) {
  7307. eleCoor = thisTemp.calculationCoor(obj['element']);
  7308. css['top'] = eleCoor['y'] + 'px';
  7309. }
  7310. thisTemp.css(obj['element'], css);
  7311. } else {
  7312. stopTween();
  7313. try {
  7314. var defX = this.arrIndexOf(this.elementTempArr, obj['element'].className);
  7315. if (defX > -1) {
  7316. this.elementTempArr.splice(defX, 1);
  7317. }
  7318. } catch(event) {}
  7319. thisTemp.elementArr.push(obj['element'].className);
  7320. callBack();
  7321. }
  7322. };
  7323. var tweenY = function() {
  7324. if (t < d) {
  7325. t += 10;
  7326. css = {
  7327. top: Math.ceil(tweenFun(t, b, c, d)) + 'px'
  7328. };
  7329. if (obj['static']) {
  7330. eleCoor = thisTemp.calculationCoor(obj['element']);
  7331. css['left'] = eleCoor['x'] + 'px';
  7332. }
  7333. thisTemp.css(obj['element'], css);
  7334. } else {
  7335. stopTween();
  7336. try {
  7337. var defY = this.arrIndexOf(this.elementTempArr, obj['element'].className);
  7338. if (defY > -1) {
  7339. this.elementTempArr.splice(defY, 1);
  7340. }
  7341. } catch(event) {}
  7342. thisTemp.elementArr.push(obj['element'].className);
  7343. callBack();
  7344. }
  7345. };
  7346. var tweenAlpha = function() {
  7347. if (t < d) {
  7348. t += 10;
  7349. eleCoor = thisTemp.calculationCoor(obj['element']);
  7350. var ap = Math.ceil(tweenFun(t, b, c, d)) * 0.01;
  7351. css = {
  7352. filter: 'alpha(opacity:' + ap + ')',
  7353. opacity: ap.toString()
  7354. };
  7355. if (obj['static']) {
  7356. eleCoor = thisTemp.calculationCoor(obj['element']);
  7357. css['top'] = eleCoor['y'] + 'px';
  7358. css['left'] = eleCoor['x'] + 'px';
  7359. }
  7360. thisTemp.css(obj['element'], css);
  7361. } else {
  7362. stopTween();
  7363. try {
  7364. var defA = this.arrIndexOf(this.elementTempArr, obj['element'].className);
  7365. if (defA > -1) {
  7366. this.elementTempArr.splice(defA, 1);
  7367. }
  7368. } catch(event) {}
  7369. thisTemp.elementArr.push(obj['element'].className);
  7370. callBack();
  7371. }
  7372. };
  7373. switch (obj['parameter']) {
  7374. case 'x':
  7375. tweenObj = tweenX;
  7376. break;
  7377. case 'y':
  7378. tweenObj = tweenY;
  7379. break;
  7380. case 'alpha':
  7381. tweenObj = tweenAlpha;
  7382. break;
  7383. default:
  7384. break;
  7385. }
  7386. timerTween = new thisTemp.timer(10, tweenObj);
  7387. timerTween.callBackFunction = callBack;
  7388. if (obj['overStop']) {
  7389. var mouseOver = function() {
  7390. if (timerTween != null && timerTween.runing) {
  7391. timerTween.stop();
  7392. }
  7393. };
  7394. this.addListenerInside('mouseover', mouseOver, obj['element']);
  7395. var mouseOut = function() {
  7396. var start = true;
  7397. if (obj['pauseStop'] && thisTemp.getMetaDate()['paused']) {
  7398. start = false;
  7399. }
  7400. if (timerTween != null && !timerTween.runing && start) {
  7401. timerTween.start();
  7402. }
  7403. };
  7404. this.addListenerInside('mouseout', mouseOut, obj['element']);
  7405. }
  7406. this.animateArray.push(timerTween);
  7407. this.animateElementArray.push(animateId);
  7408. if (obj['pauseStop']) {
  7409. this.animatePauseArray.push(animateId);
  7410. }
  7411. return animateId;
  7412. },
  7413. /*
  7414. 接口函数函数
  7415. 继续运行animate
  7416. */
  7417. animateResume: function(id) {
  7418. if (this.playerType == 'flashplayer') {
  7419. this.V.animateResume(this.isUndefined(id) ? '': id);
  7420. return;
  7421. }
  7422. var arr = [];
  7423. if (id != '' && !this.isUndefined(id) && id != 'pause') {
  7424. arr.push(id);
  7425. } else {
  7426. if (id === 'pause') {
  7427. arr = this.animatePauseArray;
  7428. } else {
  7429. arr = this.animateElementArray;
  7430. }
  7431. }
  7432. for (var i = 0; i < arr.length; i++) {
  7433. var index = this.arrIndexOf(this.animateElementArray, arr[i]);
  7434. if (index > -1) {
  7435. this.animateArray[index].start();
  7436. }
  7437. }
  7438. },
  7439. /*
  7440. 接口函数
  7441. 暂停运行animate
  7442. */
  7443. animatePause: function(id) {
  7444. if (this.playerType == 'flashplayer') {
  7445. this.V.animatePause(this.isUndefined(id) ? '': id);
  7446. return;
  7447. }
  7448. var arr = [];
  7449. if (id != '' && !this.isUndefined(id) && id != 'pause') {
  7450. arr.push(id);
  7451. } else {
  7452. if (id === 'pause') {
  7453. arr = this.animatePauseArray;
  7454. } else {
  7455. arr = this.animateElementArray;
  7456. }
  7457. }
  7458. for (var i = 0; i < arr.length; i++) {
  7459. var index = this.arrIndexOf(this.animateElementArray, arr[i]);
  7460. if (index > -1) {
  7461. this.animateArray[index].stop();
  7462. }
  7463. }
  7464. },
  7465. /*
  7466. 内置函数
  7467. 根据ID删除数组里对应的内容
  7468. */
  7469. deleteAnimate: function(id) {
  7470. if (this.playerType == 'flashplayer' && this.V) {
  7471. try {
  7472. this.V.deleteAnimate(id);
  7473. } catch(event) {
  7474. this.log(event);
  7475. }
  7476. return;
  7477. }
  7478. var index = this.arrIndexOf(this.animateElementArray, id);
  7479. if (index > -1) {
  7480. this.animateArray[index].callBackFunction();
  7481. this.animateArray.splice(index, 1);
  7482. this.animateElementArray.splice(index, 1);
  7483. }
  7484. },
  7485. /*
  7486. 内置函数
  7487. 删除外部新建的元件
  7488. */
  7489. deleteElement: function(ele) {
  7490. if (this.playerType == 'flashplayer' && this.V) {
  7491. try {
  7492. this.V.deleteElement(ele);
  7493. } catch(event) {}
  7494. return;
  7495. }
  7496. //先将该元件从元件数组里删除,让其不再跟随播放器的尺寸改变而改变位置
  7497. var def = this.arrIndexOf(this.elementArr, ele.className);
  7498. if (def > -1) {
  7499. this.elementArr.splice(def, 1);
  7500. }
  7501. try {
  7502. def = this.arrIndexOf(this.elementTempArr, ele.className);
  7503. if (def > -1) {
  7504. this.elementTempArr.splice(def, 1);
  7505. }
  7506. } catch(event) {}
  7507. this.deleteAnimate(ele);
  7508. this.deleteChild(ele);
  7509. },
  7510. /*
  7511. --------------------------------------------------------------
  7512. 共用函数部分
  7513. 以下函数并非只能在本程序中使用,也可以在页面其它项目中使用
  7514. 根据ID获取元素对象
  7515. */
  7516. getByElement: function(obj, parent) {
  7517. if (this.isUndefined(parent)) {
  7518. parent = document;
  7519. }
  7520. var num = obj.substr(0, 1);
  7521. var res = [];
  7522. if (num != '#') {
  7523. if (num == '.') {
  7524. obj = obj.substr(1, obj.length);
  7525. }
  7526. if (parent.getElementsByClassName) {
  7527. res = parent.getElementsByClassName(obj);
  7528. } else {
  7529. var reg = new RegExp(' ' + obj + ' ', 'i');
  7530. var ele = parent.getElementsByTagName('*');
  7531. for (var i = 0; i < ele.length; i++) {
  7532. if (reg.test(' ' + ele[i].className + ' ')) {
  7533. res.push(ele[i]);
  7534. }
  7535. }
  7536. }
  7537. if (res.length > 0) {
  7538. return res[0];
  7539. } else {
  7540. return res;
  7541. }
  7542. } else {
  7543. if (num == '#') {
  7544. obj = obj.substr(1, obj.length);
  7545. }
  7546. return document.getElementById(obj);
  7547. }
  7548. },
  7549. /*
  7550. 共用函数
  7551. 功能:修改样式或获取指定样式的值,
  7552. elem:ID对象或ID对应的字符,如果多个对象一起设置,则可以使用数组
  7553. attribute:样式名称或对象,如果是对象,则省略掉value值
  7554. value:attribute为样式名称时,定义的样式值
  7555. 示例一:
  7556. this.css(ID,'width','100px');
  7557. 示例二:
  7558. this.css('id','width','100px');
  7559. 示例三:
  7560. this.css([ID1,ID2,ID3],'width','100px');
  7561. 示例四:
  7562. this.css(ID,{
  7563. width:'100px',
  7564. height:'100px'
  7565. });
  7566. 示例五(获取宽度):
  7567. var width=this.css(ID,'width');
  7568. */
  7569. css: function(elem, attribute, value) {
  7570. var i = 0;
  7571. var k = '';
  7572. if (typeof(elem) == 'object') { //对象或数组
  7573. if (!this.isUndefined(typeof(elem.length))) { //说明是数组
  7574. for (i = 0; i < elem.length; i++) {
  7575. var el;
  7576. if (typeof(elem[i]) == 'string') {
  7577. el = this.getByElement(elem[i])
  7578. } else {
  7579. el = elem[i];
  7580. }
  7581. if (typeof(attribute) != 'object') {
  7582. if (!this.isUndefined(value)) {
  7583. el.style[attribute] = value;
  7584. }
  7585. } else {
  7586. for (k in attribute) {
  7587. if (!this.isUndefined(attribute[k])) {
  7588. try {
  7589. el.style[k] = attribute[k];
  7590. } catch(event) {
  7591. this.log(event);
  7592. }
  7593. }
  7594. }
  7595. }
  7596. }
  7597. return;
  7598. }
  7599. }
  7600. if (typeof(elem) == 'string') {
  7601. elem = this.getByElement(elem);
  7602. }
  7603. if (typeof(attribute) != 'object') {
  7604. if (!this.isUndefined(value)) {
  7605. elem.style[attribute] = value;
  7606. } else {
  7607. if (!this.isUndefined(this.getStyle(elem, attribute))) {
  7608. return this.getStyle(elem, attribute);
  7609. } else {
  7610. return false;
  7611. }
  7612. }
  7613. } else {
  7614. for (k in attribute) {
  7615. if (!this.isUndefined(attribute[k])) {
  7616. elem.style[k] = attribute[k];
  7617. }
  7618. }
  7619. }
  7620. },
  7621. /*
  7622. 内置函数
  7623. 兼容型获取style
  7624. */
  7625. getStyle: function(obj, attr) {
  7626. if (!this.isUndefined(obj.style[attr])) {
  7627. return obj.style[attr];
  7628. } else {
  7629. if (obj.currentStyle) {
  7630. return obj.currentStyle[attr];
  7631. } else {
  7632. return getComputedStyle(obj, false)[attr];
  7633. }
  7634. }
  7635. },
  7636. /*
  7637. 共用函数
  7638. 判断变量是否存在或值是否为undefined
  7639. */
  7640. isUndefined: function(value) {
  7641. try {
  7642. if (value == 'undefined' || value == undefined || value == null) {
  7643. return true;
  7644. }
  7645. } catch(event) {
  7646. this.log(event);
  7647. }
  7648. return false;
  7649. },
  7650. /*
  7651. 共用函数
  7652. 外部监听函数
  7653. */
  7654. addListener: function(name, funName) {
  7655. if (name && funName) {
  7656. if (this.playerType == 'flashplayer') {
  7657. var ff = ''; //定义用来向flashplayer传递的函数字符
  7658. if (typeof(funName) == 'function') {
  7659. ff = this.getParameterNames(funName);
  7660. }
  7661. this.V.addListener(name, ff);
  7662. return;
  7663. }
  7664. var have = false;
  7665. for (var i = 0; i < this.listenerJsArr.length; i++) {
  7666. var arr = this.listenerJsArr[i];
  7667. if (arr[0] == name && arr[1] == funName) {
  7668. have = true;
  7669. break;
  7670. }
  7671. }
  7672. if (!have) {
  7673. this.listenerJsArr.push([name, funName]);
  7674. }
  7675. }
  7676. },
  7677. /*
  7678. 共用函数
  7679. 外部删除监听函数
  7680. */
  7681. removeListener: function(name, funName) {
  7682. if (name && funName) {
  7683. if (this.playerType == 'flashplayer') {
  7684. var ff = ''; //定义用来向flashplayer传递的函数字符
  7685. if (typeof(funName) == 'function') {
  7686. ff = this.getParameterNames(funName);
  7687. }
  7688. this.V.removeListener(name, ff);
  7689. return;
  7690. }
  7691. for (var i = 0; i < this.listenerJsArr.length; i++) {
  7692. var arr = this.listenerJsArr[i];
  7693. if (arr[0] == name && arr[1] == funName) {
  7694. this.listenerJsArr.splice(i, 1);
  7695. break;
  7696. }
  7697. }
  7698. }
  7699. },
  7700. /*
  7701. 内部监听函数,调用方式:
  7702. this.addListenerInside('click',function(event){},[ID]);
  7703. d值为空时,则表示监听当前的视频播放器
  7704. */
  7705. addListenerInside: function(e, f, d, t) {
  7706. if (this.isUndefined(t)) {
  7707. t = false;
  7708. }
  7709. var o = this.V;
  7710. if (!this.isUndefined(d)) {
  7711. o = d;
  7712. }
  7713. if (o.addEventListener) {
  7714. try {
  7715. o.addEventListener(e, f, t);
  7716. } catch(event) {}
  7717. } else if (o.attachEvent) {
  7718. try {
  7719. o.attachEvent('on' + e, f);
  7720. } catch(event) {}
  7721. } else {
  7722. o['on' + e] = f;
  7723. }
  7724. },
  7725. /*
  7726. 删除内部监听函数,调用方式:
  7727. this.removeListenerInside('click',function(event){}[,ID]);
  7728. d值为空时,则表示监听当前的视频播放器
  7729. */
  7730. removeListenerInside: function(e, f, d, t) {
  7731. /*if(this.playerType=='flashplayer' && this.getParameterNames(f) && this.isUndefined(d)) {
  7732. return;
  7733. }*/
  7734. if (this.isUndefined(t)) {
  7735. t = false;
  7736. }
  7737. var o = this.V;
  7738. if (!this.isUndefined(d)) {
  7739. o = d;
  7740. }
  7741. if (o.removeEventListener) {
  7742. try {
  7743. this.addNum--;
  7744. o.removeEventListener(e, f, t);
  7745. } catch(e) {}
  7746. } else if (o.detachEvent) {
  7747. try {
  7748. o.detachEvent('on' + e, f);
  7749. } catch(e) {}
  7750. } else {
  7751. o['on' + e] = null;
  7752. }
  7753. },
  7754. /*
  7755. 共用函数
  7756. 统一分配监听,以达到跟as3同样效果
  7757. */
  7758. sendJS: function(name, val) {
  7759. if (this.adPlayerPlay && name.substr( - 2) != 'Ad') {
  7760. return;
  7761. }
  7762. var list = this.listenerJsArr;
  7763. var obj = {
  7764. variable: this.vars['variable']
  7765. };
  7766. if (this.vars['playerID']) {
  7767. obj['playerID'] = this.vars['playerID'];
  7768. }
  7769. if(this.vars['debug']){
  7770. this.log(name+':'+val);
  7771. }
  7772. for (var i = 0; i < list.length; i++) {
  7773. var arr = list[i];
  7774. if (arr[0] == name) {
  7775. if (val) {
  7776. switch (arr[1].length) {
  7777. case 1:
  7778. arr[1](val);
  7779. break;
  7780. case 2:
  7781. arr[1](val, obj);
  7782. break;
  7783. default:
  7784. arr[1]();
  7785. break;
  7786. }
  7787. } else {
  7788. switch (arr[1].length) {
  7789. case 1:
  7790. if (typeof(val) == 'boolean') {
  7791. arr[1](false);
  7792. } else {
  7793. arr[1](obj);
  7794. }
  7795. break;
  7796. default:
  7797. arr[1]();
  7798. break;
  7799. }
  7800. }
  7801. }
  7802. }
  7803. },
  7804. /*
  7805. 共用函数
  7806. 获取函数名称,如 function ckplayer(){} var fun=ckplayer,则getParameterNames(fun)=ckplayer
  7807. */
  7808. getParameterNames: function(fn) {
  7809. if (typeof(fn) !== 'function') {
  7810. return false;
  7811. }
  7812. var COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
  7813. var code = fn.toString().replace(COMMENTS, '');
  7814. var result = code.slice(code.indexOf(' ') + 1, code.indexOf('('));
  7815. return result === null ? false: result;
  7816. },
  7817. /*
  7818. 共用函数
  7819. 获取当前本地时间
  7820. */
  7821. getNowDate: function() {
  7822. var nowDate = new Date();
  7823. var month = nowDate.getMonth() + 1;
  7824. var date = nowDate.getDate();
  7825. var hours = nowDate.getHours();
  7826. var minutes = nowDate.getMinutes();
  7827. var seconds = nowDate.getSeconds();
  7828. var tMonth = '',
  7829. tDate = '',
  7830. tHours = '',
  7831. tMinutes = '',
  7832. tSeconds = '',
  7833. tSeconds = (seconds < 10) ? '0' + seconds: seconds + '',
  7834. tMinutes = (minutes < 10) ? '0' + minutes: minutes + '',
  7835. tHours = (hours < 10) ? '0' + hours: hours + '',
  7836. tDate = (date < 10) ? '0' + date: date + '',
  7837. tMonth = (month < 10) ? '0' + month: month + '';
  7838. return tMonth + '/' + tDate + ' ' + tHours + ':' + tMinutes + ':' + tSeconds;
  7839. },
  7840. /*
  7841. 共用函数
  7842. 格式化时分秒
  7843. seconds:Int:秒数
  7844. ishours:Boolean:是否显示小时,如果设置成false,则会显示如80:20,表示1小时20分钟20秒
  7845. */
  7846. formatTime: function(seconds, ishours) {
  7847. var tSeconds = '',
  7848. tMinutes = '',
  7849. tHours = '';
  7850. if (isNaN(seconds)) {
  7851. seconds = 0;
  7852. }
  7853. var s = Math.floor(seconds % 60),
  7854. m = 0,
  7855. h = 0;
  7856. if (ishours) {
  7857. m = Math.floor(seconds / 60) % 60;
  7858. h = Math.floor(seconds / 3600);
  7859. } else {
  7860. m = Math.floor(seconds / 60);
  7861. }
  7862. tSeconds = (s < 10) ? '0' + s: s + '';
  7863. tMinutes = (m > 0) ? ((m < 10) ? '0' + m + ':': m + ':') : '00:';
  7864. tHours = (h > 0) ? ((h < 10) ? '0' + h + ':': h + ':') : '';
  7865. if (ishours) {
  7866. return tHours + tMinutes + tSeconds;
  7867. } else {
  7868. return tMinutes + tSeconds;
  7869. }
  7870. },
  7871. /*
  7872. 共用函数
  7873. 获取一个随机字符
  7874. len:随机字符长度
  7875. */
  7876. randomString: function(len) {
  7877. len = len || 16;
  7878. var chars = 'abcdefghijklmnopqrstuvwxyz';
  7879. var maxPos = chars.length;
  7880. var val = '';
  7881. for (i = 0; i < len; i++) {
  7882. val += chars.charAt(Math.floor(Math.random() * maxPos));
  7883. }
  7884. return 'ch' + val;
  7885. },
  7886. /*
  7887. 共用函数
  7888. 获取字符串长度,中文算两,英文数字算1
  7889. */
  7890. getStringLen: function(str) {
  7891. var len = 0;
  7892. for (var i = 0; i < str.length; i++) {
  7893. if (str.charCodeAt(i) > 127 || str.charCodeAt(i) == 94) {
  7894. len += 2;
  7895. } else {
  7896. len++;
  7897. }
  7898. }
  7899. return len;
  7900. },
  7901. /*
  7902. 内部函数
  7903. 用来为ajax提供支持
  7904. */
  7905. createXHR: function() {
  7906. if (window.XMLHttpRequest) {
  7907. //IE7+、Firefox、Opera、Chrome 和Safari
  7908. return new XMLHttpRequest();
  7909. } else if (window.ActiveXObject) {
  7910. //IE6 及以下
  7911. try {
  7912. return new ActiveXObject('Microsoft.XMLHTTP');
  7913. } catch(event) {
  7914. try {
  7915. return new ActiveXObject('Msxml2.XMLHTTP');
  7916. } catch(event) {
  7917. this.eject(this.errorList[7]);
  7918. }
  7919. }
  7920. } else {
  7921. this.eject(this.errorList[8]);
  7922. }
  7923. },
  7924. /*
  7925. 共用函数
  7926. ajax调用
  7927. */
  7928. ajax: function(cObj) {
  7929. var thisTemp = this;
  7930. var callback = null;
  7931. var obj = {
  7932. method: 'get',
  7933. //请求类型
  7934. dataType: 'json',
  7935. //请求的数据类型
  7936. charset: 'utf-8',
  7937. async: false,
  7938. //true表示异步,false表示同步
  7939. url: '',
  7940. data: null,
  7941. success: null
  7942. };
  7943. if (typeof(cObj) != 'object') {
  7944. this.eject(this.errorList[9]);
  7945. return;
  7946. }
  7947. obj = this.standardization(obj, cObj);
  7948. if (obj.dataType === 'json' || obj.dataType === 'text' || obj.dataType === 'html') {
  7949. var xhr = this.createXHR();
  7950. callback = function() {
  7951. //判断http的交互是否成功
  7952. if (xhr.status == 200) {
  7953. if (thisTemp.isUndefined(obj.success)) {
  7954. return;
  7955. }
  7956. if (obj.dataType === 'json') {
  7957. try {
  7958. obj.success(eval('(' + xhr.responseText + ')')); //回调传递参数
  7959. } catch(event) {
  7960. obj.success(null);
  7961. }
  7962. } else {
  7963. obj.success(xhr.responseText); //回调传递参数
  7964. }
  7965. } else {
  7966. obj.success(null);
  7967. thisTemp.eject(thisTemp.errorList[10], 'Ajax.status:' + xhr.status);
  7968. }
  7969. };
  7970. obj.url = obj.url.indexOf('?') == -1 ? obj.url + '?rand=' + this.randomString(6) : obj.url;
  7971. obj.data = this.formatParams(obj.data); //通过params()将名值对转换成字符串
  7972. if (obj.method === 'get' && !this.isUndefined(obj.data)) {
  7973. if (obj.data != '') {
  7974. if (obj.url.indexOf('?') == -1) {
  7975. obj.url += '?' + obj.data
  7976. } else {
  7977. obj.url += '&' + obj.data;
  7978. }
  7979. }
  7980. }
  7981. if (obj.async === true) { //true表示异步,false表示同步
  7982. xhr.onreadystatechange = function() {
  7983. if (xhr.readyState == 4 && callback != null) { //判断对象的状态是否交互完成
  7984. callback(); //回调
  7985. }
  7986. };
  7987. }
  7988. xhr.open(obj.method, obj.url, obj.async);
  7989. if (obj.method === 'post') {
  7990. try{
  7991. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  7992. xhr.setRequestHeader('charset', obj['charset']);
  7993. xhr.send(obj.data);
  7994. }
  7995. catch(event){callback();}
  7996. } else {
  7997. try{
  7998. xhr.send(null); //get方式则填null
  7999. }
  8000. catch(event){callback(); }
  8001. }
  8002. if (obj.async === false) { //同步
  8003. callback();
  8004. }
  8005. } else if (obj.dataType === 'jsonp') {
  8006. var oHead = document.getElementsByTagName('head')[0];
  8007. var oScript = document.createElement('script');
  8008. var callbackName = 'callback' + new Date().getTime();
  8009. var params = this.formatParams(obj.data) + '&callback=' + callbackName; //按时间戳拼接字符串
  8010. callback = obj.success;
  8011. //拼接好src
  8012. oScript.src = obj.url.split('?') + '?' + params;
  8013. //插入script标签
  8014. oHead.insertBefore(oScript, oHead.firstChild);
  8015. //jsonp的回调函数
  8016. window[callbackName] = function(json) {
  8017. callback(json);
  8018. oHead.removeChild(oScript);
  8019. };
  8020. }
  8021. },
  8022. /*
  8023. 内置函数
  8024. 动态加载js
  8025. */
  8026. loadJs: function(path, success) {
  8027. var oHead = document.getElementsByTagName('HEAD').item(0);
  8028. var oScript = document.createElement('script');
  8029. oScript.type = 'text/javascript';
  8030. oScript.src = this.getNewUrl(path);
  8031. oHead.appendChild(oScript);
  8032. oScript.onload = function() {
  8033. success();
  8034. }
  8035. },
  8036. /*
  8037. 共用函数
  8038. 排除IE6-9
  8039. */
  8040. isMsie: function() {
  8041. var browser = navigator.appName;
  8042. var b_version = navigator.appVersion;
  8043. var version = b_version.split(';');
  8044. var trim_Version = '';
  8045. if (version.length > 1) {
  8046. trim_Version = version[1].replace(/[ ]/g, '');
  8047. }
  8048. if (browser == 'Microsoft Internet Explorer' && (trim_Version == 'MSIE6.0' || trim_Version == 'MSIE7.0' || trim_Version == 'MSIE8.0' || trim_Version == 'MSIE9.0' || trim_Version == 'MSIE10.0')) {
  8049. return false;
  8050. }
  8051. return true;
  8052. },
  8053. /*
  8054. 共用函数
  8055. 判断是否安装了flashplayer
  8056. */
  8057. uploadFlash: function() {
  8058. var swf;
  8059. if (navigator.userAgent.indexOf('MSIE') > 0) {
  8060. try {
  8061. var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
  8062. return true;
  8063. } catch(e) {
  8064. return false;
  8065. }
  8066. }
  8067. if (navigator.userAgent.indexOf('Firefox') > 0) {
  8068. swf = navigator.plugins['Shockwave Flash'];
  8069. if (swf) {
  8070. return true
  8071. } else {
  8072. return false;
  8073. }
  8074. }
  8075. return true;
  8076. },
  8077. /*
  8078. 共用函数
  8079. 检测浏览器是否支持HTML5-Video
  8080. */
  8081. supportVideo: function() {
  8082. if (!this.isMsie()) {
  8083. return false;
  8084. }
  8085. if ( !! document.createElement('video').canPlayType) {
  8086. var vidTest = document.createElement('video');
  8087. var oggTest;
  8088. try {
  8089. oggTest = vidTest.canPlayType('video/ogg; codecs="theora, vorbis"');
  8090. } catch(error) {
  8091. oggTest = false;
  8092. }
  8093. if (!oggTest) {
  8094. var h264Test;
  8095. try {
  8096. h264Test = vidTest.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');
  8097. } catch(error) {
  8098. h264Test = false;
  8099. }
  8100. if (!h264Test) {
  8101. return false;
  8102. } else {
  8103. if (h264Test == "probably") {
  8104. return true;
  8105. } else {
  8106. return false;
  8107. }
  8108. }
  8109. } else {
  8110. if (oggTest == "probably") {
  8111. return true;
  8112. } else {
  8113. return false;
  8114. }
  8115. }
  8116. } else {
  8117. return false;
  8118. }
  8119. },
  8120. /*
  8121. 共用函数
  8122. 获取属性值
  8123. */
  8124. getDataset: function(ele, z) {
  8125. try {
  8126. return ele.dataset[z];
  8127. } catch(error) {
  8128. try {
  8129. return ele.getAttribute('data-' + z)
  8130. } catch(error) {
  8131. return false;
  8132. }
  8133. }
  8134. },
  8135. /*
  8136. 共用函数
  8137. 返回flashplayer的对象
  8138. */
  8139. getObjectById: function(id) {
  8140. var x = null;
  8141. var y = this.getByElement('#' + id);
  8142. var r = 'embed';
  8143. if (y && y.nodeName == 'OBJECT') {
  8144. if (typeof(y.SetVariable) != 'undefined') {
  8145. x = y;
  8146. } else {
  8147. var z = y.getElementsByTagName(r)[0];
  8148. if (z) {
  8149. x = z;
  8150. }
  8151. }
  8152. }
  8153. return x;
  8154. },
  8155. /*
  8156. 共用函数
  8157. 对象转地址字符串
  8158. */
  8159. formatParams: function(data) {
  8160. var arr = [];
  8161. for (var i in data) {
  8162. arr.push(encodeURIComponent(i) + '=' + encodeURIComponent(data[i]));
  8163. }
  8164. return arr.join('&');
  8165. },
  8166. /*
  8167. 内置函数
  8168. 对地址进行冒泡排序
  8169. */
  8170. arrSort: function(arr) {
  8171. var temp = [];
  8172. for (var i = 0; i < arr.length; i++) {
  8173. for (var j = 0; j < arr.length - i; j++) {
  8174. if (!this.isUndefined(arr[j + 1]) && arr[j][3] < arr[j + 1][3]) {
  8175. temp = arr[j + 1];
  8176. arr[j + 1] = arr[j];
  8177. arr[j] = temp;
  8178. }
  8179. }
  8180. }
  8181. return arr;
  8182. },
  8183. /*
  8184. 内置函数
  8185. 判断文件后缀
  8186. */
  8187. getFileExt: function(filepath) {
  8188. if (filepath != '' && !this.isUndefined(filepath)) {
  8189. if (filepath.indexOf('?') > -1) {
  8190. filepath = filepath.split('?')[0];
  8191. }
  8192. var pos = '.' + filepath.replace(/.+\./, '');
  8193. return pos.toLowerCase();
  8194. }
  8195. return '';
  8196. },
  8197. /*
  8198. 内置函数
  8199. 判断是否是移动端
  8200. */
  8201. isMobile: function() {
  8202. if (navigator.userAgent.match(/(iPhone|iPad|iPod|Android|ios)/i)) {
  8203. return true;
  8204. }
  8205. return false;
  8206. },
  8207. /*
  8208. 内置函数
  8209. 搜索字符串str是否包含key
  8210. */
  8211. isContains: function(str, key) {
  8212. return str.indexOf(key) > -1;
  8213. },
  8214. /*
  8215. 内置函数
  8216. 给地址添加随机数
  8217. */
  8218. getNewUrl: function(url) {
  8219. if (this.isContains(url, '?')) {
  8220. return url += '&' + this.randomString(8) + '=' + this.randomString(8);
  8221. } else {
  8222. return url += '?' + this.randomString(8) + '=' + this.randomString(8);
  8223. }
  8224. },
  8225. /*
  8226. 共用函数
  8227. 获取clientX和clientY
  8228. */
  8229. client: function(event) {
  8230. var eve = event || window.event;
  8231. if (this.isUndefined(eve)) {
  8232. eve = {
  8233. clientX: 0,
  8234. clientY: 0
  8235. };
  8236. }
  8237. return {
  8238. x: eve.clientX + (document.documentElement.scrollLeft || this.body.scrollLeft) - this.pdCoor['x'],
  8239. y: eve.clientY + (document.documentElement.scrollTop || this.body.scrollTop) - this.pdCoor['y']
  8240. }
  8241. },
  8242. /*
  8243. 内置函数
  8244. 获取节点的绝对坐标
  8245. */
  8246. getCoor: function(obj) {
  8247. var coor = this.getXY(obj);
  8248. return {
  8249. x: coor['x'] - this.pdCoor['x'],
  8250. y: coor['y'] - this.pdCoor['y']
  8251. };
  8252. },
  8253. getXY: function(obj) {
  8254. var parObj = obj;
  8255. var left = obj.offsetLeft;
  8256. var top = obj.offsetTop;
  8257. while (parObj = parObj.offsetParent) {
  8258. left += parObj.offsetLeft;
  8259. top += parObj.offsetTop;
  8260. }
  8261. return {
  8262. x: left,
  8263. y: top
  8264. };
  8265. },
  8266. /*
  8267. 内置函数
  8268. 删除本对象的所有属性
  8269. */
  8270. removeChild: function() {
  8271. if (this.playerType == 'html5video') {
  8272. //删除计时器
  8273. var i = 0;
  8274. var timerArr = [this.timerError, this.timerFull, this.timerTime, this.timerBuffer, this.timerClick, this.timerLoading, this.timerCBar, this.timerVCanvas];
  8275. for (i = 0; i < timerArr.length; i++) {
  8276. if (timerArr[i] != null) {
  8277. if (timerArr[i].runing) {
  8278. timerArr[i].stop();
  8279. }
  8280. timerArr[i] = null;
  8281. }
  8282. }
  8283. //删除事件监听
  8284. var ltArr = this.listenerJsArr;
  8285. for (i = 0; i < ltArr.length; i++) {
  8286. this.removeListener(ltArr[i][0], ltArr[i][1]);
  8287. }
  8288. }
  8289. this.playerType == '';
  8290. this.V = null;
  8291. if (this.showFace) {
  8292. this.deleteChild(this.CB['menu']);
  8293. }
  8294. this.deleteChild(this.PD);
  8295. this.CD.innerHTML = '';
  8296. },
  8297. /*
  8298. 内置函数
  8299. 画封闭的图形
  8300. */
  8301. canvasFill: function(name, path) {
  8302. name.beginPath();
  8303. for (var i = 0; i < path.length; i++) {
  8304. var d = path[i];
  8305. if (i > 0) {
  8306. name.lineTo(d[0], d[1]);
  8307. } else {
  8308. name.moveTo(d[0], d[1]);
  8309. }
  8310. }
  8311. name.closePath();
  8312. name.fill();
  8313. },
  8314. /*
  8315. 内置函数
  8316. 画矩形
  8317. */
  8318. canvasFillRect: function(name, path) {
  8319. for (var i = 0; i < path.length; i++) {
  8320. var d = path[i];
  8321. name.fillRect(d[0], d[1], d[2], d[3]);
  8322. }
  8323. },
  8324. /*
  8325. 共用函数
  8326. 删除容器节点
  8327. */
  8328. deleteChild: function(f) {
  8329. var def = this.arrIndexOf(this.elementArr, f.className);
  8330. if (def > -1) {
  8331. this.elementArr.splice(def, 1);
  8332. }
  8333. var childs = f.childNodes;
  8334. for (var i = childs.length - 1; i >= 0; i--) {
  8335. f.removeChild(childs[i]);
  8336. }
  8337. if (f && f != null && f.parentNode) {
  8338. try {
  8339. if (f.parentNode) {
  8340. f.parentNode.removeChild(f);
  8341. }
  8342. } catch(event) {}
  8343. }
  8344. },
  8345. /*
  8346. 内置函数
  8347. 根据容器的宽高,内部节点的宽高计算出内部节点的宽高及坐标
  8348. */
  8349. getProportionCoor: function(stageW, stageH, vw, vh) {
  8350. var w = 0,
  8351. h = 0,
  8352. x = 0,
  8353. y = 0;
  8354. if (stageW / stageH < vw / vh) {
  8355. w = stageW;
  8356. h = w * vh / vw;
  8357. } else {
  8358. h = stageH;
  8359. w = h * vw / vh;
  8360. }
  8361. x = (stageW - w) * 0.5;
  8362. y = (stageH - h) * 0.5;
  8363. return {
  8364. width: parseInt(w),
  8365. height: parseInt(h),
  8366. x: parseInt(x),
  8367. y: parseInt(y)
  8368. };
  8369. },
  8370. /*
  8371. 共用函数
  8372. 将字幕文件内容转换成数组
  8373. */
  8374. parseSrtSubtitles: function(srt) {
  8375. var subtitlesArr = [];
  8376. var textSubtitles = [];
  8377. var i = 0;
  8378. var arrs = srt.split('\n');
  8379. var arr = [];
  8380. var delHtmlTag = function(str) {
  8381. return str.replace(/<[^>]+>/g, ''); //去掉所有的html标记
  8382. };
  8383. for (i = 0; i < arrs.length; i++) {
  8384. if (arrs[i].replace(/\s/g, '').length > 0) {
  8385. arr.push(arrs[i]);
  8386. } else {
  8387. if (arr.length > 0) {
  8388. textSubtitles.push(arr);
  8389. }
  8390. arr = [];
  8391. }
  8392. }
  8393. for (i = 0; i < textSubtitles.length; ++i) {
  8394. var textSubtitle = textSubtitles[i];
  8395. if (textSubtitle.length >= 2) {
  8396. var sn = textSubtitle[0]; // 字幕的序号
  8397. var startTime = this.toSeconds(this.trim(textSubtitle[1].split(' --> ')[0])); // 字幕的开始时间
  8398. var endTime = this.toSeconds(this.trim(textSubtitle[1].split(' --> ')[1])); // 字幕的结束时间
  8399. var content = [delHtmlTag(textSubtitle[2])]; // 字幕的内容
  8400. var cktrackdelay=this.vars['cktrackdelay'];
  8401. if(cktrackdelay!=0){
  8402. startTime+=cktrackdelay;
  8403. endTime+=cktrackdelay;
  8404. }
  8405. // 字幕可能有多行
  8406. if (textSubtitle.length > 2) {
  8407. for (var j = 3; j < textSubtitle.length; j++) {
  8408. content.push(delHtmlTag(textSubtitle[j]));
  8409. }
  8410. }
  8411. // 字幕对象
  8412. var subtitle = {
  8413. sn: sn,
  8414. startTime: startTime,
  8415. endTime: endTime,
  8416. content: content
  8417. };
  8418. subtitlesArr.push(subtitle);
  8419. }
  8420. }
  8421. return subtitlesArr;
  8422. },
  8423. /*
  8424. 共用函数
  8425. 计时器,该函数模拟as3中的timer原理
  8426. time:计时时间,单位:毫秒
  8427. fun:接受函数
  8428. number:运行次数,不设置则无限运行
  8429. */
  8430. timer: function(time, fun, number) {
  8431. var thisTemp = this;
  8432. this.time = 10; //运行间隔
  8433. this.fun = null; //监听函数
  8434. this.timeObj = null; //setInterval对象
  8435. this.number = 0; //已运行次数
  8436. this.numberTotal = null; //总至需要次数
  8437. this.runing = false; //当前状态
  8438. this.startFun = function() {
  8439. thisTemp.number++;
  8440. thisTemp.fun();
  8441. if (thisTemp.numberTotal != null && thisTemp.number >= thisTemp.numberTotal) {
  8442. thisTemp.stop();
  8443. }
  8444. };
  8445. this.start = function() {
  8446. if (!thisTemp.runing) {
  8447. thisTemp.runing = true;
  8448. thisTemp.timeObj = window.setInterval(thisTemp.startFun, time);
  8449. }
  8450. };
  8451. this.stop = function() {
  8452. if (thisTemp.runing) {
  8453. thisTemp.runing = false;
  8454. window.clearInterval(thisTemp.timeObj);
  8455. thisTemp.timeObj = null;
  8456. }
  8457. };
  8458. if (time) {
  8459. this.time = time;
  8460. }
  8461. if (fun) {
  8462. this.fun = fun;
  8463. }
  8464. if (number) {
  8465. this.numberTotal = number;
  8466. }
  8467. this.start();
  8468. },
  8469. /*
  8470. 共用函数
  8471. 将时分秒转换成秒
  8472. */
  8473. toSeconds: function(t) {
  8474. var s = 0.0;
  8475. if (t) {
  8476. var p = t.split(':');
  8477. for (i = 0; i < p.length; i++) {
  8478. s = s * 60 + parseFloat(p[i].replace(',', '.'));
  8479. }
  8480. }
  8481. return s;
  8482. },
  8483. /*将字符变成数字形式的数组*/
  8484. arrayInt: function(str) {
  8485. var a = str.split(',');
  8486. var b = [];
  8487. for (var i = 0; i < a.length; i++) {
  8488. if (this.isUndefined(a[i])) {
  8489. a[i] = 0;
  8490. }
  8491. if (a[i].substr( - 1) != '%') {
  8492. a[i] = parseInt(a[i]);
  8493. }
  8494. b.push(a[i]);
  8495. }
  8496. return b;
  8497. },
  8498. /*
  8499. 共用函数
  8500. 将对象Object标准化
  8501. */
  8502. standardization: function(o, n) { //n替换进o
  8503. var h = {};
  8504. var k;
  8505. for (k in o) {
  8506. h[k] = o[k];
  8507. }
  8508. for (k in n) {
  8509. var type = typeof(h[k]);
  8510. switch (type) {
  8511. case 'number':
  8512. h[k] = parseFloat(n[k]);
  8513. break;
  8514. default:
  8515. h[k] = n[k];
  8516. break;
  8517. }
  8518. }
  8519. return h;
  8520. },
  8521. /*
  8522. 共用函数
  8523. 搜索数组
  8524. */
  8525. arrIndexOf: function(arr, key) {
  8526. if(!arr || !key){
  8527. return false;
  8528. }
  8529. var re = new RegExp(key, ['']);
  8530. return (arr.toString().replace(re, '┢').replace(/[^,┢]/g, '')).indexOf('┢');
  8531. },
  8532. /*
  8533. 共用函数
  8534. 去掉空格
  8535. */
  8536. trim: function(str) {
  8537. if (str != '') {
  8538. return str.replace(/(^\s*)|(\s*$)/g, '');
  8539. }
  8540. return '';
  8541. },
  8542. /*
  8543. 共用函数
  8544. 判断对象类型
  8545. */
  8546. typeString:function typeString(object) {
  8547. return Object.prototype.toString.call(object).slice(8,-1).toLowerCase();
  8548. },
  8549. /*
  8550. 共用函数
  8551. 输出内容到控制台
  8552. */
  8553. log: function(val) {
  8554. try {
  8555. console.log(val);
  8556. } catch(e) {}
  8557. },
  8558. /*
  8559. 共用函数
  8560. 弹出提示
  8561. */
  8562. eject: function(er, val) {
  8563. if (!this.vars['debug']) {
  8564. return;
  8565. }
  8566. var errorVal = er[1];
  8567. if (!this.isUndefined(val)) {
  8568. errorVal = errorVal.replace('[error]', val);
  8569. }
  8570. var value = 'error ' + er[0] + ':' + errorVal;
  8571. try {
  8572. this.log(value);
  8573. } catch(e) {}
  8574. }
  8575. };
  8576. window.ckplayer = ckplayer;
  8577. })();