Skip to content

Commit

Permalink
feat(ads): Dispatch a player event for client-side ad errors (shaka-p…
Browse files Browse the repository at this point in the history
…roject#5045)

Closes shaka-project#4335

The errors are now forwarded to the player

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
  • Loading branch information
gingman and avelad committed Mar 2, 2023
1 parent 2ae5a99 commit 673b7fc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/ads/ad_manager.js
Expand Up @@ -314,6 +314,17 @@ goog.require('shaka.util.IReleasable');
*/


/**
* @event shaka.ads.AdManager.AD_ERROR
* @description Fired when a fatal error is 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.
Expand Down Expand Up @@ -902,6 +913,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
Expand Down
4 changes: 4 additions & 0 deletions lib/ads/client_side_ad_manager.js
Expand Up @@ -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_(
Expand Down

0 comments on commit 673b7fc

Please sign in to comment.