ckplayer.js 205 KB

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