První Prius byl drahým experimentem. Toyotě se však vyplatil

03.11.2019
přidejte názor
  • Toyota Prius už je na trhu více než 20 let

  • První generace byla spíše experimentální, značka na výrobě prodělávala

  • V USA se z Priusu stal symbol „environmentální vzdělanosti“

  • Snad každá hollywoodská celebrita musela být vidět v Priusu

  • Ve skutečnosti je výroba Toyoty Prius ekologicky náročnější než u běžného vozu

Uvidíme je na silnici stále častěji a brzy budou v automobilovém světě naprosto běžné. Řeč je o hybridních systémech pohonu, které kombinují funkci tradičního spalovacího motoru s elektromotorem. Průkopníkem tohoto systému pohonu je Toyota Prius, která je s námi už více než dvacet let.

Postupem času se Toyota Prius prosadila jako atraktivní alternativa k dieselům a vybudovala si poněkud zvláštní image, která byla mnoha lidem tu pro smích, tu protivná. Z Priusu se totiž stal jakýsi symbol „hollywoodské politické korektnosti“, kdy se s ním rády naparovaly celebrity, aby ukázaly své environmentální cítění.

Toyota Prius (14) Toyota předpovídala, že v roce 2005 bude mít třetina všech nových prodaných aut hybridní pohon. Trochu to nevyšlo
Toyota Prius (17) Myšlenka hybridního pohonu Toyoty je rovoluční, ale ostatní výrobci ji kupodivu ve velkém nekopírují. Systém byl totiž drahý

Jak pokrytecké je slýchat potřebu bojovat s „globálním oteplováním“ od lidí, kteří mají několik luxusních residencí s vyhřívanými bazény a jednou cestou soukromým tryskáčem za zábavou vygenerují větší uhlíkovou stopu než průměrné město za celý rok... Ale byla by škoda Prius kvůli tomu zavrhnout. Je to totiž technicky velice zajímavé auto a ikonický status mu právem náleží.

Myšlenka spojit spalovací motor a elektromotor není nikterak nová. Podobné systémy se objevily už na konci 19. století, kdy byl ještě automobilismus v plenkách. Jenže až na konci 80. let 20. století se díky pokrokům ve výpočetní technice podařilo dosáhnout reálné použitelnosti podobných systémů. Bez výkonného počítače totiž hybrid pořádně fungovat nemůže.

Retro: „Nová řada“ zachránila BMW od bankrotu a dostala značku na vrchol
Přečtěte si také:

Retro: „Nová řada“ zachránila BMW od bankrotu a dostala značku na vrchol

Kouzlo Toyoty Prius je v tom, že spojuje dva systémy pohonu do jednoho poměrně kompaktního celku. Ačkoli se během čtyř generací systém HSD (Hybrid Synergy Drive) neustále vyvíjel, v principu funguje pořád stejně. Srdcem hybridního systému je planetová převodovka s plynule měnitelným převodem, která spojuje činnost spalovacího motoru s elektromotorem a posílá výsledek na kola.

Práce na alternativním systému pohonu zahájila Toyota v lednu 1992, kdy se začaly hledat cesty, jak dále zvýšit účinnost spalování a snížit náročnost výroby auta na přírodní zdroje. Oficiálně se práce rozjely 1. února 1994. Vývoj vedl Takehisa Yaegashi, kterému se přezdívá „pan Hybrid“ nebo také otec hybridů.

Toyota Prius Concept (2) První koncepty hybridního Priusu pracovaly s myšlenkou účinného pohonu a především nízkých jízdních odporů
Toyota Prius Concept (1) Největším úskalím bylo vyvinout spolehlivý akumulátor, který by snášel proměnné podmínky provozu osobního auta

