Jak se zbavit rýmy? Pomůžou léky i babské rady

24. 9. 2018 13:16
přidejte názor
Autor: Depositphotos

Rýma je zánět nosní sliznice, který se projevuje pocitem plného nosu a výtokem hlenu. Ačkoli je rýma „zabiják mužů“, ve většině případů se jedná o virové onemocnění, které nevyžaduje lékařské vyšetření. Běžná doba léčby je 7 dní.

Během rýmy se špatně dýchá, to však není způsobeno přítomností hlenu, nýbrž to způsobují zduřelé sliznice.

Rýma může být způsobena alergiemi, viry i bakteriemi. Pokud nejste alergici a bojujete s rýmou, je nejspíše způsobena virovou infekcí.

Pokud máte pocit, že na vás rýma přichází v určitých obdobích, je možné, že máte alergii. V tom případě se zajděte otestovat k lékaři. Při alergické rýmě jsou hlavní pomocí léky proti alergii, tedy antihistaminika. Ty jako alergik můžete mít doma preventivně, a dávat si je, když tušíte, že rýma zase přichází.

Inkubační doba a přenos rýmy

Rýma se přenáší kapénkovou infekcí i osobním kontaktem. Viry způsobující rýmu jsou téměř všudypřítomné, a je jich více než 200 druhů. Ty se neustále mění, proto na rýmu neexistuje očkování.Inkubační doba rýmy je 1–3 dny a člověk je náchylnější k nakažení, když má sníženou imunitu. Prochladnutí je jeden z hlavních případů, kdy dochází ke snížené imunitě, proto je podzim nejrizikovějším obdobím.

Virová, nebo bakteriální rýma

Ačkoli je původcem rýmy virové onemocnění, v dutinách se vám mohou přemnožit bakterie, a nastává bakteriální infekce. Doba léčby rýmy je většinou do jednoho týdne. V případě, že se jedná o bakteriální rýmu, je léčba delší.

Rozvine-li se bakteriální infekce, dojde ke změně hlenu, který vysmrkáváte. Z čirého přechází do hustého, žlutě až zeleně zbarveného a následuje zvýšení teploty.

V takovém případě navštivte lékaře. Pokud vám doktor potvrdí bakteriální infekci, předepíše vám antibiotika.

Jak se zbavit rýmy

Při rýmě je jako u všech onemocnění vhodné relaxovat a příliš se nenamáhat. Není nutné brát si nemocenskou, ale po práci udržujte klidový režim na lůžku. V posteli se teple zabalte a podložte si hlavu, aby hlen mohl vytékat.

Babské rady na rýmu, aneb co pomáhá

  • Vdechování vodní páry
  • Kuřecí vývar
  • Horká koupel
  • Bylinné čaje s medem a citrónem
  • Čaj z rostliny s názvem Rýmovník
  • Jezte hodně ovoce
  • Vyhýbejte se mléčným výrobkům
  • Berte zinkové tablety
  • Česnek
  • Nosní výplach solným roztokem
  • Spánek
  • Nosní kapky

Jak vyléčit rýmu? Homeopatika i léky

Častým smrkáním zabráníte rozmnožování virů a zhoršení infekce.

Viry zabíjejí vysoké teploty, proto se naložte do horké vany a poté se rychle zabalte a ulehněte do postele. Přijde uměle vyvolaná horečka a vy se budete silně potit. To je žádoucí, neboť dochází k rychlému zabíjení virů. Po půl hodině se opět převlečte do suchého a teplého oblečení.

Uvařte si silný domácí kuřecí vývar. Nejen, že si pochutnáte, ale vývar má také silné odhleňovací účinky.

Zinkové tablety také zamezují rozmnožování virů, popřípadě se můžete v homeopatických lékárnách zeptat na jiné látky. Doporučují se Allium cepa 9ch, Dulcamara 9ch nebo Kalium biochromicum 9ch, záleží na typu rýmy.

Na zmírnění zduření sliznice používejte nosní kapky, s těmi ale opatrně, jsou vysoce návykové a při dlouhodobém užívání jsou kontraproduktivní.

Nedoporučuje se konzumace mléka a mléčných výrobků, neboť způsobují zahlenění organismu.


Nejoblíbenější léky proti rýmě a ucpanému nosu jsou SinupretOlynthNa­sivinSanorin Muconasal.


Jak se zbavit rýmy přes noc

Na lehké projevy rýmy se doporučuje si potřít chodidla cibulí a dát na nohy ponožky. Poté nakrájejte cibuli na kolečka a dejte na talíř, který nechte v pokoji. V teple se vyspěte, a ráno byste měli od rýmy cítit úlevu.

Druhy rýmy

Vzhledem k tomu, že je rýma způsobena různými viry, bakteriemi nebo alergiemi, má několik odlišných projevů. Proč vás někdy bolí hlava z velkého tlaku, zatímco jindy vám z nosu vyloženě teče? Je to ovlivněno právě tím, jaký druh rýmy máte a v jakém stádiu nemoci jste.

Vazomotorická rýma

Tato rýma je jedinou výjimkou, neboť není způsobena žádným onemocněním ani alergií, nýbrž fyziologickou reakcí, například na rychlou změnu teploty. Vazomotorická rýma se spouští při konzumaci pálivých jídel, při změně polohy těla, nebo při fyzické aktivitě. Tato rýma většinou rychle přejde, jelikož není způsobená infekcí.

