-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…412) Add prebid config to Kaltura player config to allow play prebid ads via IMA plugin and play prebid ad via playAdNow API. prebid will inject ad tag URL to ad layout config and delay the loading of playback, Prebid can get ad only once.
- Loading branch information
Showing
9 changed files
with
623 additions
and
27 deletions.
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
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,12 @@ | ||
// @flow | ||
|
||
declare type KPAdPrebidConfig = { | ||
adUnit: Object, | ||
params?: Object, | ||
options?: Object, | ||
timeout: number | ||
}; | ||
|
||
declare type KPPrebidConfig = KPAdPrebidConfig & { | ||
libUrl: string | ||
}; |
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,88 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"> | ||
<title>Title</title> | ||
<link rel="stylesheet" type="text/css" href="./style.css"/> | ||
<script src="./kaltura-ovp-player.js" type="text/javascript"></script> | ||
<script src="http://location-for-ima/playkit-ima.js" type="text/javascript"></script> | ||
</head> | ||
<body> | ||
<div id="player-placeholder"></div> | ||
<script> | ||
var config = { | ||
logLevel:'DEBUG', | ||
targetId: 'player-placeholder', | ||
provider: { | ||
partnerId: 1091, | ||
env: { | ||
cdnUrl: "https://qa-apache-php7.dev.kaltura.com/", | ||
serviceUrl: "https://qa-apache-php7.dev.kaltura.com/api_v3" | ||
}, | ||
}, | ||
advertising: { | ||
prebid: { | ||
libUrl: 'https://acdn.adnxs.com/prebid/not-for-prod/3/prebid.js' | ||
}, | ||
adBreaks: [ | ||
{ | ||
position: 0, | ||
ads: [{ | ||
url: ['https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator='], | ||
prebid:{ | ||
adUnit: { | ||
code: 'video1', | ||
mediaTypes: { | ||
video: { | ||
playerSize: [640, 480], | ||
context: 'instream', | ||
mimes: ['video/mp4'], | ||
protocols: [1, 2, 3, 4, 5, 6, 7, 8], | ||
playbackmethod: [2] | ||
} | ||
}, | ||
bids: [{ | ||
bidder: 'appnexus', | ||
params: { | ||
placementId: 13232361, // Add your own placement id here | ||
video: { | ||
skippable: true, | ||
playback_method: ['auto_play_sound_off'] | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
options: { | ||
cache: { | ||
url: 'https://prebid.adnxs.com/pbc/v1/cache' | ||
}, | ||
debug: true, | ||
enableSendAllBids: true, | ||
s2sConfig: { | ||
endpoint: 'http://prebid.adnxs.com/pbs/v1/openrtb2/auction', | ||
enabled: true, | ||
accountId: 'c9d412ee-3cc6-4b66-9326-9f49d528f13e', | ||
bidders: ['appnexus'] | ||
} | ||
} | ||
} | ||
}] | ||
} | ||
] | ||
}, | ||
plugins: { | ||
ima: {} | ||
} | ||
}; | ||
|
||
try { | ||
var kalturaPlayer = KalturaPlayer.setup(config); | ||
kalturaPlayer.loadMedia({entryId: '0_wifqaipd'}); | ||
} catch (e) { | ||
console.error(e.message) | ||
} | ||
</script> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// @flow | ||
import {BaseMiddleware} from '@playkit-js/playkit-js'; | ||
import {AdsController} from '../controllers'; | ||
|
||
/** | ||
* Middleware implementation for ima plugin. | ||
* @class AdLayoutMiddleware | ||
* @param {Ima} context - The ima plugin context. | ||
* @private | ||
*/ | ||
class AdLayoutMiddleware extends BaseMiddleware { | ||
/** | ||
* The id of the ima middleware. | ||
* @type {string} | ||
* @public | ||
* @memberof AdLayoutMiddleware | ||
*/ | ||
id: string = 'AdLayoutMiddleware'; | ||
/** | ||
* The plugin context. | ||
* @member | ||
* @private | ||
* @memberof AdLayoutMiddleware | ||
*/ | ||
_context: AdsController; | ||
|
||
constructor(context: AdsController) { | ||
super(); | ||
this._context = context; | ||
} | ||
|
||
/** | ||
* Load middleware handler. | ||
* @param {Function} next - The load play handler in the middleware chain. | ||
* @returns {void} | ||
* @memberof AdLayoutMiddleware | ||
*/ | ||
load(next: Function): void { | ||
this._context.prerollReady.then(() => this.callNext(next)); | ||
} | ||
|
||
/** | ||
* Play middleware handler. | ||
* @param {Function} next - The next play handler in the middleware chain. | ||
* @returns {void} | ||
* @memberof AdLayoutMiddleware | ||
*/ | ||
play(next: Function): void { | ||
this._context.prerollReady.then(() => this.callNext(next)); | ||
} | ||
} | ||
|
||
export {AdLayoutMiddleware}; |
Oops, something went wrong.