From 65994c4ebf387a584c52371d1757a9dd960ba9cb Mon Sep 17 00:00:00 2001 From: Anthony Date: Tue, 5 Oct 2021 20:04:41 +0300 Subject: [PATCH] re enable preload ads --- ui/component/app/view.jsx | 24 +++++----- .../plugins/videojs-aniview/plugin.js | 48 +++++++++---------- .../viewers/videoViewer/internal/videojs.jsx | 4 +- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/ui/component/app/view.jsx b/ui/component/app/view.jsx index 00505e48a..8e4fdc1e6 100644 --- a/ui/component/app/view.jsx +++ b/ui/component/app/view.jsx @@ -327,19 +327,17 @@ function App(props: Props) { // Load IMA3 SDK for aniview: DISABLED FOR NOW // @if TARGET='web' - // useEffect(() => { - // if (ENABLE_PREROLL_ADS) { - // const script = document.createElement('script'); - // script.src = `https://imasdk.googleapis.com/js/sdkloader/ima3.js`; - // script.async = true; - // // $FlowFixMe - // document.body.appendChild(script); - // return () => { - // // $FlowFixMe - // document.body.removeChild(script); - // }; - // } - // }); + useEffect(() => { + const script = document.createElement('script'); + script.src = `https://imasdk.googleapis.com/js/sdkloader/ima3.js`; + script.async = true; + // $FlowFixMe + document.body.appendChild(script); + return () => { + // $FlowFixMe + document.body.removeChild(script); + }; + }); // @endif // @if TARGET='app' diff --git a/ui/component/viewers/videoViewer/internal/plugins/videojs-aniview/plugin.js b/ui/component/viewers/videoViewer/internal/plugins/videojs-aniview/plugin.js index 0dcdc20be..b61c7a991 100644 --- a/ui/component/viewers/videoViewer/internal/plugins/videojs-aniview/plugin.js +++ b/ui/component/viewers/videoViewer/internal/plugins/videojs-aniview/plugin.js @@ -26,27 +26,27 @@ const VERSION = '0.0.1'; * */ // TEST PRE-ROLL WITH THIS TAG: -// https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpreonly&cmsid=496&vid=short_onecue&correlator= +const macroUrl = 'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpreonly&cmsid=496&vid=short_onecue&correlator='; // Modified to work with IMA -const macroUrl = - `https://vast.aniview.com/api/adserver61/vast/` + - `?AV_PUBLISHERID=60afcbc58cfdb065440d2426` + - `&AV_CHANNELID=60b354389c7adb506d0bd9a4` + - `&AV_URL=[URL]` + - `&cb=[CACHEBUSTING]` + - `&AV_WIDTH=[WIDTH]` + - `&AV_HEIGHT=[HEIGHT]` + - // `&AV_SCHAIN=[SCHAIN_MACRO]` + - // `&AV_CCPA=[CCPA_MACRO]` + - // `&AV_GDPR=[GDPR_MACRO]` + - // `&AV_CONSENT=[CONSENT_MACRO]` + - `&skip=true` + - `&skiptimer=5` + - `&logo=true` + - `&usevslot=true` + - `&vastretry=5` + - `&hidecontrols=false`; +// const macroUrl = +// `https://vast.aniview.com/api/adserver61/vast/` + +// `?AV_PUBLISHERID=60afcbc58cfdb065440d2426` + +// `&AV_CHANNELID=60b354389c7adb506d0bd9a4` + +// `&AV_URL=[URL]` + +// `&cb=[CACHEBUSTING]` + +// `&AV_WIDTH=[WIDTH]` + +// `&AV_HEIGHT=[HEIGHT]` + +// // `&AV_SCHAIN=[SCHAIN_MACRO]` + +// // `&AV_CCPA=[CCPA_MACRO]` + +// // `&AV_GDPR=[GDPR_MACRO]` + +// // `&AV_CONSENT=[CONSENT_MACRO]` + +// `&skip=true` + +// `&skiptimer=5` + +// `&logo=true` + +// `&usevslot=true` + +// `&vastretry=5` + +// `&hidecontrols=false`; const defaults = { adTagUrl: macroUrl, @@ -69,16 +69,16 @@ class AniviewPlugin extends Component { this.player = player; // request ads whenever there's new video content - /* player.on('contentchanged', () => { + player.on('contentchanged', () => { // in a real plugin, you might fetch your ad inventory here player.trigger('adsready'); - }); */ + }); // Plugin event listeners - // player.on('readyforpreroll', (event) => this.onReadyForPreroll(event)); + player.on('readyforpreroll', (event) => this.onReadyForPreroll(event)); } - /* onReadyForPreroll(event) { + onReadyForPreroll(event) { // send event when ad is playing to remove loading spinner this.player.one('adplaying', () => { this.player.trigger('ads-ad-started'); @@ -88,7 +88,7 @@ class AniviewPlugin extends Component { this.player.one('adended', () => { this.player.ads.endLinearAdMode(); }); - } */ + } log(...args) { if (this.options_.debug) { diff --git a/ui/component/viewers/videoViewer/internal/videojs.jsx b/ui/component/viewers/videoViewer/internal/videojs.jsx index bac5fb9ba..5cf8a5d56 100644 --- a/ui/component/viewers/videoViewer/internal/videojs.jsx +++ b/ui/component/viewers/videoViewer/internal/videojs.jsx @@ -16,7 +16,7 @@ import qualityLevels from 'videojs-contrib-quality-levels'; import isUserTyping from 'util/detect-typing'; // @if TARGET='web' // Disabled for now. -// import './plugins/videojs-aniview/plugin'; +import './plugins/videojs-aniview/plugin'; // @endif const isDev = process.env.NODE_ENV !== 'production'; @@ -580,6 +580,8 @@ export default React.memo(function VideoJs(props: Props) { // I think this is a callback function const videoNode = containerRef.current && containerRef.current.querySelector('video, audio'); onPlayerReady(player, videoNode); + + vjs.aniview(); }); // pre-roll ads