From e360d68878896cd182eb2266fc09bdd01a011310 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 30 Jun 2022 21:01:27 -0700 Subject: [PATCH] Add working outstream with mediaType renderer example (#3871) * Add working outstream with mediaType renderer example * Expand appnexus renderer example * Fix html formatting --- _data/sidebar.yml | 8 + _includes/video/pb-os-nas-renderer.html | 91 +++++++++++ _layouts/video_sample.html | 2 + ...-outstream-no-server-specify-renderer.html | 145 ++++++++++++++++++ 4 files changed, 246 insertions(+) create mode 100644 _includes/video/pb-os-nas-renderer.html create mode 100644 examples/video/outstream/pb-ve-outstream-no-server-specify-renderer.html diff --git a/_data/sidebar.yml b/_data/sidebar.yml index 9080b000f9..97b9747c92 100644 --- a/_data/sidebar.yml +++ b/_data/sidebar.yml @@ -1730,6 +1730,14 @@ sectionTitle: subgroup: 1 +- sbSecId: 4 + title: 'No Server (Specify Renderer)' + link: /examples/video/outstream/pb-ve-outstream-no-server-specify-renderer.html + isHeader: 0 + isSectionHeader: 0 + sectionTitle: + subgroup: 1 + - sbSecId: 4 title: "Long-Form (Ad Pods)" link: diff --git a/_includes/video/pb-os-nas-renderer.html b/_includes/video/pb-os-nas-renderer.html new file mode 100644 index 0000000000..35a8a624ad --- /dev/null +++ b/_includes/video/pb-os-nas-renderer.html @@ -0,0 +1,91 @@ + + + + {% include head--common.html %} + + + + + + + + diff --git a/_layouts/video_sample.html b/_layouts/video_sample.html index e7b74b4615..47b83f76fc 100644 --- a/_layouts/video_sample.html +++ b/_layouts/video_sample.html @@ -44,6 +44,8 @@ {% include /video/pb-os-app.html %} {% elsif page.videoType == "pb-os-nas" %} {% include /video/pb-os-nas.html %} +{% elsif page.videoType == "pb-os-nas-renderer" %} + {% include /video/pb-os-nas-renderer.html %} {% elsif page.videoType == "pb-lf-fw" %} {% include /video/pb-lf-fw.html %} {% elsif page.videoType == "pb-cp-fp" %} diff --git a/examples/video/outstream/pb-ve-outstream-no-server-specify-renderer.html b/examples/video/outstream/pb-ve-outstream-no-server-specify-renderer.html new file mode 100644 index 0000000000..ab09e8518f --- /dev/null +++ b/examples/video/outstream/pb-ve-outstream-no-server-specify-renderer.html @@ -0,0 +1,145 @@ +--- +layout: video_sample +title: Prebid Video | Video Outstream Example with No Ad Server using Specified Renderer +description: An example of an outstream video ad using Prebid.js and no ad server but with a specified renderer. +videoType: pb-os-nas-renderer +isVideo: true +sidebarType: 4 +--- + + + +
+
+
+

{{ page.title }}

+

{{page.description }}

+
+ + +
+

Important: + This example uses a test version of Prebid.js hosted on our CDN that is not recommended for production use. It includes all available adapters. Production implementations should build from source or customize the build using the Download page to make sure only the necessary bidder adapters are included.

+
+ +
+
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

+
+ +
+

Prebid Outstream Video Ad

+
+ +
+

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?

+
+
+ + +
+

Warning: + Do not forget to exchange the placementId in the code examples with your own placementId!

+
+ +

Place this code in the page header.

+
+
+
+<script>
+    var pbjs = pbjs || {};
+    pbjs.que = pbjs.que || [];
+
+    function callANRenderer(bid, ad) {
+      const adResponse = {
+          ad: {
+              video: {
+                  content: ad,
+                  player_width: 640,
+                  player_height: 480,
+              }
+          }
+      }
+
+      bid.renderer.push(() => {
+          window.ANOutstreamVideo.renderAd({
+              targetId: bid.adUnitCode,
+              adResponse,
+          });
+      });
+    }
+
+    function render(bid) {
+        let ad = bid.ad || bid.vastXml;
+
+        if (ad) {
+            callANRenderer(bid, ad)
+        } else {
+            if (bid.vastUrl) {
+              (async () => {
+                  ad = await fetch(resp).then(resp => resp.text());
+
+                  if (typeof ad === 'string') {
+                      callANRenderer(bid, ad);
+                  } else {
+                      console.log('Invalid VAST');
+                  }
+              })();
+            } else {
+                console.log('Invalid ad');
+            }
+        }
+    }
+
+    const adUnits = [{
+        code: 'video1',
+        mediaTypes: {
+            video: {
+                context: 'outstream',
+                playerSize: [640, 480],
+                mimes: ['video/mp4'],
+                protocols: [1, 2, 3, 4, 5, 6, 7, 8],
+                playbackmethod: [2],
+                skip: 1,
+                renderer: {
+                    render,
+                    url: "https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js"
+                },
+            }
+        },
+        bids: [{
+            bidder: 'appnexus',
+            params: {
+                placementId: 13232385
+            }
+        }]
+    }];
+
+    pbjs.que.push(function() {
+        pbjs.addAdUnits(adUnits);
+        pbjs.requestBids({
+            timeout: 1000,
+            bidsBackHandler: function(bids) {
+                const highestCpmBids = pbjs.getHighestCpmBids('video1');
+                pbjs.renderAd(document, highestCpmBids[0].adId);
+            }
+        });
+    });
+</script>
+            
+
+ +

Place this code in the page body.

+
+ +
+
+<div id='video1'>
+  <p>Prebid Outstream Video Ad</p>
+</div>
+            
+
+
+
+ +