ckplayer.js 192 KB

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