Vodnatá rýma

Většina zánětů nosní sliznice a nosohltanu začíná vodnatým výtokem čirého hlenu z nosu, tedy vodnatou rýmou. Jedná se o počáteční stádium infekce, někdy je také stádiem jediným, když se nerozšiřují viry ani bakterie. Většinou ale rýma vodnatá přechází na rýmu hlenovou až hlenohnisavou.

Zastydlá rýma

Tak se říká zánětu vedlejších nosních dutin. Zastydlá rýma se projevuje špatným dýcháním, pocitem ucpaného nosu, přitom se nemocnému nedaří smrkat. Je doprovázena bolestí hlavy a pocitu tlaku v lebce. V ucpaných dutinách může vzniknout bakteriální infekce, které se říká sinusitida. Tu je třeba léčit antibiotiky.

Zaražená rýma

Zaražená rýma je v podstatě totéž, co zastydlá rýma. Hlen se zdá být zaražen v dutinách hlavy a vyvíjí nepříjemný tlak. Pro léčbu rýmy je důležité ji udržovat tekutou, neboť při delším pobytu v těle se rozmnožují viry a někdy i bakterie. Zajděte si do lékárny a nakupte léky pomáhající rozpouštět a vylučovat hlen.

Hnisavá rýma

Hnisavá rýma je komplikací běžné rýmy. Mění se struktura a barva hlenu, je komplikované jej vysmrkávat. Pokud dochází ke stupňování příznaků, vyhledejte lékaře. Když komplikace ustoupí během jednoho týdne, stačí samoléčba.Hnisavá rýma může být způsobena několika různými komplikacemi infekce, mnohé z nich musí být léčeny antibiotiky.

Nepříjemné potíže při rýmě

Ne náhodou se soustřeďuje lékařské oddělení ORL na problémy nosu, uší a krku. Tyto orgány jsou propojeny a onemocnění jednoho může snadno vést k onemocnění ostatních. Tedy při silné rýmě je možné, že vás budou bolet v uších a v krku.Někdy dochází k rozšiřování infekce, a v takovém případě je důležité problém řešit, jindy jde však o pouhý podtlak v uších či vyschlý krk z dýchání ústy.

Bolesti ucha při rýmě

Pokud máte rýmu a bolí vás ucho, může jít o zánět, současně je pravděpodobnější, že se jedná o podtlak ve středouší.

Ten vzniká tím, že nateče Eustachova trubice, která je mezi dutinami a otevře se vždy při polknutí nebo zívnutí, aby vyrovnala tlak mezi svaly nosohltanu. Když je zduřelá, není se schopná otevřít. Postupně se v ní spotřebovává vzduch, čímž vzniká podtlak, který vtahuje ušní bubínek dovnitř.

V takovém případě stačí podávat nosní kapky ke zmírnění otoku a léky proti bolesti. Pokud doma máte léky proti alergii, antihistaminika, také je použijte, pomohou ke splasknutí otoku sliznice.

Zalehlé ucho z rýmy

Zalehlé ucho je vždy způsobeno nevyrovnaným tlakem v dutinách. Proto, když vzlétáte v letadle, musíte často zívat, abyste tlak vyrovnali. Reflexy na vyrovnání tlaku jsou mnohdy samy vyvolány tělem, někdy je jim však třeba pomoci.

Pokud vám zalehlo ucho, zatímco máte rýmu, je dost možné, že je právě rýma na vině. Zkuste problém řešit, jako u běžného zalehnutí ucha. Zívejte, žvýkejte a polykejte, a současně dodržujte léčbu rýmy.

Doporučuje se užívat vitamíny, pít mnoho tekutin, a stejně jako u bolesti ucha používat nosní kapky a spreje, ty sníží otok sliznice a napomůžou otevření Eustachovy trubice.

Zánět středního ucha

Především u dětí se může nosohltanová infekce rozšířit do ucha a způsobit zánět středního ucha. Zánět středního ucha poznáte podle tlaku a bolesti v uchu, což je způsobeno přebytečnou tekutinou tlačící na bubínek v uchu.Pokud si vaše dítě stěžuje na bolest ucha, má zvýšenou teplotu a trpí nespavostí, urychleně navštivte lékaře. Zánět středního ucha je bolestivé onemocnění s nepříjemnou léčbou, a neléčené může mít vážné následky.

Chronická rýma

Ačkoli lékaři mnohdy žertují, že léčená rýma trvá 7 dní a neléčená týden, je vhodné si během tohoto onemocnění naordinovat klid a zdravý životní styl. V případě, že budete rýmu neřešit a takzvaně „přecházet“, může rýma přejít do bakteriálního onemocnění, nebo do chronického projevu.

Rýma se považuje za chronickou, když přetrvává déle než dva měsíce. Během nich může několikrát přijít mírné zlepšení, nikdy se však plně nevyléčí. V takovém případě navštivte lékaře, pravděpodobně vás pošle na ORL (ušní, nosní a krční).

Pokud vás trápí zadní rýma, pomůže vám tento článek.

  • Žá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 »