Skip to content

Commit

Permalink
fix(FEC-11304): missing entryId on plugins (#453)
Browse files Browse the repository at this point in the history
Issue: 
1. sources weren't taken for evaluation - 
`setSources` after configure: evaluator needs the config.source but it didn't update cause `setSources` called after.
`setSources` before `configure`: `sourceSelected` called but `entryId` didn't configure yet.
2. plugin doesn't load correctly from `setMedia` -
plugin config passes throw after sources loaded and then the plugin won't load.
Solution: 
Pass sources config to evaluation so plugin and sources will be loaded correctly.
  • Loading branch information
Yuvalke authored Jun 3, 2021
1 parent f6a414c commit db567aa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/kaltura-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ class KalturaPlayer extends FakeEventTarget {
if (!hasYoutubeSource(sources)) {
this._thumbnailManager = new ThumbnailManager(this._localPlayer, this.config.ui, mediaConfig);
}
this._localPlayer.setSources(sources || {});
this.configure(playerConfig);
this.configure({...playerConfig, sources});
}

/**
Expand Down
24 changes: 24 additions & 0 deletions test/src/kaltura-player.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,30 @@ describe('kaltura player api', function () {
});
});

it('should plugin from setMedia be available after sources selected', () => {
PluginManager.register('numbers', NumbersPlugin);
player.setMedia({sources: SourcesConfig.Mp4, plugins: {numbers: {}}});
(player.plugins.numbers !== undefined).should.be.true;
(player.plugins.numbers !== null).should.be.true;
player.plugins.numbers.should.be.instanceOf(NumbersPlugin);
PluginManager.unRegister('numbers', NumbersPlugin);
});

it('should evaluate the plugin config on source selected', done => {
player.addEventListener(player.Event.SOURCE_SELECTED, () => {
try {
player.plugins.colors.config.entryId.should.equals(entryId);
player.plugins.colors.config.partnerId.should.equals(1091);
player.plugins.colors.config.entryName.should.equals('Vod');
player.plugins.colors.config.entryType.should.equals('custom');
done();
} catch (e) {
done(e);
}
});
player.loadMedia({entryId});
});

it('should evaluate the configured plugin config - second media', done => {
player.loadMedia({entryId}).then(() => {
player.configure({
Expand Down

0 comments on commit db567aa

Please sign in to comment.