První koncept se představil v roce 1995 na autosalonu v Tokiu. Už tehdy vůz dostal jméno Prius, což je z latinského „před“. Toyota chtěla ukázat, že vůz předpovídá budoucnost a předbíhá svou dobu. Dá se říci, že jméno opravdu sedí. Vždyť ani po dvaceti letech ještě není hybridní systém zcela rozšířený, i když s podobnými vozy logicky přišla i konkurence. Nejznámější alternativou je třeba Honda Insight.

Asi největší překážkou bylo, vedle samostného odladění funkce hybridního systému, vybrat vhodný akumulátor a zajistit jeho vysokou životnost. Vývoj zjistil, že není vhodné baterii neustále nabíjet na plnou kapacitu a zase vybíjet. Optimální bylo udržovat akumulátor Ni-MH v rozmezí 40 až 60% nabití, případně více. Energetické toky řídí palubní počítač, který má na starosti i planetovou převodovku. Zajímavé je, že zatímco bez spalovacího motoru by Prius teoreticky mohl jet, bez tohoto počítače by nefungoval.

Retro: Preston Tucker byl Elon Musk své doby. Z jeho auta se ale stal propadák
Přečtěte si také:

Retro: Preston Tucker byl Elon Musk své doby. Z jeho auta se ale stal propadák

Pro pohon první generace Toyoty Prius byl vybrán motor 1NZ-FXE, což je čtyřválec 1,5 l pracující v upraveném Atkinsonově cyklu. Oproti běžné patnáctistovce sice klesl špičkový výkon i točivý moment, ale výrazně se zvýšila tepelná účinnost. Už tehdy dosahovala Toyota tepelné účinnosti mimořádných 37 %.

Výkon motoru s kompresním poměrem 13,5:1 byl 43 kW (58 k) v 4000 min-1 a točivý moment měl hodnotu 102 Nm v 4000 min-1. Elektromotor poskytoval výkon 30 kW (40 k) v 940-2000 min-1 a točivý moment 305 Nm od první otáčky. Energie byla uskladněna v Ni-MH akumulátoru Panasonic o kapacitě 1,31 kWh. Celkový výkon soustavy nejde sečíst, neboť je potřeba složit výkonové křivky obou motorů. Elektromotor především slouží k asistenci spalovací jednotce a pomáhá zvyšovat účinnost v momentě, kdy spalovací motor nepracuje ve svém optimálním pásmu otáček, ve kterém má nejvyšší účinnost.

Toyota Prius (2) Prius měl vždycky poměrně radikální interiér s velkým ukazatelem energetických toků. I dnes designem Prius vyčnívá
Toyota Prius FL (9) Hybridní systém se postupně vyvíjí, ale základ je stejný: spalovací motor a elektromotor spojují své snažení v planetové převodovce

První Prius s označením NHW10 se prodával jen na domácím japonském trhu za cenu v přepočtu necelých 17 000 amerických dolarů. Podle odhadů analytiků však výrobní náklady činily až 32 000 dolarů, takže Toyota údajně na každém Priusu první generace prodělávala. Byla to zkrátka sázka na novou technologii a automobilka především testovala vůz v provozu u běžných spotřebitelů. Brzy se objevilo několik problémů, které bylo třeba řešit.

Předně se ukázalo, že v nízkých nebo extrémně vysokých teplotách baterie nepodává potřebný výkon. Celý systém byl také náchylný na nadmořskou výšku. Toyota pečlivě sbírala data a když byla výroba první verze Priusu v únoru 2000 po 37 425 vyrobených kusech ukončena, už věděla, co je potřeba modifikovat.

Elektrická auta jsou starší než ta benzinová. Zpočátku se dokonce prodávala lépe
Přečtěte si také:

Elektrická auta jsou starší než ta benzinová. Zpočátku se dokonce prodávala lépe

Pro modelový rok 2001 byl představen modernější typ s označením NHW11. Dostal upravený spalovací motor a především modifikovaný systém řízení celého hybridního systému. Vůz také zamířil poprvé na export a především do Spojených států, kde se z Priusu stal hit.

