Skip to content

Commit

Permalink
feat(Ads): Expose the interstitial player (#7793)
Browse files Browse the repository at this point in the history
Close #7763
  • Loading branch information
avelad authored Dec 23, 2024
1 parent 6abdec4 commit 6783ce0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
5 changes: 5 additions & 0 deletions externs/shaka/ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ shaka.extern.IAdManager = class extends EventTarget {
* @return {!Promise}
*/
addAdUrlInterstitial(url) {}

/**
* @return {shaka.Player}
*/
getInterstitialPlayer() {}
};


Expand Down
14 changes: 14 additions & 0 deletions lib/ads/ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,20 @@ shaka.ads.AdManager = class extends shaka.util.FakeEventTarget {
return this.interstitialAdManager_.addAdUrlInterstitial(url);
}

/**
* @override
* @export
*/
getInterstitialPlayer() {
if (!this.interstitialAdManager_) {
throw new shaka.util.Error(
shaka.util.Error.Severity.RECOVERABLE,
shaka.util.Error.Category.ADS,
shaka.util.Error.Code.INTERSTITIAL_AD_MANAGER_NOT_INITIALIZED);
}
return this.interstitialAdManager_.getPlayer();
}

/**
* @param {!shaka.util.FakeEvent} event
* @private
Expand Down
8 changes: 6 additions & 2 deletions lib/ads/interstitial_ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ shaka.ads.InterstitialAdManager = class {
this.player_.destroy();
}

/**
* @return {shaka.Player}
*/
getPlayer() {
return this.player_;
}

/**
* @param {shaka.extern.HLSInterstitial} hlsInterstitial
Expand Down Expand Up @@ -1352,8 +1358,6 @@ shaka.ads.InterstitialAdManager = class {
this.player_.configure('ads.disableDASHInterstitial', true);
const netEngine = this.player_.getNetworkingEngine();
goog.asserts.assert(netEngine, 'Need networking engine');
netEngine.clearAllRequestFilters();
netEngine.clearAllResponseFilters();
this.basePlayer_.getNetworkingEngine().copyFiltersInto(netEngine);
}

Expand Down
3 changes: 3 additions & 0 deletions test/test/util/fake_ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ shaka.test.FakeAdManager = class extends shaka.util.FakeEventTarget {
/** @override */
addAdUrlInterstitial(url) {}

/** @override */
getInterstitialPlayer() {}

/**
* @param {!shaka.test.FakeAd} ad
*/
Expand Down

0 comments on commit 6783ce0

Please sign in to comment.