Tihle letos zaujali. A právem. Přinášíme perličky z Příběhů podnikatelů

29. 12. 2017
Doba čtení: 7 minut

Sdílet

Ilustrační obrázek
Autor: Depositphotos – AllaSerebrina
Ilustrační obrázek
Je jedním z vašich novoročních předsevzetí, že si konečně splníte sen a začnete dělat něco, co má opravdu smysl a bude vás bavit? Nebojte se a inspirujte se.

Připravili jsme výběr toho nejzajímavějšího z letošních Příběhů podnikatelů.

Kdy je příliš pozdě začít rozjíždět byznys? Nikdy

Věk je jenom číslo. Důležité je odhodlání. Pak se dá začít podnikat v každém věku. Ukázkovým příkladem tohoto přístupu je sedlář Jan Hnátek, který na pražských Vinohradech provozuje Ateliér pro práci s kůží Haki. Až do svých 50 let působil jako manažer v Sazce. Po krizi, kterou si tato loterijní firma prošla, se ze dne na den ocitl bez práce. Rozhodně ale ne bez naděje a odhodlání. Řekl si tenkrát, že je ten správný okamžik začít dělat to, co ho baví. A skutečně začal profesionalizovat svou zálibu v sedlářství. A to až do té míry, že neváhal nastoupit do učení. Já, když se do něčeho pustím, tak to myslím vážně. Sice už jsem měl v oboru něco za sebou, ale chyběl mi výuční list. Nechtěl jsem, abych působil jako amatér, a tak jsem si dojednal schůzku s ředitelem učiliště ve Vysočanech a požádal o přijetí ke studiu. Ředitel mi to rozmlouval a radil, že si mám jen požádat o živnostenský list a začít podnikat, protože jde o volnou živnost. Když jsem mu řekl, že už živnostenský list mám, ale chci získat ten výuční, abych si ho mohl zarámovat a pověsit v dílně, jen se na mě udiveně díval, vzpomíná Jan Hnátek v rozhovoru nazvaném V 50 letech na učiliště? Proč ne, mistr sedlář toho nelituje.

Lidmi, kteří se nenechají skolit nepříjemnou realitou, jsou i manželé Miroslav a Jaroslava Lasákovi z Radošova u Karlových Varů. Ti se po ztrátě zaměstnání ve vyšším věku vrhli na domácí výrobu ponožek a investice do pletacích strojů rozhodně nelitují. Bylo to někdy v roce 2005, mně bylo přes 50 let, kolem se zavíral jeden podnik za druhým a hrozilo, že můžu kdykoli přijít o práci. Říkal jsem si, že najít nové místo bude pro člověka v mém věku složité, a bral jsem nákup pletacího stroje jako naději. Kdybych byl bez místa, můžu se začít živit výrobou ponožek, popisuje své rozhodnutí i po letech Miroslav Lasák. Minimálně by to byl dobrý přivýdělek. Práci si nakonec udržel déle než jeho manželka, a když o ni přišel i on, podnikání už nic nestálo v cestě a stalo se vlastně i nutností. Tak začal příběh českých ponožek Lenka popsaný v článku Vyrábí ponožky. Byznys překvapivě kvete.

Žádným junákem už po návratu z emigrace nebyl ani Rudolf Holý z krušnohorského Perninku. Jeho motivace obnovit slávu kdysi věhlasného lyžařského střediska ale byla opět silnější než datum narození v občanském průkazu. Dnes, na prahu sedmdesátky, se svým dětem chystá postupně předat oblíbený a zcela funkční a konkurenceschopný skiareál. Do penze se ale ještě určitě nechystá. Podnikání ho totiž udržuje v kondici. Nemám problém sednout do rolby a upravit svah ani zaskočit v bufetu. Když jsem tu začínal, musel jsem se naučit všechno. Dnes je mi 68 let a tak si taky rád odlehčím a jen sleduju, jak to šlape. Jakmile je ale něco potřeba, musím nastoupit. Všechno musí být v co nejlepším stavu. Jen tak se vyvarujeme možným úrazům a lidem se u nás bude líbit, říká Rudolf Holý. Do podnikání se pustil v době, kdy hodně lyžařských středisek upadalo a končilo. A to nejen u nás, ale i v nižších polohách Alp. Ani tam nemají malé skiareály na růžích ustláno. Když už do něčeho jdete, tak do toho musíte jít naplno a mít to rádi. Jinak brzy skončíte. Musíte se obětovat a pak si užívat chvíle, kdy vám váš projekt začne dělat radost, dodává Rudolf Holý. Celý jeho příběh je zachycen v článku Proč provozovatelé skiareálů každý rok roní slzy? Protože své práci nerozumí.

Tohle podnikání závidí jen málokdo

