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 1 commit
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
4 changes: 2 additions & 2 deletions src/common/thumbnail-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@

private _buildKalturaThumbnailConfig = (uiConfig: UiConfig, mediaConfig: KPMediaConfig): KPThumbnailConfig => {
const seekbarConfig = Utils.Object.getPropertyPath(uiConfig, 'components.seekbar');
const posterUrl = mediaConfig.sources && mediaConfig.sources.poster;
const rawThumbnailUrl = mediaConfig.sources && mediaConfig.sources.rawThumbnailUrl;

Check failure on line 74 in src/common/thumbnail-manager.ts

View workflow job for this annotation

GitHub Actions / build-types / running-tests (ubuntu-latest)

Property 'rawThumbnailUrl' does not exist on type 'ProviderMediaConfigSourcesObject'.

Check failure on line 74 in src/common/thumbnail-manager.ts

View workflow job for this annotation

GitHub Actions / build / running-tests (ubuntu-latest)

Property 'rawThumbnailUrl' does not exist on type 'ProviderMediaConfigSourcesObject'.

Check failure on line 74 in src/common/thumbnail-manager.ts

View workflow job for this annotation

GitHub Actions / type-check / running-tests (ubuntu-latest)

Property 'rawThumbnailUrl' does not exist on type 'ProviderMediaConfigSourcesObject'.
lianbenjamin marked this conversation as resolved.
Show resolved Hide resolved
const isVod = mediaConfig.sources && 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
3 changes: 2 additions & 1 deletion src/ovp/poster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
const playerWidth = dimensions.width;
const playerHeight = dimensions.height;
if (typeof playerPoster === 'string' && THUMBNAIL_REGEX.test(playerPoster) && playerPoster === mediaConfigPoster) {
SivanA-Kaltura marked this conversation as resolved.
Show resolved Hide resolved
playerSources.poster = `${playerPoster}/height/${playerHeight}/width/${playerWidth}${ks ? `/ks/${ks}` : ''}`;
const rawThumbnailUrl = mediaSources.rawThumbnailUrl;

Check failure on line 25 in src/ovp/poster.ts

View workflow job for this annotation

GitHub Actions / build-types / running-tests (ubuntu-latest)

Property 'rawThumbnailUrl' does not exist on type 'ProviderMediaConfigSourcesObject'.

Check failure on line 25 in src/ovp/poster.ts

View workflow job for this annotation

GitHub Actions / build / running-tests (ubuntu-latest)

Property 'rawThumbnailUrl' does not exist on type 'ProviderMediaConfigSourcesObject'.

Check failure on line 25 in src/ovp/poster.ts

View workflow job for this annotation

GitHub Actions / type-check / running-tests (ubuntu-latest)

Property 'rawThumbnailUrl' does not exist on type 'ProviderMediaConfigSourcesObject'.
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 @@

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 @@
});

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'};

Check failure on line 47 in tests/e2e/ovp/poster.spec.js

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Insert `·`
lianbenjamin marked this conversation as resolved.
Show resolved Hide resolved
const playerSources = { poster: '/p/1091/thumbnail/entry_id/0_wifqaipd/2' };
const ks = '123';
addKalturaPoster(playerSources, mediaSources, { width: 640, height: 360 }, ks);
Expand Down
Loading