Skip to content

Commit

Permalink
fix(FEC-8842): playlist - item sources config ignored (#211)
Browse files Browse the repository at this point in the history
* config the player with the item sources config before `loadMedia`
* delete empty url  properties (`hls\dash\progressive`) from item sources config, otherwise the empty url property will override the provider's url property
  • Loading branch information
yairans authored Jan 20, 2019
1 parent 7e8359f commit fc73982
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/common/playlist/playlist-item.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
const formats = ['hls', 'dash', 'progressive'];
/**
* @class PlaylistItem
* @param {ProviderMediaConfigSourcesObject} [sources] - The item sources
Expand All @@ -21,11 +22,9 @@ class PlaylistItem {
* @memberof PlaylistItem
*/
updateSources(sourcesObject: ProviderMediaConfigSourcesObject): void {
if (this._sources) {
this._sources.hls = sourcesObject.hls;
this._sources.dash = sourcesObject.dash;
this._sources.progressive = sourcesObject.progressive;
}
formats.forEach(format => {
this._sources && (this._sources[format] = sourcesObject[format]);
});
}

/**
Expand All @@ -35,6 +34,11 @@ class PlaylistItem {
* @memberof PlaylistItem
*/
get sources(): ?ProviderMediaConfigSourcesObject {
formats.forEach(format => {
if (this._sources && this._sources[format] && this._sources[format].length === 0) {
delete this._sources[format];
}
});
return this._sources;
}

Expand All @@ -54,12 +58,9 @@ class PlaylistItem {
* @memberof PlaylistItem
*/
isPlayable(): boolean {
return !!(
this._sources &&
((this._sources.hls && this._sources.hls.length) ||
(this._sources.dash && this._sources.dash.length) ||
(this._sources.progressive && this._sources.progressive.length))
);
return !!formats.find(format => {
return this._sources && this._sources[format] && this._sources[format].length;
});
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/common/playlist/playlist-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ class PlaylistManager {
return Promise.resolve();
} else {
if (this._mediaInfoList[index]) {
this._player.reset();
this._player.configure({
sources: activeItem.sources
});
return this._player.loadMedia(this._mediaInfoList[index]).then(mediaConfig => {
this._playlist.updateItemSources(index, mediaConfig.sources);
this._player.dispatchEvent(new FakeEvent(PlaylistEventType.PLAYLIST_ITEM_CHANGED, {index, activeItem}));
Expand Down

0 comments on commit fc73982

Please sign in to comment.