Mezi 23 příběhy podnikatelů, které server Podnikatel.cz v roce 2017 přinesl, mají své místo i ti, kteří začali podnikat v netradičních oborech. Mezi nimi určitě vyčníval čistič bot Michal Grivalský. Najdete ho v pasáži Myslbek v centru Prahy a patří k těm, kteří obnovili prakticky zapomenuté řemeslo. V Myslbeku si ho váží proto, že poskytuje neobvyklý a nadstandardní servis. A navíc přivádí i klientelu zdejším obchodům, restauracím a kavárnám. Článek o jeho profesním životě se jmenuje Zákazníci na něj naléhají, aby zvýšil ceny. Jaký živnostník má takové štěstí? Jak se dočtete, zrovna lehké živobytí čistič bot nemá. Přesto by neměnil. Svou práci dělá s láskou a zapálením.

Stejně je na tom i Daniel Havlín, který navzdory pokroku v oblasti IT a komunikace udržuje funkční jednu z posledních pražských internetových kaváren. I to je podnik, který stojí za to navštívit. Je možné ho doporučit klidně i jako exkurzi s dětmi, které si nedokážou představit život bez sociálních sítí a mobilů. Cestu na Pankrác ale neodkládejte. Jednoho dne by se totiž internetová kavárna mohla změnit na kavárnu skutečnou. To je můj sen. Rád bych měl útulnou kavárnu, kam by lidi mohli zajít na kávu s přáteli nebo na pracovní schůzku. Protože bych se asi úplně nedovedl odpoutat od současnosti, samozřejmě bych tam nabízel wi-fi připojení a asi bych někam do rohu umístil i jeden nebo dva počítače pro ty, kteří by potřebovali sednout před velkou obrazovku, líčí Daniel Havlín své představy. Jak funguje jeden z posledních podniků svého druhu si připomeňte v článku Internetová kavárna. Těžké retro, kterému zvoní hrana.

Nebáli se zariskovat a uspěli

Začátky podnikání bývají náročné na čas, energii, psychiku i peníze. Toto všechno se ještě násobí ve chvíli, kdy se člověk pouští do pro něj zcela nového oboru. Neutéct od toho a nespadnout do dluhů vyžaduje silnou vůli a dřinu. Své o tom ví třeba Jan Novák z Brandýsa nad Labem, který už dva roky vyrábí originální psací pera. Od mladíka, který je svým založením intelektuál, vystudoval gymnázium a Univerzitu Karlovu, nikdo nečekal, že se jednou začne živit manuální prací. A donedávna si to nemyslel ani on. Přestože po dvou letech podnikání udělal velký posun, cítí se být stále na začátku. Vzhlíží především k americkým výrobcům, kteří produkují skutečně mistrovské kousky a vyrobí si je celé sami. On stále ladí technologie a snaží se souznít se dřevem. Jednou by rád vytvořil pero z betonu. Je to materiál, který prý miluje. Teď ale mají úspěch dřevěná pera a není důvod se atraktivního produktu zbavovat. Spíš je na čase přemýšlet o dalším vývoji firmy. Čeho už dosáhl a jak si žije, to Jan Novák popisuje v článku K podnikání ho přivedla videa na YouTube. Živí se výrobou psacích per.

WT100 25_SE

Nesnadný začátek má za sebou Linda Bezusová Kamarádová, která v pražských Nuslích připravuje špičkové džemy. A obstojí s nimi i v mezinárodním srovnání. Dva a půl roku kloubila svou kancelářskou práci s péčí o rodinu a výrobu a prodejem marmelád. Teď je to přesně rok od chvíle, kdy se věnuje už jen svým marmeládám, a rozhodnutí osamostatnit se nelituje. Vždyť se propracovala mezi elitu. Její pomerančová marmeláda s rebarborou značky Marmelinda získala na světové soutěži The Marmalade Awards 2017 získala zlatou medaili. Stříbro brala za marmeládu ze španělských pomerančů a bronzovou medailí porota ocenila kombinaci pomeranče s citronem a citronu se zázvorem a zeleným čajem. Ani výrobce exkluzivních marmelád s oceněním ze světové soutěže to ale jako obchodník nemá jednoduché. Medaile sice vypadají jako vstupenka do špičkových hotelů a kaváren, ale jen na první pohled. Linda Bezusová Kamarádová se o tom rozpovídala v článku Vaří marmelády a džemy světové kvality. Přesto jejich prodej není snadný.

Svět byznysu je neúprosný, ale naštěstí pro spoustu lidí stále lákavý. Právě díky podnikatelům vznikají nové hodnoty nebo se oživují staré. Redakce serveru Podnikatel.cz přeje do roku 2018 všem odvážlivcům, kteří se rozhodli postavit na vlastní nohy a být zodpovědní sami za sebe a často i své zaměstnance, hodně štěstí, energie a zajímavých příležitostí. A protože inspirujících příběhů není nikdy dost, budeme vás s nimi rádi seznamovat i v příštím roce.

'; 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'; } }
Upozorníme vás na články, které by vám neměly uniknout (maximálně 2x týdně).
'; 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 »