Skip to content

Commit

Permalink
fix(FEC-8298): SOURCE_SELECTED event triggered before the UI ready wh…
Browse files Browse the repository at this point in the history
…en the source provided manually (#129)

postpone the `sources` config after the ui initialization
  • Loading branch information
yairans committed Jan 24, 2019
1 parent 0756aed commit 44e8fb5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/kaltura-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ class KalturaPlayer extends FakeEventTarget {
constructor(options: KPOptionsObject) {
super();
this._eventManager = new EventManager();
this._localPlayer = loadPlayer(options);
const {sources} = options;
const noSourcesOptions = Utils.Object.mergeDeep({}, options, {sources: null});
this._localPlayer = loadPlayer(noSourcesOptions);
this._logger = getLogger('KalturaPlayer' + Utils.Generator.uniqueId(5));
this._uiWrapper = new UIWrapper(this, options);
this._provider = new Provider(options.provider, __VERSION__);
this._playlistManager = new PlaylistManager(this, options);
this._playlistManager.configure(options.playlist);
Object.values(CoreEventType).forEach(coreEvent => this._eventManager.listen(this._localPlayer, coreEvent, e => this.dispatchEvent(e)));
this._localPlayer.configure({sources});
}

loadMedia(mediaInfo: ProviderMediaInfoObject): Promise<*> {
Expand Down
19 changes: 19 additions & 0 deletions test/src/setup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,23 @@ describe('setup', function() {
kalturaPlayer = setup(config);
kalturaPlayer.textStyle.should.deep.equal(textStyle);
});

it('should configure sources', function(done) {
const url = 'http://cfvod.kaltura.com/pd/p/2196781/sp/219678100/serveFlavor/entryId/1_afvj3z0u/v/1/flavorId/1_vpmhfzgl/name/a.mp4';
config.sources = {
progressive: [
{
id: 'id',
mimetype: 'video/mp4',
url
}
]
};
kalturaPlayer = setup(config);
kalturaPlayer.load();
kalturaPlayer.ready().then(() => {
kalturaPlayer.src.should.equal(url);
done();
});
});
});

0 comments on commit 44e8fb5

Please sign in to comment.