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

[DualScreen Plugin]: Add Events (used by kava analytics) #131

Merged
merged 4 commits into from
Mar 12, 2024
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
17 changes: 15 additions & 2 deletions src/dualscreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@ import {ImagePlayer, SlideItem, SlideThumbnail} from './image-player';
import {core, ui, BasePlugin, IEngineDecoratorProvider, KalturaPlayer} from '@playkit-js/kaltura-player-js';
import {OnClickEvent} from '@playkit-js/common/dist/hoc/a11y-wrapper';
import './styles/global.scss';
import {DualscreenEvents} from './events';

const {
reducers: {shell}
} = ui;
const {EventType} = core;
const {EventType, FakeEvent} = core;

const HAS_DUAL_SCREEN_PLUGIN_OVERLAY = 'has-dual-screen-plugin-overlay';
const PRESETS = ['Playback', 'Live', 'Ads'];
const IMAGE_PLAYER_ID = 'imagePlayer';
const MAIN_PLAYER_ID = 'mainPlayer';

export class DualScreen extends BasePlugin<DualScreenConfig> implements IEngineDecoratorProvider {
private _layout: Layout;
private layout!: Layout;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question = why do you need the "!", since layout can be null/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can’t be null, it is assigned on the constructor, so it is never = null

private _externalLayout: ExternalLayout | null = null;
private _pipPosition: Position = Position.BottomRight;
private _removeActivesArr: Function[] = [];
Expand Down Expand Up @@ -85,6 +86,18 @@ export class DualScreen extends BasePlugin<DualScreenConfig> implements IEngineD
return new DualScreenEngineDecorator(engine, this, dispatcher);
}

set _layout(layout: Layout) {
if (layout !== this.layout) {
this.layout = layout;
// @ts-expect-error - TS2339: Property 'dispatchEvent' does not exist on type 'KalturaPlayer'
MosheMaorKaltura marked this conversation as resolved.
Show resolved Hide resolved
this.player.dispatchEvent(new FakeEvent(DualscreenEvents.CHANGE_LAYOUT, {layout}));
}
}

get _layout(): Layout {
return this.layout;
}

get ready() {
return this._readyPromise;
}
Expand Down
9 changes: 9 additions & 0 deletions src/events/events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* dualscreen plugin event types.
*/
export const DualscreenEvents = {
/**
* Fired when dual-screen mode chances.
*/
CHANGE_LAYOUT: 'dualscreen_change_layout',
};
2 changes: 2 additions & 0 deletions src/events/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import {DualscreenEvents} from './events';
export {DualscreenEvents};
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference path="./global.d.ts" />

import {DualScreen} from './dualscreen';
import {DualscreenEvents} from './events';

declare var __VERSION__: string;
declare var __NAME__: string;
Expand All @@ -10,6 +11,7 @@ const NAME = __NAME__;

export {DualScreen as Plugin};
export {VERSION, NAME};
export {DualscreenEvents};

const pluginName: string = 'dualscreen';
KalturaPlayer.core.registerPlugin(pluginName, DualScreen);
Loading