5nm ne-APU Ryzeny „Raphael“ prý možná mají integrovanou grafiku. Jak to AMD udělá?

8. 3. 2021

Sdílet

 Autor: AMD
Zatímco Intel má skoro ve všech procesorech integrované GPU, výkonnější AMD Ryzeny ho naopak postrádají a leckomu to vadí. Ale vypadá to, že až přijde socket AM5 a DDR5, mohlo by se to změnit: generace „Raphael“ by mohla i u těchto výkonných CPU grafiky obsahovat.

Minulý týden se dostaly ven nějaké informace o architektuře Zen 4, kterou AMD nasadí u 5nm Epyců a tají z desktopových 5nm Ryzenů pro socket AM5: dozvěděli jsme se hlavně věci k serverové verzi plus to, že jádra Zen 4 budou umět AVX-512, ale také například vyplynulo, že Zen 4 asi v desktopové verzi s kódovým označením Raphael nezvýší počty jader a zůstaneme na maximálně 16 jádrech/32 vláknech.

Ovšem u těchto Ryzenů „Raphael“ by se možná mohla udát jedna pro leckoho vítaná změna. Dnešní výkonnější procesory Ryzen pro desktop vždy postrádají integrovanou grafiku. Tu totiž AMD dává kvůli úspoře místa jen do monolitických „APU“, které jsou primárně určené pro notebooky. Velké Ryzeny ji v generaci 10002000 neměly, protože šlo o čipy, které se současně používaly pro serverové Epycy, které by přítomnost GPU ještě víc prodražovala.

Ryzeny Raphael pro socket AM5 s grafikou RDNA 3 na extra čipletu?

Ovšem v současnosti se šíří informace či drby, že právě desktopové Ryzeny Raphael (zatím nevíme, zda to bude generace 6000 nebo 7000, jednoduše řečeno ta první 5nm/pro socket AM5 a paměti DDR5) by už mohly mít svou vlastní integrovanou grafiku, která by už tak nebyla výsadou APU.

Různé weby teď píší o tom, že by Raphael mohl obsahovat GPU architektury RDNA 3 na vlastním čipletu – GPU by tedy bylo osazené jako další křemík. Možná by mohlo zabírat místo druhého CPU čipletu – pak by tyto procesory ale byly omezeny jen na osm jader. To by zase pak moc nedávalo smysl, protože potřebu osmijader s iGPU už pokrývají ta APU (u socketu AM5 to bude Rembrandt a poté Phoenix). Nebo by tento čiplet mohl ležet někde vedle a pak by ho mohla dostávat i 16jádra s dvěma CPU čiplety.

Bohužel není jasný nějaký přímý zdroj této informace, s trochou pátrání ale dojdeme k tomu, že jde asi aspoň částečně o spekulace opírající se o jeden už vlastně starý únik, o němž jsme loni už psali. A sice o útržek roadmapy, jenž vidíte níže, který publikoval leaker z Twitteru s přezdívkou MebiuW. Ukazuje posloupnost výkonných „CPU“ (tedy ne APU) Ryzenů pro desktop – 7nm Vermeer s jádry Zen 3, poté jeho refresh Warhol, jenž čekáme letos (to asi budou pořád stejné čipy, tedy refresh v pravém slova smyslu, něco jako Ryzeny 2000).

dajná roadmapa AMD ukazující Ryzen 5000 Warhol Údajná roadmapa AMD ukazující Ryzen 6000 "Warhol" a následující Raphael (Zdroj: MebiuW, via: VideoCardz, květen 2020)

A pak je zde něco začínajícího na „Ra“, což asi bude Raphael, který má vyjít roku 2022. Jak vidíte, u tohoto procesoru je useklý text „Na-“, což by mohlo znamenat Navi. U procesorů APU totiž AMD v této roadmapě právě takto označuje přítomnost integrované grafiky.

Roadmapa procesorů AMD sestavená z útržků webem VideoCardz Roadmapa procesorů AMD sestavená z útržků webem VideoCardz. Označení Dragon Crest berte s rezervou, nesedí do schématu a není jasné, zda platí (Zdroj: MebiuW, kompilace VideoCardz)

MebiuW myslím k tomuto víc neřekl, takže to, že bude použitá architektura RDNA 3 (kterou budou mít Radeony asi až v roce 2022), by byla čistá spekulace. Osobně bych si tipnul, že toto spíš nenastane a z časových důvodů bude spíš použité GPU starší generaci RDNA 2. Také tato roadmapa nutně neříká, že by toto GPU muselo mít formu čipletu navíc. Je zde totiž ještě jedna možnost, jak by takové integrované Navi v procesorech Raphael mohlo být realizováno. Tedy pokud v těchto procesorech opravdu GPU bude – zatím bych to raději nebral jako hotovou věc.

GPU čiplet nebo IO čiplet s GPU?

Od generace 3000 má AMD ještě jednu příležitost, jak do těchto procesorů grafiku dostat – mají totiž separátní 14nm „IO čiplet“, v němž je paměťový řadič, funkcionalita čipsetu a řadič PCI Expressu. Mohlo by v něm už být i integrované GPU, protože tento IO čiplet není sdílený mezi desktopem a servery. Pokud by tedy IO čiplet Ryzenů obsahoval iGPU, v IO čipletu Epyců by nepřekáželo a tudíž padají některé důvody. Proč dřív v „CPU Ryzenech“ nebylo. Ale v generaci 3000 ani 5000 AMD tuto příležitost nevyužilo.

