Skip to content

Commit

Permalink
feat(FEC-10041): playAdsWithMSE with DAI detach the playback and ad (#…
Browse files Browse the repository at this point in the history
…408)

Issue: ad and playback have the same content URI.
Solution: check if ads are imadai and exclude the logic for attaching detach.
  • Loading branch information
Yuvalke authored Feb 4, 2021
1 parent 2b9dd50 commit d7b5e09
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
"dependencies": {
"@babel/polyfill": "^7.0.0",
"@playkit-js/playkit-js": "0.67.0",
"@playkit-js/playkit-js": "0.68.0-canary.c6b4a44",
"@playkit-js/playkit-js-dash": "1.21.2",
"@playkit-js/playkit-js-hls": "1.23.0",
"@playkit-js/playkit-js-ui": "0.63.0",
Expand Down
14 changes: 13 additions & 1 deletion src/common/ads/ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Ad {
_height: number;
_bitrate: number;
_bumper: boolean;
_inStream: boolean;

constructor(id: string, options: PKAdOptions) {
this._id = id;
Expand All @@ -38,6 +39,7 @@ class Ad {
this._height = options.height || 0;
this._bitrate = options.bitrate || 0;
this._bumper = options.bumper;
this._inStream = options.inStream || false;
}

/**
Expand Down Expand Up @@ -175,6 +177,15 @@ class Ad {
return this._bumper;
}

/**
* @instance
* @memberof Ad
* @return {boolean} - Whether the ad is imadai.
*/
get inStream(): boolean {
return this._inStream;
}

/**
* @instance
* @memberof Ad
Expand All @@ -201,7 +212,8 @@ class Ad {
width: this.width,
height: this.height,
bitrate: this.bitrate,
bumper: this.bumper
bumper: this.bumper,
inStream: this.inStream
};
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/common/utils/setup-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,8 @@ function checkNativeTextTracksSupport(options: KPOptionsObject): void {
*/
function _configureAdsWithMSE(options: KPOptionsObject): void {
const playAdsWithMSE = Utils.Object.getPropertyPath(options, 'playback.playAdsWithMSE');
//dai should play without playAdsWithMSE config
if (typeof playAdsWithMSE !== 'boolean') {
if (options.plugins && options.plugins.imadai && !options.plugins.imadai.disable) {
options = Utils.Object.createPropertyPath(options, 'playback.playAdsWithMSE', false);
} else {
options = Utils.Object.createPropertyPath(options, 'playback.playAdsWithMSE', true);
}
options = Utils.Object.createPropertyPath(options, 'playback.playAdsWithMSE', true);
}
const disableMediaPreloadIma = Utils.Object.getPropertyPath(options, 'plugins.ima.disableMediaPreload');
const disableMediaPreloadBumper = Utils.Object.getPropertyPath(options, 'plugins.bumper.disableMediaPreload');
Expand Down
15 changes: 11 additions & 4 deletions src/kaltura-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class KalturaPlayer extends FakeEventTarget {
_controllerProvider: ControllerProvider;
_adsController: ?AdsController;
_eventManager: EventManager = new EventManager();
_attachEventManager: EventManager;
_mediaInfo: ?ProviderMediaInfoObject = null;
_remotePlayer: ?BaseRemotePlayer = null;
_pluginManager: PluginManager = new PluginManager();
Expand Down Expand Up @@ -291,6 +292,9 @@ class KalturaPlayer extends FakeEventTarget {
if (!this._reset) {
this._reset = true;
this._firstPlay = true;
if (this._attachEventManager) {
this._attachEventManager.removeAll();
}
this._uiWrapper.reset();
this._resetProviderPluginsConfig();
this._pluginManager.reset();
Expand Down Expand Up @@ -669,16 +673,19 @@ class KalturaPlayer extends FakeEventTarget {
this._eventManager.listen(this, AdEventType.AD_AUTOPLAY_FAILED, (event: FakeEvent) => this._onAdAutoplayFailed(event));
this._eventManager.listen(this, AdEventType.AD_STARTED, () => this._onAdStarted());
if (this.config.playback.playAdsWithMSE) {
this._attachEventManager = new EventManager();
this._eventManager.listen(this, AdEventType.AD_LOADED, (event: FakeEvent) => {
const {
payload: {ad}
} = event;
if (ad && ad.linear && ad.position === 1) {
this._eventManager.listenOnce(this, AdEventType.AD_BREAK_START, () => this._detachMediaSource());
if (ad && ad.linear && ad.position === 1 && !ad.inStream) {
this._attachEventManager.listenOnce(this, AdEventType.AD_BREAK_START, () => this._detachMediaSource());
this._attachEventManager.listenOnce(this, AdEventType.AD_BREAK_END, () => this._attachMediaSource());
this._attachEventManager.listenOnce(this, AdEventType.AD_ERROR, () => this._attachMediaSource());
} else {
this._attachEventManager.removeAll();
}
});
this._eventManager.listen(this, AdEventType.AD_BREAK_END, () => this._attachMediaSource());
this._eventManager.listen(this, AdEventType.AD_ERROR, () => this._attachMediaSource());
}
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1150,10 +1150,10 @@
react-redux "^7.2.0"
redux "^4.0.5"

"@playkit-js/playkit-js@0.67.0":
version "0.67.0"
resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js/-/playkit-js-0.67.0.tgz#ec9367e9e2a0b19c6bdd7f65bf228d78c7c5845a"
integrity sha512-KOyREQn70tcH7frXgVQ4nUbQddVvDG7Kk1tI6wnhGoiwnm77REXDmktqSzSEEWixTeeFH1Qe53PZk/EUJXmAZQ==
"@playkit-js/playkit-js@0.68.0-canary.c6b4a44":
version "0.68.0-canary.c6b4a44"
resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js/-/playkit-js-0.68.0-canary.c6b4a44.tgz#51e2e49bdb385eeaadcd4112ba9e36096c3f5e08"
integrity sha512-gD78eq/AXdXgH4rmOyk49SJGJRwMAJUGQWDFDc88vVw45y/KieNp0CSSjHZFZk9oLZx+Ut+2ZnNhkhEVD50vnA==
dependencies:
js-logger "^1.6.0"
ua-parser-js "^0.7.21"
Expand Down

0 comments on commit d7b5e09

Please sign in to comment.