Lenovo Thinkpad X1 Nano Gen1: nejlehčí pracovní ultrabook (recenze)

23. 6. 2021

Sdílet

 Autor: Radomír Kejduš / Cnews.cz
Lenovo vyrobilo extrémně tenký a lehký ThinkPad, jež je zároveň odolným ultrabookem. ThinkPad X1 Nano je velmi zajímavý laptop a krásná ukázka toho, jak spojit ergonomické a odolné tělo s dnešními požadavky na přenositelnost.

ThinkPad X1 Nano (s označením Gen1) se jako vůbec první ThinkPad dostal s hmotností pod jeden kilogram a také jde o první ThinkPad s certifikací Intel Evo. Vedle toho zaujme i jeho tenké tělo zvlášť s přihlédnutím k tomu, že kvůli tomu nenastaly žádné typické ústupky – klávesnice je stále podsvícená a vešly se i panty umožňující plné otevření víka.

K tomu si přidejte pro ThinkPad typicky výborně zpracované pevné tělo z příjemných materiálů. Pocitově máte v rukou notebook z budoucnosti, jak si ji možná představují konzervativní uživatelé. První dojem je prostě dokonalý.

Lenovo Thinkpad X1 Nano Gen1 recenze7 Plné otevření displeje

Černé tělo je příjemně pogumované a matné a v logu ThinkPad tradičně svítí červená dioda. Otisky prstů ale na těle bohužel i tak zůstávají. Notebook je o pár milimetrů menší než list papíru formátu A4. V balení dostanete drobnou nabíječku s koncovkou USB-C. Jen druhá část kabelu směrem do zásuvky je stále tlustá a neforemná. Nad klávesnicí jsou dva nahoru namířené stereoreproduktory hrající zcela standardně.

Lenovo Thinkpad X1 Nano Gen1Lenovo Thinkpad X1 Nano Gen1Lenovo-Thinkpad-X1-Nano-Gen1-recenze1-large

Víko otevřete lehce a jde to až do plných 180°. Objeví se před vámi matný nedotykový displej a méně častý poměr stran 16:10. Rámečky jsou tenké, ale zase ne tak moc, aby se nevešla webová kamera – dokonce i s posuvnou krytkou. Celé víko je pevnější než u většiny velkých notebooků a na rozdíl od nich bych zvýšenou odolnost tomuto stroji věřil. Splňuje jinak vcelku běžnou armádní specifikaci MIL-STD-810H.

model Lenovo Thinkpad X1 Nano Gen1
displej 13" (16:10) | IPS | 2160 × 1350 px | (CSOT MND007ZA1–2), matný
procesor Intel Core i7–1160G7(10nm, Tiger Lake) na 0,4–2,1 GHz (turbo 4,4 GHz), 4/8 jader, TDP 9 W
grafický čip Intel Iris Xe
operační paměť 16 GB LPDDR4
disk 512 GB SSD NVMe (WD SN530)
klávesnice ISO / alfanumerická, podsvícená, CZ diakritika
porty 2× Thunderbolt 4 (USB-C),  jack
sítě Wi-Fi 6 (802.11ax Intel AX201), Bluetooth (5.2), LAN (ne), LTE (ano)
biometrika/čtečka otisků čtečka obličeje a otisku
akumulátor 48 Wh
rozměry a hmotnost 293 × 207 × 16,7 mm / 0,9 kg
OS Windows 10 Pro
záruka 3 roky
doporučená cena 72 690 Kč

Klávesnice

Klávesnici uThinkPadů není třeba představovat – jsou to nejlepší, na čem ve světě notebooků psát. Jde o evropskou verzi ISO s velkým Enterem a krátkým levým Shiftem. Jednotlivá tlačítka jsou příjemně tvarovaná (mají prohloubení pro bříška prstů), šipky padnou skvěle do ruky a klávesy horní řada F mají pro odlišení jiný tvar. Výška zdvihu je i přes tenké tělo pořád přibližně stejná jako u jiných ThinkPadů.

Lenovo Thinkpad X1 Nano Gen1 recenze12 Standardní dobrá Thinkpadová klávesnice

