Skip to content

Commit

Permalink
fix(FEC-11402): preview doesn't work in video ratio different than 16…
Browse files Browse the repository at this point in the history
…:9 (#466)

Preview image height should be calculated according to video ratio and not used from constant as video ratio can be different than 16:9
  • Loading branch information
RoyBregman committed Jul 19, 2021
1 parent 1c0fb7f commit 26dc475
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/thumbnail-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ThumbnailManager {
_convertKalturaThumbnailToThumbnailInfo = (time: number): ?ThumbnailInfo => {
if (this._thumbnailConfig) {
const {thumbsSprite, thumbsWidth, thumbsSlices} = this._thumbnailConfig;
const {thumbsHeight} = DefaultThumbnailConfig;
const thumbsHeight = Math.floor(thumbsWidth * (this._player.videoHeight / this._player.videoWidth));
const duration = this._player.duration / thumbsSlices;
const thumbnailInfo = {
x: Math.floor(time / duration) * thumbsWidth,
Expand Down
11 changes: 11 additions & 0 deletions test/src/common/thumbnail-manager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ describe('ThumbnailManager', () => {
spy.should.calledOnce;
});

it('should return thumbnail height from core player with video ratio 4:3', () => {
fakeMediaConfig.sources.poster = null;
fakePlayer.config.ui.components.seekbar.thumbsSprite = thumbsSprite;
thumbnailManager = new ThumbnailManager(fakePlayer, fakePlayer.config.ui, fakeMediaConfig);
fakePlayer.duration = 1000;
fakePlayer.videoHeight = 480;
fakePlayer.videoWidth = 640;
const thumbInfo = thumbnailManager.getThumbnail(100);
thumbInfo.height.should.equal(thumbInfo.width * (fakePlayer.videoHeight / fakePlayer.videoWidth));
});

it('should set the configured thumbs sprite with default sizes', () => {
fakePlayer.config.ui.components.seekbar.thumbsSprite = thumbsSprite;
thumbnailManager = new ThumbnailManager(fakePlayer, fakePlayer.config.ui, fakeMediaConfig);
Expand Down

0 comments on commit 26dc475

Please sign in to comment.