amd ryzen 3000 ces toms hardware Fotografie vzorku Ryzenu 3000 bez rozvaděče tepla z CES 2019. Vlevo IO čiplet, vpravo jeden CPU čiplet (Zdroj: Tom's Hardware)

U 5nm Ryzenů „Raphael“ pro socket AM5 by CPU čiplety opět byly z Epycu Genoa, ale IO čiplet bude zase separátní a pokud je pravda, že Rapheal bude mít integrované GPU, pak by AMD mohlo přidat grafiku právě do tohoto křemíku. Byla by tím pádem na starším procesu a asi by v zájmu ušetření místa nebyla moc výkonná, ale to hlavní by bylo splněno – vyšší modely Ryzenů s 12 až 16 jádry by už nepotřebovaly doplnit samostatnou kartou (lidé si k nim teď často kupují i pomalé adaptéry jako je GeForce GT 1030). Tím pádem by také byly snáze využitelné v OEM sestavách.

Je tedy teď otázka, která z cest by mohla být zvolena – zda separátní čiplet, nebo integrace do IO čipletu. První varianta, kdy by GPU bylo samostatný kousek křemíku navíc, má tu výhodu, že by AMD pořád mohlo vyrábět procesory, kde by nebylo osazeno. Ty by pak byly na výrobu lacinější – výhoda proti monolitickým CPU Intelu. GPU čiplet by měly jen ty modely Ryzenů, kde by byla grafika chtěná.

Jenže: GPU potřebuje i paměti a pro rozumný výkon by k nim mělo mít co nejpřímější přístup, protože je důležitá co největší propustnost. Bylo-li by na samostatném čipletu, muselo by do paměti přes Infinity Fabric, všechna komunikace by šla přes separátní IO čiplet. Z tohoto pohledu se zdá šikovnější integrovat GPU do IO čipletu, kde bude hned vedle řadiče pamětí. Otázka však je, zda je toto vůbec důležité, protože se nejspíš bavíme o relativně nevýkonném GPU určeném hlavně pro základní funkčnost a akceleraci multimédií.

Pokud by integrovaná grafika byla v IO čipletu, mělo by to zase tu nevýhodu, že by se zvětšil o desítky mm², které by zvyšovaly výrobní náklady na každý kus. Ale je možné, že by to AMD až tak nevadilo. Intel zdá se operuje s tím, že se vyplatí mít iGPU takto na drtivé většině prodávaných CPU.

Je zde ještě jedna nevýhoda: IO čiplet je vyrobený starším procesem. Ale pokud je použita architektura RDNA nebo RDNA2 („Navi“), tak tu AMD implementovalo jen na 7nm procesu. Nezdá se moc pravděpodobné, že by AMD začalo už příští rok IO čiplet vyrábět drahým a nedostatkovým 7nm procesem. Jak moc je architektura RDNA 2 portovatelná na jiný proces (třeba od GlobalFoundries a navíc méně pokročilé generace), je otázka. Je pravda, že AMD teď GPU licencuje Samsungu, což vyžaduje schopnost adaptace na jiné procesy, takže možná, že jako bonus teď dovedou nějaké méně výkonné Navi udělat i na 12nm nebo 10nm procesu.

Procesor s integrovanou grafikou na separátním čipletu (který tehdy obsahoval i řadič pamětí a byl tedy velmi podobný IO čipletu v Ryzenech/Epycích) už tu kdysi byl, mobilní Core i3/i5 Arrandale od Intelu. Šlo o 32nm procesor odvozený od architektury Nehalem/Westmere, čiplet s GPU/northbridgem byl 45nm (Zdroj: Intel)

Přítomnost GPU ještě nemusí být jistá

Co z toho tedy AMD zvolí, uvidíme – čekal bych osobně spíš integraci do IO čipletu, která vypadá jako cesta nejmenšího odporu, ale to nemusí být rozhodující. Samotnou existenci iGPU v Ryzenech „Raphael“ ale zatím nemáme úplně potvrzenou, takže to zatím berte celé s rezervou. Byla by škoda, pokud by se ukázalo, že šlo jenom o něčí omyl/spekulaci.

Ale mimochodem: na oné uniklé roadmapě byl ještě Raphael ohraničen přerušovanou čárou a separátně pak ještě bylo přerušovaně ohraničeno to „Navi“. A takto se vyznačují elementy, které ještě nejsou definitivně rozhodnuté a mohou se měnit. Tudíž je tu i možnost, že šlo o vlastnosti, které AMD pro budoucí produkty zvažovalo, ale mezitím mohlo zase zrušit (což podle některých indicií možná nastalo v příběhu o SMT4).

bitcoin_smenarna

Jak bude podle vás řešená intergovaná grafika v procesorech AMD Ryzen "Raphael"/Zen 4?

Že některým uživatelům (nebo firmám stavějícím kancelářská PC) integrovaná grafika chybí, je ale celkem jasné, takže aspoň pro část trhu by toto mohlo být přínosné. Navíc: teoreticky by se tímto možná otevírala cesta, jak tato výkonná CPU (ovšem asi předělaná do pouzdra BGA) dostat i do výkonnějších notebooků a mobilních pracovních stanic. Tam totiž doteď nemohly, jelikož tyto stroje iGPU vyžadují. Toto by ale asi vyžadovalo, aby AMD eliminovalo zhoršenou spotřebu, kterou vícečipové provedení desktopových Ryzenů působí.

Galerie: Uniklé či zveřejněné dokumenty k architektuře AMD Zen 4

Zdroje: Hardware Times, MebiuW

Autor článku

Redaktor portálu Cnews.cz. Zaměřuje se na procesory, mobilní SoC, grafické karty, disky a další počítačový hardware. Profil autora →

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