Ani tahle klávesnice není sice dokonalá, ale ostatní výrobci by se mohli inspirovat. To platí i pro Lenovo, které do ostatních řad notebooků používá horší klávesnice. Horní řadu bývá lepší ponechat multimediálním tlačítkům, pro vyvolání zkratky zavření okna (Alt+F4) je to pak ale komplikované – Lenovo se stále nenaučilo horní řadu přepnout i s Altem.

Jinak tvarovaná horní řadaJinak tvarovaná horní řadaOddělené šipkyOddělené šipky

Dvě klávesy pro telefonní hovory (F10 a F11 s piktogramy sluchátka) jsou možná trochu nadbytečné. V základu jsou nastavené na spuštění Skypu a Microsoft Teams a když tyto aplikace nemáte nainstalované, nedělají nic.

Touchpad i s trackpointem fungují na jedničku. Plocha pro klikání je aktivní zhruba do poloviny výšky. Vedle touchpadu je spolehlivá čtečka otisků prstů. Přihlašovat se případně můžete i obličejem přes Windows Hello.

Displej

Lenovo pro tento model použilo IPS panel od TCL, respektive od společnosti CSOT (China Star Optoelectronics Technology), kterou TCL vlastní. Je matný a rozlišení 2160 × 1350 px o něco málo převyšuje Full HD. Lenovo udává jas až 450 nitů.

Lenovo Thinkpad X1 Nano Gen1 recenze15 homogenita displeje Homogenita podsvícení displeje

Kolorimetrickou sondou jsem naměřil rozsah jasu 4 až 406 nitů a kontrast 1600:1. Rovnoměrnost podsvícení typicky klesá od středu ke krajům, ale ne nijak výrazně. Vyvážení bílé i přesnost barev dokonce odpovídá fotografickým monitorům. Displeji nelze prakticky nic vytknout.

Vyvážení bíléVyvážení bíléPřesnost barevPřesnost barev

Konektivita

Na pravém boku je pouze zapínací tlačítko, což je u nekonvertibilních notebooků (clamshell) trochu netradiční umístění. Je ale nahmatatelné velmi snadno, takže mi to ani nevadilo. Vedle něj je jinak už jen výdech chlazení.

Na levé straně jsou sluchátkový jack a dva porty USB-C, respektive Thunderbolt 4. Nabíjet můžete kterýmkoliv. Z tohoto portu si případně vyvedete téměř jakýkoliv jiný port nebo připojíte externí monitor. Někomu možná bude chybět klasické USB-A nebo třeba čtečka karet, ale dvojice Thunderboltů 4 je asi to nejlepší, co dnes můžete mít.

2× Thunderbolt 42× Thunderbolt 4Zapínací tlačítko na bokuZapínací tlačítko na boku

Pod displejem je pak u některých modelů schovaný šuplíček na SIM kartu, volitelně totiž můžete mít i verzi s modulem LTE/5G. Bezdrátovou síť doplňuje Wi-Fi 6 a Bluetooth 5.2.

Lenovo Thinkpad X1 Nano Gen1 recenze3 Slot na SIM

Výdrž

Akumulátor je od známého výrobce SMP a pro malý laptop je 48 Wh spíše o nadprůměrná kapacita. Dlouhou výdrž slibuje i samotná certifikace Intel Evo. Také 65W nabíječka je velmi příjemná, drobná a snadno se bude s notebookem přenášet. Za hodinu v zásuvce se dostanete na 78 % (Lenovo inzeruje 80 %, takže se téměř trefilo).

Lenovo Thinkpad X1 Nano Gen1 recenze2 Drobná nabíječka s konektorem USB-C

Přes ikonku v oznamovací oblasti „u hodin“ lze přepínat mezi několika úspornými stavy. Vyzkoušel jsem dva z nich a ve zkratce za cenu nižší výdrže můžete docílit vyššího výkonu. V úspornějším stavu vydrží akumulátor deset a půl hodiny práce a 8,5 hodin přehrávání videa. Současně má pak ale počítač klidně o třetinu nižší výkon. Certifikace Intel Evo tedy proběhla zřejmě s odřenýma ušima.

