Skip to content

Commit

Permalink
Add HTML5 video support param to bid requests (prebid#3596)
Browse files Browse the repository at this point in the history
* Add HTML5 video support param to bid requests

* Use const instead of var for consistency
  • Loading branch information
madma authored and jacekburys-quantcast committed May 15, 2019
1 parent c06231d commit 45392da
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ export const sharethroughAdapterSpec = {
buildRequests: (bidRequests, bidderRequest) => {
return bidRequests.map(bid => {
let query = {
bidId: bid.bidId,
placement_key: bid.params.pkey,
hbVersion: '$prebid.version$',
strVersion: VERSION,
bidId: bid.bidId,
consent_required: false,
instant_play_capable: canAutoPlayHTML5Video(),
hbSource: 'prebid',
consent_required: false
hbVersion: '$prebid.version$',
strVersion: VERSION
};

if (bidderRequest && bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString) {
Expand Down Expand Up @@ -148,4 +149,25 @@ function b64EncodeUnicode(str) {
}));
}

function canAutoPlayHTML5Video() {
const userAgent = navigator.userAgent;
if (!userAgent) return false;

const isAndroid = /Android/i.test(userAgent);
const isiOS = /iPhone|iPad|iPod/i.test(userAgent);
const chromeVersion = parseInt((/Chrome\/([0-9]+)/.exec(userAgent) || [0, 0])[1]);
const chromeiOSVersion = parseInt((/CriOS\/([0-9]+)/.exec(userAgent) || [0, 0])[1]);
const safariVersion = parseInt((/Version\/([0-9]+)/.exec(userAgent) || [0, 0])[1]);

if (
(isAndroid && chromeVersion >= 53) ||
(isiOS && (safariVersion >= 10 || chromeiOSVersion >= 53)) ||
!(isAndroid || isiOS)
) {
return true;
} else {
return false;
}
}

registerBidder(sharethroughAdapterSpec);

0 comments on commit 45392da

Please sign in to comment.