-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add working outstream with mediaType renderer example #3871
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" class="html--no-js"> | ||
<head> | ||
{% include head--common.html %} | ||
<!--production version of prebid.js--> | ||
<script async src="//cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js"></script> | ||
|
||
<!--pbjs and player code --> | ||
<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> | ||
</head> | ||
<body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
examples/video/outstream/pb-ve-outstream-no-server-specify-renderer.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
--- | ||
|
||
|
||
|
||
<div class="container"> | ||
<div class="row"> | ||
<div class="vidHeader" style="width:75vw;"> | ||
<h1>{{ page.title }}</h1> | ||
<p>{{page.description }}</p> | ||
</div> | ||
|
||
<!--video warning--> | ||
<div class="pb-alert pb-alert-important"> | ||
<p style="color:#85720f"><b>Important:</b> | ||
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.</p> | ||
</div> | ||
|
||
<div> | ||
<div> | ||
<p>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.</p> | ||
</div> | ||
|
||
<div id='video1'> | ||
<p>Prebid Outstream Video Ad</p> | ||
</div> | ||
|
||
<div> | ||
<p>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?</p> | ||
</div> | ||
</div> | ||
|
||
<!--header code example--> | ||
<div class="pb-alert pb-alert-warning"> | ||
<p style="color:#a94443"><b>Warning:</b> | ||
Do not forget to exchange the placementId in the code examples with your own placementId!</p> | ||
</div> | ||
|
||
<h4>Place this code in the page header.</h4> | ||
<div class="pb-code-hl-wrap"> | ||
<pre class="pb-code-hl"> | ||
<!--put javascript code here--> | ||
<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> | ||
</pre> | ||
</div> | ||
|
||
<h4>Place this code in the page body.</h4> | ||
<div class="pb-code-hl-wrap"> | ||
<!--body code example--> | ||
<pre class="pb-code-hl"> | ||
<!--put body html and javascript here--> | ||
<div id='video1'> | ||
<p>Prebid Outstream Video Ad</p> | ||
</div> | ||
</pre> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script type="text/javascript" src="/assets/js/video/pb-code-highlight.js"></script> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can add some css to reserve some space that it's clear "this is the ad container, if you don't see anything something is wrong"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to stay away from CSS in html. I think it's clear if no video is playing than something is wrong!