Lenovo-Thinkpad-X1-Nano-Gen1-recenze18-Vantage1-largeLenovo-Thinkpad-X1-Nano-Gen1-recenze19-Vantage2-largeLenovo-Thinkpad-X1-Nano-Gen1-recenze20-Vantage3-largeLenovo-Thinkpad-X1-Nano-Gen1-recenze21-Vantage4-largeLenovo-Thinkpad-X1-Nano-Gen1-recenze22-Vantage3-large

V aplikaci Vantage lze nastavit různé šetřiče například podle toho, kdy s počítačem pracujete nebo také omezit nejvyšší hodnotu nabití či třeba nenabíjet pokud kapacita neklesne pod určenou hodnotu.

Lenovo Thinkpad X1 Nano Gen1 recenze23 baterie Režimy baterie

Na zásuvku lze volit tři režimy nazvané: Lepší baterie, Lepší výkon a Nejlepší výkon. Při provozu na akumulátor se objeví ještě režim Spořič baterie.

Výkon

Procesor Intel Core i7–1160G7 má sice TDP pouze 9 W, ale jeho výkon je vcelku srovnatelný s obdobnými modely na 15 W. Grafika Intel Iris Xe pak umožňuje hrát na nízké detaily, což je při takto tenkém těle skoro zázrak. CounterStrike si zahrajete.

Chlazení je ale jinak dost omezující. Uvnitř je jeden ventilátor nasávající vzduch zespodu a ten se umí roztočit naplno i mimo zátěž. Třeba i jen při nabíjení baterie, která se touto činností samozřejmě zahřívá. Procesor dokáže krátce držet frekvenci 3,3 GHz, ale dlouhodobě jen 2,3 GHz. Ventilátor jede v zátěži naplno, ale není nějak výrazně hlučný.

Lenovo Thinkpad X1 Nano Gen1 recenze24 hwinfo

Horní část klávesnice se zahřeje na 38 °C, výdech už má kolem 45 °C a spodek se také pohybuje okolo 40. Na klíně to při zátěži zkrátka není příjemné. Provozovat notebook v úspornějším stavu dává větší smysl.

Rozborka

Tenké ultrabooky jsou často špatně rozebíratelné. Tady ale na spodní straně najdete šroubky a můžete se opatrně podívat dovnitř (jeden je přelepený a znamená ztrátu záruky). Nejvýraznějším prvkem uvnitř je LTE modul od Fibocomu (L850-GL), u kterého je nachystaná ještě druhá sada antén. Tipujeme pro použití s 5G, ale může jít o něco jiného.

Lenovo Thinkpad X1 Nano Gen1 recenze14 Rozborka

Výrazné je i vedení heatpipe od procesoru k ventilátoru. Paměť je napájená přímo na desce a SSD by sice mohlo být přístupné, ale vidět nikde není a kompletní rozborku neděláme. Měděný plíšek v pravé části fotky sundat nešel.

Chválím tedy fakt, že se dá do notebooku dobře dostat (i když to Lenovo uživatelům nálepkou zakazuje), ale uvnitř je všechno již tak miniaturizované, že i výměna disku bude velmi složitá.

linux_sprava_tip

Hodnocení

Cnews_WeWantItThinkpad X1 Nano je úchvatný laptop, pro který jen ještě úplně nedozrály možnosti chlazení. Má skvělou klávesnici, výborný displej a k tomu nejmodernější konektivitu ve velmi tenké a lehkém těle. Navíc je pevný a odolný (crashtesty jsme ale nedělali).

Lenovo Thinkpad X1 Nano Gen1 recenze9 Posuvná krytka na webkameře

Ventilátor ale někdy hučí, i když zdánlivě nemá proč. Dojem také kazí vysoká cena, která je opravdu jen pro nadšence. Konfigurace stojí 72 tisíc a volitelně si lze vybrat i konfiguraci s Ubuntu. Tělo je přes matný povrch magnetem na otisky prstů. I tak bych se nezlobil, kdyby se zhruba tímto směrem tenké notebooky ubíraly. Thinkpad X1 Nano je zkrátka výborný na práci mimo domov.

Autor článku

Nadšenec do notebooků a příznivce kompaktních smartphonů. Najdete mě na Twitteru nebo LinkedInu.

'; 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 »