From 81b5db25c0f2fcb156f65ca6c28763901b151ebc Mon Sep 17 00:00:00 2001 From: Simon Gingras Date: Tue, 28 Feb 2023 09:39:20 -0500 Subject: [PATCH 1/3] feat: Dispatch a player event for client-side ad errors --- lib/ads/ad_manager.js | 7 +++++++ lib/ads/client_side_ad_manager.js | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/lib/ads/ad_manager.js b/lib/ads/ad_manager.js index 920ac303df..3ee8c411d9 100644 --- a/lib/ads/ad_manager.js +++ b/lib/ads/ad_manager.js @@ -902,6 +902,13 @@ shaka.ads.AdManager.AD_METADATA = 'ad-metadata'; */ shaka.ads.AdManager.AD_RECOVERABLE_ERROR = 'ad-recoverable-error'; +/** + * The event name for when the ad manager dispatch errors. + * + * @const {string} + * @export + */ +shaka.ads.AdManager.AD_ERROR = 'ad-error'; /** * The event name for when the client side SDK signalled its readiness diff --git a/lib/ads/client_side_ad_manager.js b/lib/ads/client_side_ad_manager.js index 2a35e2c5b8..718acc0e63 100644 --- a/lib/ads/client_side_ad_manager.js +++ b/lib/ads/client_side_ad_manager.js @@ -133,6 +133,10 @@ shaka.ads.ClientSideAdManager = class { shaka.log.warning( 'There was an ad error from the IMA SDK: ' + e.getError()); shaka.log.warning('Resuming playback.'); + + const data = (new Map()).set('originalEvent', e); + this.onEvent_(new shaka.util.FakeEvent(shaka.ads.AdManager.AD_ERROR, data)); + this.onAdComplete_(/* adEvent= */ null); // Remove ad breaks from the timeline this.onEvent_( From 4bf3b701e2c878cdba1b5d864ac39da8ebe54500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Wed, 1 Mar 2023 13:35:14 +0100 Subject: [PATCH 2/3] Add JSDoc --- lib/ads/ad_manager.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/ads/ad_manager.js b/lib/ads/ad_manager.js index 3ee8c411d9..dd67c755b8 100644 --- a/lib/ads/ad_manager.js +++ b/lib/ads/ad_manager.js @@ -314,6 +314,17 @@ goog.require('shaka.util.IReleasable'); */ +/** + * @event shaka.ads.AdManager.AD_ERROR + * @description Fired when the a fatal error was encountered. + * @property {string} type + * 'ad-error' + * @property {Object} originalEvent + * The native SDK event, if available. + * @exportDoc + */ + + /** * @event shaka.ads.AdManager.AdInteractionEvent * @description Fired when an ad triggers the interaction callback. From fa5a18feaffc40530d8e9f94d4d190fd78d0cb6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Wed, 1 Mar 2023 14:00:16 +0100 Subject: [PATCH 3/3] Update lib/ads/ad_manager.js Co-authored-by: Simon Gingras --- lib/ads/ad_manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ads/ad_manager.js b/lib/ads/ad_manager.js index dd67c755b8..b0742b1ef9 100644 --- a/lib/ads/ad_manager.js +++ b/lib/ads/ad_manager.js @@ -316,7 +316,7 @@ goog.require('shaka.util.IReleasable'); /** * @event shaka.ads.AdManager.AD_ERROR - * @description Fired when the a fatal error was encountered. + * @description Fired when a fatal error is encountered. * @property {string} type * 'ad-error' * @property {Object} originalEvent