Skip to content

Commit

Permalink
fix(FEC-13583): [Click 2 Action] | The video is still playing sometim…
Browse files Browse the repository at this point in the history
…es behind CTA overlay.
  • Loading branch information
SivanA-Kaltura committed Dec 20, 2023
2 parents 4787641 + dbce8f0 commit 9a073b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/call-to-action-manager.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {KalturaPlayer, ui} from '@playkit-js/kaltura-player-js';
import {KalturaPlayer, ui, PlaykitUI} from '@playkit-js/kaltura-player-js';
const {PLAYER_SIZE} = ui.Components;

import {FloatingItem, FloatingManager} from '@playkit-js/ui-managers';
Expand All @@ -17,11 +17,18 @@ class CallToActionManager {
private popupInstance: FloatingItem | null = null;
private floatingManager: FloatingManager;
private hideMessageTimeout = -1;
private playQueued = false;

constructor(player: KalturaPlayer, floatingManager: FloatingManager) {
constructor(player: KalturaPlayer, floatingManager: FloatingManager, eventManager: PlaykitUI.EventManager) {
this.player = player;
this.store = ui.redux.useStore();
this.floatingManager = floatingManager;
eventManager.listen(player, this.player.Event.Core.PLAYING, () => {
this.playQueued = false;
if (this.removeActiveOverlay) {
this.player.pause();
}
});
}

private showPopup({
Expand Down Expand Up @@ -60,7 +67,7 @@ class CallToActionManager {
}

private showOverlay(message: MessageData, descriptionLines: number, onClose?: () => void) {
if (!this.player.paused) {
if (!this.player.paused || this.playQueued) {
this.player.pause();
this.playOnClose = true;
}
Expand Down Expand Up @@ -103,6 +110,7 @@ class CallToActionManager {
private onOverlayCloseClick() {
this.removeOverlay();
if (this.playOnClose) {
this.playQueued = true;
this.player.play();
this.playOnClose = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/call-to-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CallToAction extends BasePlugin<CallToActionConfig> {

constructor(name: string, player: KalturaPlayer, config: CallToActionConfig) {
super(name, player, config);
this.callToActionManager = new CallToActionManager(player, this.floatingManager);
this.callToActionManager = new CallToActionManager(player, this.floatingManager, this.eventManager);
}

static isValid() {
Expand Down

0 comments on commit 9a073b7

Please sign in to comment.