Motor sice snížil svůj kompresní poměr na 13,0:1, ale dostal proměnné časování ventilů. Jeho výkon vzrostl na 52 kW (70 k) v 4500 min-1 a točivý moment se zvýšil na 110 Nm v 4200 min-1. Elektromotor byl také upraven, jeho výkon narostl na 33 kW (44 k) v 1040 min-1 a točivý moment na 350 Nm. Modifikován byl rovněž akumulátor, který lépe snášel rozdílné teploty a nově nabídl kapacitu až 1,8 kWh. Toyota také konečně udávala dynamické parametry. Modernizovaný Prius akceleroval na 100 km/h za 13,4 s a nejvyšší rychlost byla omezena na 160 km/h.

Toyota Prius FL (17) První generace Toyoty Prius si našla 123 000 zákazníků a ke konci prodeje už přestala být výroba tolik ztrátová
Toyota Prius FL (15) Prius byl úspěšný i díky mnoha daňovým úlevám a jiným výhodám, například možnosti používat v některých městech vyhrazené jízdní pruhy

Toyota Prius první generace byl nakonec prodejní úspěch, částečně i díky americké daňové úlevě ve výši 2000 dolarů. Zásluhou rostoucích prodejů přestala být výroba Priusu ztrátová a modifikovaná verze NHW11 se už dokázala zaplatit, i když o nějakém miliardovém zisku se ještě mluvit nedalo. Celkem bylo vyrobeno 123 000 priusů první generace.

Kritici poukazují na to, že výroba Toyoty Prius, provoz a následná recyklace nepřináší pro životní prostředí žádný užitek. Dokonce je tomu prý naopak. Podle jedné studie je například jen výroba Priusu stejně ekologicky náročná jako výroba a osmiletý provoz Fordu F150 s benzinovým osmiválcem. Na druhou stranu se Toyotě povedlo aspoň vytvořit akumulátor, který měl výrazně delší životnost, než se původně předpokládalo. Ani po 10 letech provozu obvykle neklesla kapacita pod 90 %.

Toyotě se nedá upřít úspěch, kterého modelovou řadou Prius dosáhla. Když vynecháme podivné environmentalistické pozlátko a nebudeme se zabývat zkreslenými a mnohdy zavádějícími informacemi Toyoty o životním prostředí (pamatuji si moc dobře na jednu tiskovou prezentaci Toyoty, kde zaznělo, že oxid uhličitý je toxický plyn), ve skutečnosti je Prius technicky velice zajímavé auto. Dnes jsou hybridy samozřejmě mnohem dál a aktuální generace Priusu je rychlejší, úspornější a ve všech směrech lepší. Ale bez první generace by prostě taková nebyla. Bude tedy první Prius sběratelský exponát? Těžko říci, ale pravděpodobně zatím ne. Na rozdíl od neúspěšných průkopníků jich totiž byly vyrobeny desetitisíce.

  • Žádné názory
  • Našli jste v článku chybu?
