Skip to content

Commit

Permalink
feat(Ads): Add config to allow disable interstitials (#7271)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Sep 6, 2024
1 parent bb78f9f commit 64e45c9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
6 changes: 5 additions & 1 deletion demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,11 @@ shakaDemo.Config = class {
.addBoolInput_('Skip play detection',
'ads.skipPlayDetection')
.addBoolInput_('Supports multiple media elements',
'ads.supportsMultipleMediaElements');
'ads.supportsMultipleMediaElements')
.addBoolInput_('Ignore HLS Interstitial',
'ads.disableHLSInterstitial')
.addBoolInput_('Ignore DASH Interstitial',
'ads.disableDASHInterstitial');
}

/**
Expand Down
12 changes: 11 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,9 @@ shaka.extern.MediaSourceConfiguration;
* @typedef {{
* customPlayheadTracker: boolean,
* skipPlayDetection: boolean,
* supportsMultipleMediaElements: boolean
* supportsMultipleMediaElements: boolean,
* disableHLSInterstitial: boolean,
* disableDASHInterstitial: boolean
* }}
*
* @description
Expand All @@ -1915,6 +1917,14 @@ shaka.extern.MediaSourceConfiguration;
* Defaults to <code>true</code> except on Tizen, WebOS, Chromecast,
* Hisense, PlayStation 4, PlayStation5, Xbox whose default value is
* <code>false</code>.
* @property {boolean} disableHLSInterstitial
* If this is true, we ignore HLS interstitial events.
* <br>
* Defaults to <code>false</code>.
* @property {boolean} disableDASHInterstitial
* If this is true, we ignore DASH interstitial events.
* <br>
* Defaults to <code>false</code>.
*
* @exportDoc
*/
Expand Down
6 changes: 6 additions & 0 deletions lib/ads/ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,9 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
* @export
*/
onHLSInterstitialMetadata(basePlayer, baseVideo, interstitial) {
if (this.config_ && this.config_.disableHLSInterstitial) {
return;
}
if (!this.interstitialAdManager_) {
this.initInterstitial(/* adContainer= */ null, basePlayer, baseVideo);
}
Expand All @@ -837,6 +840,9 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
* @export
*/
onDASHInterstitialMetadata(basePlayer, baseVideo, region) {
if (this.config_ && this.config_.disableDASHInterstitial) {
return;
}
if (region.schemeIdUri != 'urn:mpeg:dash:event:alternativeMPD:2022') {
return;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ shaka.util.PlayerConfiguration = class {
customPlayheadTracker,
skipPlayDetection,
supportsMultipleMediaElements,
disableHLSInterstitial: false,
disableDASHInterstitial: false,
};

const textDisplayer = {
Expand Down

0 comments on commit 64e45c9

Please sign in to comment.