ckplayer.js 254 KB

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