Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ads): Dispatch a player event for client-side ad errors #5045

Merged
merged 3 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/ads/ad_manager.js
Original file line number Diff line number Diff line change
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';
joeyparrish marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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
Original file line number Diff line number Diff line change
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