'; document.getElementById('preroll-iframe').onload = function () { setupIframe(); } prerollContainer = document.getElementsByClassName('preroll-container-iframe')[0]; } function setupIframe() { prerollDocument = document.getElementById('preroll-iframe').contentWindow.document; let el = prerollDocument.createElement('style'); prerollDocument.head.appendChild(el); el.innerText = "#adContainer>div:nth-of-type(1),#adContainer>div:nth-of-type(1) > iframe { width: 99% !important;height: 99% !important;max-width: 100%;}#videoContent,body{ width:100vw;height:100vh}body{ font-family:'Helvetica Neue',Arial,sans-serif}#videoContent{ overflow:hidden;background:#000}#adMuteBtn{ width:35px;height:35px;border:0;background:0 0;display:none;position:absolute;fill:rgba(230,230,230,1);bottom:20px;right:25px}"; videoContent = prerollDocument.getElementById('contentElement'); videoContent.style.display = 'none'; videoContent.volume = 1; videoContent.muted = false; const playPromise = videoContent.play(); if (playPromise !== undefined) { playPromise.then(function () { console.log('PREROLL sound allowed'); // setUpIMA(true); videoContent.volume = 1; videoContent.muted = false; setUpIMA(); }).catch(function () { console.log('PREROLL sound forbidden'); videoContent.volume = 0; videoContent.muted = true; setUpIMA(); }); } } function setupDimensions() { prerollWidth = Math.min(iinfoPrerollPosition.offsetWidth, 480); prerollHeight = Math.min(iinfoPrerollPosition.offsetHeight, 320); } function setUpIMA() { google.ima.settings.setDisableCustomPlaybackForIOS10Plus(true); google.ima.settings.setLocale('cs'); google.ima.settings.setNumRedirects(10); // Create the ad display container. createAdDisplayContainer(); // Create ads loader. adsLoader = new google.ima.AdsLoader(adDisplayContainer); // Listen and respond to ads loaded and error events. adsLoader.addEventListener( google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, onAdsManagerLoaded, false); adsLoader.addEventListener( google.ima.AdErrorEvent.Type.AD_ERROR, onAdError, false); // An event listener to tell the SDK that our content video // is completed so the SDK can play any post-roll ads. const contentEndedListener = function () { adsLoader.contentComplete(); }; videoContent.onended = contentEndedListener; // Request video ads. const adsRequest = new google.ima.AdsRequest(); adsRequest.adTagUrl = iinfoVastUrls[iinfoVastUrlIndex]; console.log('Preroll advert: ' + iinfoVastUrls[iinfoVastUrlIndex]); videoContent.muted = false; videoContent.volume = 1; // Specify the linear and nonlinear slot sizes. This helps the SDK to // select the correct creative if multiple are returned. // adsRequest.linearAdSlotWidth = prerollWidth; // adsRequest.linearAdSlotHeight = prerollHeight; adsRequest.nonLinearAdSlotWidth = 0; adsRequest.nonLinearAdSlotHeight = 0; adsLoader.requestAds(adsRequest); } function createAdDisplayContainer() { // We assume the adContainer is the DOM id of the element that will house // the ads. prerollDocument.getElementById('videoContent').style.display = 'none'; adDisplayContainer = new google.ima.AdDisplayContainer( prerollDocument.getElementById('adContainer'), videoContent); } function unmutePrerollAdvert() { adVolume = !adVolume; if (adVolume) { adsManager.setVolume(0.3); prerollDocument.getElementById('adMuteBtn').innerHTML = ''; } else { adsManager.setVolume(0); prerollDocument.getElementById('adMuteBtn').innerHTML = ''; } } function onAdsManagerLoaded(adsManagerLoadedEvent) { // Get the ads manager. const adsRenderingSettings = new google.ima.AdsRenderingSettings(); adsRenderingSettings.restoreCustomPlaybackStateOnAdBreakComplete = true; adsRenderingSettings.loadVideoTimeout = 12000; // videoContent should be set to the content video element. adsManager = adsManagerLoadedEvent.getAdsManager(videoContent, adsRenderingSettings); // Add listeners to the required events. adsManager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, onAdError); adsManager.addEventListener( google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED, onContentPauseRequested); adsManager.addEventListener( google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED, onContentResumeRequested); adsManager.addEventListener( google.ima.AdEvent.Type.ALL_ADS_COMPLETED, onAdEvent); // Listen to any additional events, if necessary. adsManager.addEventListener(google.ima.AdEvent.Type.LOADED, onAdEvent); adsManager.addEventListener(google.ima.AdEvent.Type.STARTED, onAdEvent); adsManager.addEventListener(google.ima.AdEvent.Type.COMPLETE, onAdEvent); playAds(); } function playAds() { // Initialize the container. Must be done through a user action on mobile // devices. videoContent.load(); adDisplayContainer.initialize(); // setupDimensions(); try { // Initialize the ads manager. Ad rules playlist will start at this time. adsManager.init(1920, 1080, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will // start at this time; the call will be ignored for ad rules. adsManager.start(); // window.addEventListener('resize', function (event) { // if (adsManager) { // setupDimensions(); // adsManager.resize(prerollWidth, prerollHeight, google.ima.ViewMode.NORMAL); // } // }); } catch (adError) { // An error may be thrown if there was a problem with the VAST response. // videoContent.play(); } } function onAdEvent(adEvent) { const ad = adEvent.getAd(); console.log('Preroll event: ' + adEvent.type); switch (adEvent.type) { case google.ima.AdEvent.Type.LOADED: if (!ad.isLinear()) { videoContent.play(); } prerollDocument.getElementById('adContainer').style.width = '100%'; prerollDocument.getElementById('adContainer').style.maxWidth = '640px'; prerollDocument.getElementById('adContainer').style.height = '360px'; break; case google.ima.AdEvent.Type.STARTED: window.addEventListener('scroll', onActiveView); if (ad.isLinear()) { intervalTimer = setInterval( function () { // Example: const remainingTime = adsManager.getRemainingTime(); // adsManager.pause(); }, 300); // every 300ms } prerollDocument.getElementById('adMuteBtn').style.display = 'block'; break; case google.ima.AdEvent.Type.ALL_ADS_COMPLETED: if (ad.isLinear()) { clearInterval(intervalTimer); } if (prerollLastError === 303) { playYtVideo(); } break; case google.ima.AdEvent.Type.COMPLETE: if (ad.isLinear()) { clearInterval(intervalTimer); } playYtVideo(); break; } } function onAdError(adErrorEvent) { console.log(adErrorEvent.getError()); prerollLastError = adErrorEvent.getError().getErrorCode(); if (!loadNext()) { playYtVideo(); } } function loadNext() { iinfoVastUrlIndex++; if (iinfoVastUrlIndex < iinfoVastUrls.length) { iinfoPrerollPosition.remove(); playPrerollAd(); } else { return false; } adVolume = 1; return true; } function onContentPauseRequested() { videoContent.pause(); } function onContentResumeRequested() { videoContent.play(); } function onActiveView() { if (prerollContainer) { const containerOffset = prerollContainer.getBoundingClientRect(); const windowHeight = window.innerHeight; if (containerOffset.top < windowHeight/1 && containerOffset.bottom > 0.0) { if (prerollPaused) { adsManager.resume(); prerollPaused = false; } return true; } else { if (!prerollPaused) { adsManager.pause(); prerollPaused = true; } } } return false; } function playYtVideo() { iinfoPrerollPosition.remove(); youtubeIframe.style.display = 'block'; youtubeIframe.src += '&autoplay=1&mute=1'; } }
'; document.getElementById('outstream-iframe').onload = function () { setupIframe(); } replayScreen = document.getElementById('iinfoOutstreamReplay'); iinfoOutstreamPosition = document.getElementById('iinfoOutstreamPosition'); outstreamContainer = document.getElementsByClassName('outstream-container')[0]; setupReplayScreen(); } function setupIframe() { outstreamDocument = document.getElementById('outstream-iframe').contentWindow.document; let el = outstreamDocument.createElement('style'); outstreamDocument.head.appendChild(el); el.innerText = "#adContainer>div:nth-of-type(1),#adContainer>div:nth-of-type(1) > iframe { width: 99% !important;height: 99% !important;max-width: 100%;}#videoContent,body{ width:100vw;height:100vh}body{ font-family:'Helvetica Neue',Arial,sans-serif}#videoContent{ overflow:hidden;background:#000}#adMuteBtn{ width:35px;height:35px;border:0;background:0 0;display:none;position:absolute;fill:rgba(230,230,230,1);bottom:-5px;right:25px}"; videoContent = outstreamDocument.getElementById('contentElement'); videoContent.style.display = 'none'; videoContent.volume = 1; videoContent.muted = false; if ( location.href.indexOf('rejstriky.finance.cz') !== -1 || location.href.indexOf('finance-rejstrik') !== -1 || location.href.indexOf('firmy.euro.cz') !== -1 || location.href.indexOf('euro-rejstrik') !== -1 || location.href.indexOf('/rejstrik/') !== -1 || location.href.indexOf('/rejstrik-firem/') !== -1) { outstreamDirectPlayed = true; soundAllowed = true; iinfoVastUrlIndex = 0; } if (!outstreamDirectPlayed) { console.log('OUTSTREAM direct'); setUpIMA(true); } else { if (soundAllowed) { const playPromise = videoContent.play(); if (playPromise !== undefined) { playPromise.then(function () { console.log('OUTSTREAM sound allowed'); setUpIMA(false); }).catch(function () { console.log('OUTSTREAM sound forbidden'); renderBanner(); }); } } else { renderBanner(); } } } function getWrapper() { let articleWrapper = document.querySelector('.rs-outstream-placeholder'); // Outstream Placeholder from RedSys manipulation if (articleWrapper && articleWrapper.style.display !== 'block') { articleWrapper.innerHTML = ""; articleWrapper.style.display = 'block'; } // Don't render OutStream on homepages if (articleWrapper === null) { if (document.querySelector('body.p-index')) { return null; } } if (articleWrapper === null) { articleWrapper = document.getElementById('iinfo-outstream'); } if (articleWrapper === null) { articleWrapper = document.querySelector('.layout-main__content .detail__article p:nth-of-type(6)'); } if (articleWrapper === null) { // Euro, Autobible, Zdravi articleWrapper = document.querySelector('.o-article .o-article__text p:nth-of-type(6)'); } if (articleWrapper === null) { articleWrapper = document.getElementById('sidebar'); } if (!articleWrapper) { console.error("Outstream wrapper of article was not found."); } return articleWrapper; } function setupDimensions() { outstreamWidth = Math.min(iinfoOutstreamPosition.offsetWidth, 480); outstreamHeight = Math.min(iinfoOutstreamPosition.offsetHeight, 320); } /** * Sets up IMA ad display container, ads loader, and makes an ad request. */ function setUpIMA(direct) { google.ima.settings.setDisableCustomPlaybackForIOS10Plus(true); google.ima.settings.setLocale('cs'); google.ima.settings.setNumRedirects(10); // Create the ad display container. createAdDisplayContainer(); // Create ads loader. adsLoader = new google.ima.AdsLoader(adDisplayContainer); // Listen and respond to ads loaded and error events. adsLoader.addEventListener( google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, onAdsManagerLoaded, false); adsLoader.addEventListener( google.ima.AdErrorEvent.Type.AD_ERROR, onAdError, false); // An event listener to tell the SDK that our content video // is completed so the SDK can play any post-roll ads. const contentEndedListener = function () { adsLoader.contentComplete(); }; videoContent.onended = contentEndedListener; // Request video ads. const adsRequest = new google.ima.AdsRequest(); if (direct) { adsRequest.adTagUrl = directVast; console.log('Outstream DIRECT CAMPAING advert: ' + directVast); videoContent.muted = true; videoContent.volume = 0; outstreamDirectPlayed = true; } else { adsRequest.adTagUrl = iinfoVastUrls[iinfoVastUrlIndex]; console.log('Outstream advert: ' + iinfoVastUrls[iinfoVastUrlIndex]); videoContent.muted = false; videoContent.volume = 1; } // Specify the linear and nonlinear slot sizes. This helps the SDK to // select the correct creative if multiple are returned. // adsRequest.linearAdSlotWidth = outstreamWidth; // adsRequest.linearAdSlotHeight = outstreamHeight; adsRequest.nonLinearAdSlotWidth = 0; adsRequest.nonLinearAdSlotHeight = 0; adsLoader.requestAds(adsRequest); } function setupReplayScreen() { replayScreen.addEventListener('click', function () { iinfoOutstreamPosition.remove(); iinfoVastUrlIndex = 0; outstreamInit(); }); } /** * Sets the 'adContainer' div as the IMA ad display container. */ function createAdDisplayContainer() { // We assume the adContainer is the DOM id of the element that will house // the ads. outstreamDocument.getElementById('videoContent').style.display = 'none'; adDisplayContainer = new google.ima.AdDisplayContainer( outstreamDocument.getElementById('adContainer'), videoContent); } function unmuteAdvert() { adVolume = !adVolume; if (adVolume) { adsManager.setVolume(0.3); outstreamDocument.getElementById('adMuteBtn').innerHTML = ''; } else { adsManager.setVolume(0); outstreamDocument.getElementById('adMuteBtn').innerHTML = ''; } } /** * Loads the video content and initializes IMA ad playback. */ function playAds() { // Initialize the container. Must be done through a user action on mobile // devices. videoContent.load(); adDisplayContainer.initialize(); // setupDimensions(); try { // Initialize the ads manager. Ad rules playlist will start at this time. adsManager.init(1920, 1080, google.ima.ViewMode.NORMAL); // Call play to start showing the ad. Single video and overlay ads will // start at this time; the call will be ignored for ad rules. adsManager.start(); // window.addEventListener('resize', function (event) { // if (adsManager) { // setupDimensions(); // adsManager.resize(outstreamWidth, outstreamHeight, google.ima.ViewMode.NORMAL); // } // }); } catch (adError) { // An error may be thrown if there was a problem with the VAST response. // videoContent.play(); } } /** * Handles the ad manager loading and sets ad event listeners. * @param { !google.ima.AdsManagerLoadedEvent } adsManagerLoadedEvent */ function onAdsManagerLoaded(adsManagerLoadedEvent) { // Get the ads manager. const adsRenderingSettings = new google.ima.AdsRenderingSettings(); adsRenderingSettings.restoreCustomPlaybackStateOnAdBreakComplete = true; adsRenderingSettings.loadVideoTimeout = 12000; // videoContent should be set to the content video element. adsManager = adsManagerLoadedEvent.getAdsManager(videoContent, adsRenderingSettings); // Add listeners to the required events. adsManager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, onAdError); adsManager.addEventListener( google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED, onContentPauseRequested); adsManager.addEventListener( google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED, onContentResumeRequested); adsManager.addEventListener( google.ima.AdEvent.Type.ALL_ADS_COMPLETED, onAdEvent); // Listen to any additional events, if necessary. adsManager.addEventListener(google.ima.AdEvent.Type.LOADED, onAdEvent); adsManager.addEventListener(google.ima.AdEvent.Type.STARTED, onAdEvent); adsManager.addEventListener(google.ima.AdEvent.Type.COMPLETE, onAdEvent); playAds(); } /** * Handles actions taken in response to ad events. * @param { !google.ima.AdEvent } adEvent */ function onAdEvent(adEvent) { // Retrieve the ad from the event. Some events (for example, // ALL_ADS_COMPLETED) don't have ad object associated. const ad = adEvent.getAd(); console.log('Outstream event: ' + adEvent.type); switch (adEvent.type) { case google.ima.AdEvent.Type.LOADED: // This is the first event sent for an ad - it is possible to // determine whether the ad is a video ad or an overlay. if (!ad.isLinear()) { // Position AdDisplayContainer correctly for overlay. // Use ad.width and ad.height. videoContent.play(); } outstreamDocument.getElementById('adContainer').style.width = '100%'; outstreamDocument.getElementById('adContainer').style.maxWidth = '640px'; outstreamDocument.getElementById('adContainer').style.height = '360px'; break; case google.ima.AdEvent.Type.STARTED: window.addEventListener('scroll', onActiveView); // This event indicates the ad has started - the video player // can adjust the UI, for example display a pause button and // remaining time. if (ad.isLinear()) { // For a linear ad, a timer can be started to poll for // the remaining time. intervalTimer = setInterval( function () { // Example: const remainingTime = adsManager.getRemainingTime(); // adsManager.pause(); }, 300); // every 300ms } outstreamDocument.getElementById('adMuteBtn').style.display = 'block'; break; case google.ima.AdEvent.Type.ALL_ADS_COMPLETED: if (ad.isLinear()) { clearInterval(intervalTimer); } if (outstreamLastError === 303) { if (isBanner) { renderBanner(); } else { replayScreen.style.display = 'flex'; } } break; case google.ima.AdEvent.Type.COMPLETE: // This event indicates the ad has finished - the video player // can perform appropriate UI actions, such as removing the timer for // remaining time detection. if (ad.isLinear()) { clearInterval(intervalTimer); } if (isBanner) { renderBanner(); } else { replayScreen.style.display = 'flex'; } break; } } /** * Handles ad errors. * @param { !google.ima.AdErrorEvent } adErrorEvent */ function onAdError(adErrorEvent) { // Handle the error logging. console.log(adErrorEvent.getError()); outstreamLastError = adErrorEvent.getError().getErrorCode(); if (!loadNext()) { renderBanner(); } } function renderBanner() { if (isBanner) { console.log('Outstream: Render Banner'); iinfoOutstreamPosition.innerHTML = ""; iinfoOutstreamPosition.style.height = "330px"; iinfoOutstreamPosition.appendChild(bannerDiv); } else { console.log('Outstream: Banner is not set'); } } function loadNext() { iinfoVastUrlIndex++; if (iinfoVastUrlIndex < iinfoVastUrls.length) { iinfoOutstreamPosition.remove(); outstreamInit(); } else { return false; } adVolume = 1; return true; } /** * Pauses video content and sets up ad UI. */ function onContentPauseRequested() { videoContent.pause(); // This function is where you should setup UI for showing ads (for example, // display ad timer countdown, disable seeking and more.) // setupUIForAds(); } /** * Resumes video content and removes ad UI. */ function onContentResumeRequested() { videoContent.play(); // This function is where you should ensure that your UI is ready // to play content. It is the responsibility of the Publisher to // implement this function when necessary. // setupUIForContent(); } function onActiveView() { if (outstreamContainer) { const containerOffset = outstreamContainer.getBoundingClientRect(); const windowHeight = window.innerHeight; if (containerOffset.top < windowHeight/1 && containerOffset.bottom > 0.0) { if (outstreamPaused) { adsManager.resume(); outstreamPaused = false; } return true; } else { if (!outstreamPaused) { adsManager.pause(); outstreamPaused = true; } } } return false; } let outstreamInitInterval; if (typeof cpexPackage !== "undefined") { outstreamInitInterval = setInterval(tryToInitializeOutstream, 100); } else { const wrapper = getWrapper(); if (wrapper) { let outstreamInitialized = false; window.addEventListener('scroll', () => { if (!outstreamInitialized) { const containerOffset = wrapper.getBoundingClientRect(); const windowHeight = window.innerHeight; if (containerOffset.top < windowHeight / 1 && containerOffset.bottom > 0.0) { outstreamInit(); outstreamInitialized = true; } } }); } } function tryToInitializeOutstream() { const wrapper = getWrapper(); if (wrapper) { const containerOffset = wrapper.getBoundingClientRect(); const windowHeight = window.innerHeight; if (containerOffset.top < windowHeight / 1 && containerOffset.bottom > 0.0) { if (cpexPackage.adserver.displayed) { clearInterval(outstreamInitInterval); outstreamInit(); } } } else { clearInterval(outstreamInitInterval); } } }
OSZAR »