Skip to content

Commit

Permalink
feat(ott-provider): retrieve poster from ott backend (#43)
Browse files Browse the repository at this point in the history
OTT backend does not have in his response single poster URL value, but an array of images.
I'm checking if this array exists and in case it does, I'm parsing his first url and removing the width and height values (the player handles it according to his size in kaltura player).
  • Loading branch information
Dan Ziv authored Mar 12, 2018
1 parent bfefd09 commit bdd5da1
Show file tree
Hide file tree
Showing 10 changed files with 9,401 additions and 30 deletions.
1,058 changes: 1,053 additions & 5 deletions dist/playkit-bookmark-service.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/playkit-bookmark-service.js.map

Large diffs are not rendered by default.

3,087 changes: 3,082 additions & 5 deletions dist/playkit-ott-provider.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/playkit-ott-provider.js.map

Large diffs are not rendered by default.

3,761 changes: 3,756 additions & 5 deletions dist/playkit-ovp-provider.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/playkit-ovp-provider.js.map

Large diffs are not rendered by default.

1,112 changes: 1,107 additions & 5 deletions dist/playkit-stats-service.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/playkit-stats-service.js.map

Large diffs are not rendered by default.

28 changes: 25 additions & 3 deletions src/k-provider/ott/provider-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ export default class OTTProviderParser extends BaseProviderParser {
const playbackContext = assetResponse.playBackContextResult;
const mediaAsset = assetResponse.mediaDataResult;
const kalturaSources = playbackContext.sources;
mediaEntry.name = mediaAsset.name;
mediaEntry.id = mediaAsset.id;
const metaData = {description: mediaAsset.description};
const metaData = {};
metaData.description = mediaAsset.description;
metaData.poster = OTTProviderParser._getPoster(mediaAsset.pictures);
Object.assign(metaData, mediaAsset.metas);
Object.assign(metaData, mediaAsset.tags);
mediaEntry.name = mediaAsset.name;
mediaEntry.id = mediaAsset.id;
mediaEntry.metadata = metaData;
const filteredKalturaSources = OTTProviderParser._filterSourcesByFormats(kalturaSources, requestData.formats);
mediaEntry.sources = OTTProviderParser._getParsedSources(filteredKalturaSources);
Expand All @@ -64,6 +66,26 @@ export default class OTTProviderParser extends BaseProviderParser {
return mediaEntry;
}

/**
* Gets the poster url without width and height.
* @param {Array<Object>} pictures - Media pictures.
* @returns {string | Array<Object>} - Poster base url or array of poster candidates.
* @private
*/
static _getPoster(pictures: Array<Object>): string | Array<Object> {
if (pictures && pictures.length > 0) {
const picObj = pictures[0];
const url = picObj.url;
// Search for thumbnail service
const regex = /.*\/thumbnail\/.*(?:width|height)\/\d+\/(?:height|width)\/\d+/;
if (regex.test(url)) {
return url;
}
return pictures.map(pic => ({url: pic.url, width: pic.width, height: pic.height}));
}
return '';
}

/**
* Gets the media type (LIVE/VOD)
* @param {Object} mediaAssetData - The media asset data.
Expand Down
377 changes: 374 additions & 3 deletions test/src/k-provider/ott/media-config-data.js

Large diffs are not rendered by default.

0 comments on commit bdd5da1

Please sign in to comment.