ckplayer.js 260 KB

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