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

fix(FEC-14071): thumbnail requests append height, width, ks too many times #830

Merged
merged 6 commits into from
Aug 11, 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@playkit-js/playkit-js": "0.84.12",
"@playkit-js/playkit-js-dash": "1.37.0",
"@playkit-js/playkit-js-hls": "1.32.13",
"@playkit-js/playkit-js-providers": "2.40.7",
"@playkit-js/playkit-js-providers": "2.40.8-canary.0-932a336",
"@playkit-js/playkit-js-ui": "0.79.7-canary.0-c033fbe",
"hls.js": "^1.5.8",
"shaka-player": "4.8.11"
Expand Down
6 changes: 3 additions & 3 deletions src/common/thumbnail-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ class ThumbnailManager {

private _buildKalturaThumbnailConfig = (uiConfig: UiConfig, mediaConfig: KPMediaConfig): KPThumbnailConfig => {
const seekbarConfig = Utils.Object.getPropertyPath(uiConfig, 'components.seekbar');
const posterUrl = mediaConfig.sources && mediaConfig.sources.poster;
const isVod = mediaConfig.sources && mediaConfig.sources.type === MediaType.VOD;
const rawThumbnailUrl = mediaConfig.sources?.rawThumbnailUrl;
const isVod = mediaConfig.sources?.type === MediaType.VOD;
const ks = this._player.shouldAddKs(mediaConfig) ? mediaConfig.session?.ks : '';
const thumbnailConfig = Utils.Object.mergeDeep(DefaultThumbnailConfig, seekbarConfig);
const thumbsSprite = isVod ? this._getThumbSlicesUrl(posterUrl, ks, thumbnailConfig) : '';
const thumbsSprite = isVod ? this._getThumbSlicesUrl(rawThumbnailUrl, ks, thumbnailConfig) : '';
return {
thumbsSprite,
...thumbnailConfig
Expand Down
10 changes: 8 additions & 2 deletions src/ovp/poster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ function addKalturaPoster(
const mediaConfigPoster = mediaSources.poster;
const playerWidth = dimensions.width;
const playerHeight = dimensions.height;
if (typeof playerPoster === 'string' && THUMBNAIL_REGEX.test(playerPoster) && playerPoster === mediaConfigPoster) {
playerSources.poster = `${playerPoster}/height/${playerHeight}/width/${playerWidth}${ks ? `/ks/${ks}` : ''}`;
const rawThumbnailUrl = mediaSources.rawThumbnailUrl;
if (
typeof playerPoster === 'string' &&
THUMBNAIL_REGEX.test(playerPoster) &&
playerPoster === mediaConfigPoster &&
typeof rawThumbnailUrl === 'string'
) {
playerSources.poster = `${rawThumbnailUrl}/height/${playerHeight}/width/${playerWidth}${ks ? `/ks/${ks}` : ''}`;
}
mediaSources.poster = playerSources.poster || '';
}
Expand Down
7 changes: 4 additions & 3 deletions tests/e2e/common/thumbnail-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('ThumbnailManager', () => {
fakeMediaConfig = {
sources: {
poster: '//my-thumb-service.com/p/1/thumbnail/entry_id/2/version/3',
rawThumbnailUrl: '//my-thumb-service.com/p/1/thumbnail/entry_id/2/version/3',
type: MediaType.VOD
},
session: {
Expand Down Expand Up @@ -69,13 +70,13 @@ describe('ThumbnailManager', () => {
});

it('should get empty thumbnail slices url for non string given', () => {
fakeMediaConfig.sources.poster = null;
fakeMediaConfig.sources.rawThumbnailUrl = null;
thumbnailManager = new ThumbnailManager(fakePlayer, fakePlayer.config.ui, fakeMediaConfig);
thumbnailManager.getKalturaThumbnailConfig().thumbsSprite.should.equals('');
});

it('should get empty thumbnail slices url for non valid string given', () => {
fakeMediaConfig.sources.poster = '//my-thumb-service.com/p/1/entry_id/2/version/3';
fakeMediaConfig.sources.rawThumbnailUrl = '//my-thumb-service.com/p/1/entry_id/2/version/3';
thumbnailManager = new ThumbnailManager(fakePlayer, fakePlayer.config.ui, fakeMediaConfig);
thumbnailManager.getKalturaThumbnailConfig().thumbsSprite.should.equals('');
});
Expand All @@ -100,7 +101,7 @@ describe('ThumbnailManager', () => {
});

it('should return thumbnail from core player', () => {
fakeMediaConfig.sources.poster = null;
fakeMediaConfig.sources.rawThumbnailUrl = null;
thumbnailManager = new ThumbnailManager(fakePlayer, fakePlayer.config.ui, fakeMediaConfig);
const spy = sandbox.spy(fakePlayer._localPlayer, 'getThumbnail');
thumbnailManager.getThumbnail(100);
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/ovp/poster.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const targetId = 'player-placeholder_ovp/poster.spec';

describe('addKalturaPoster', () => {
it('should append width and height to kaltura poster', () => {
const mediaSources = { poster: '/p/1091/thumbnail/entry_id/0_wifqaipd/2' };
const mediaSources = { poster: '/p/1091/thumbnail/entry_id/0_wifqaipd/2', rawThumbnailUrl: '/p/1091/thumbnail/entry_id/0_wifqaipd/2' };
const playerSources = { poster: '/p/1091/thumbnail/entry_id/0_wifqaipd/2' };
addKalturaPoster(playerSources, mediaSources, { width: 640, height: 360 });
playerSources.poster.should.equal('/p/1091/thumbnail/entry_id/0_wifqaipd/2/height/360/width/640');
Expand Down Expand Up @@ -44,7 +44,7 @@ describe('addKalturaPoster', () => {
});

it('should append ks to kaltura poster', () => {
const mediaSources = { poster: '/p/1091/thumbnail/entry_id/0_wifqaipd/2' };
const mediaSources = { poster: '/p/1091/thumbnail/entry_id/0_wifqaipd/2', rawThumbnailUrl: '/p/1091/thumbnail/entry_id/0_wifqaipd/2' };
const playerSources = { poster: '/p/1091/thumbnail/entry_id/0_wifqaipd/2' };
const ks = '123';
addKalturaPoster(playerSources, mediaSources, { width: 640, height: 360 }, ks);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1182,10 +1182,10 @@
resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-hls/-/playkit-js-hls-1.32.13.tgz#d0c9f42f9055b6a454aa1e2a42a8bf6610c43087"
integrity sha512-d16JZrJBXqXwTyY0PRuiO2XpxjIW6QnYw1/PpipWr/IMpC8dVRhjvpz9rARbs5sM4C5QSLZS6rGBwWK+DbRIRg==

"@playkit-js/playkit-js-providers@2.40.7":
version "2.40.7"
resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-providers/-/playkit-js-providers-2.40.7.tgz#10e160ad100518aac2b289625e634e6e712eb73d"
integrity sha512-mamM+PloRxizoceIZgyDzbgb1BZbQXPb8pMrFMd/q+CkpE/bfkwwljytFZEz1j3OBi7DgRM1uL+wyFIQdxHqxQ==
"@playkit-js/playkit-js-providers@2.40.8-canary.0-932a336":
version "2.40.8-canary.0-932a336"
resolved "https://registry.yarnpkg.com/@playkit-js/playkit-js-providers/-/playkit-js-providers-2.40.8-canary.0-932a336.tgz#23d32e72a45e86403ed19ba8fd90d664178672da"
integrity sha512-0XBbzGqHjJQHYTXh1omS6lfMAy69rBe9PvK0lSznEvcMhRPLq4cTBfJ3EMpCxknb5fGRvtfDdbUHoktqurshQA==

"@playkit-js/playkit-js-ui@0.79.7-canary.0-c033fbe":
version "0.79.7-canary.0-c033fbe"
Expand Down
Loading