Prebid Video | Outstream Example with AdPlayer.Pro Player

An example of an outstream video using Prebid.js and AdPlayer.Pro player.

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.

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 src="//acdn.adnxs.com/prebid/not-for-prod/prebid.js"></script>
<!--AdPlayer.Pro code-->
<script src="https://static.adplayer.pro/player/demo.js"></script>

Place this code in the page body.


<div id='playerContainerADP'></div>
<script>
	/* our app where we run player
   our app variables */
		var pbjs;
		pbjs = pbjs || {};
		pbjs.que = pbjs.que || [];
		var debug = false;
		if (typeof window.console === 'undefined' || typeof window.console.log === 'undefined' || typeof window.console.dir === 'undefined') {
		  debug = false;
		}
		var videoId = 'video1';

		/* Prebid video ad unit
		   This is a working example but you must use your own settings/bidders for production
		   More docs at https://prebid.org/prebid-video/video-overview.html */
		var adUnits = [{
		  code: videoId,
		  mediaTypes: {
		    video: {
		      playerSize: [640, 480],
		      context: 'outstream'
		    }
		  },
		  bids: [{
		    bidder: 'appnexus',
		    params: {
		      placementId: 13232385,
		      video: {
		        skippable: true,
		        playback_method: ['auto_play_sound_off']
		      }
		    }
		  }]
		}];

		pbjs.que.push(function () {
		  pbjs.addAdUnits(adUnits);
		  pbjs.requestBids({
		    timeout: 1000,
		    bidsBackHandler: function (bids) {
		      if (debug) {
		        window.console.dir(bids);
		      }
		      // we get the VAST XML from bids adResponse and pass it to our outstream player
if (bids && bids[videoId] && bids[videoId].bids && bids[videoId].bids[0] && bids[videoId].bids[0].adResponse) { var adResponse = bids[videoId].bids[0].adResponse; if (adResponse.ad && adResponse.ad.video && typeof adResponse.ad.video.content === 'string') { var vastXml = bids[videoId].bids[0].adResponse.ad.video.content; if (vastXml !== '') { if (debug) { window.console.log(vastXml); } AdPlayerPro('playerContainerADP').setup({ "file": "https://static.adplayer.pro/video/640.mp4", "width": 640, "height": 360, "autoStart": true, "muted": true, "advertising": { "tag": vastXml } }); } } } } }); }); </script>