Skip to content

Commit

Permalink
feat(FEC-10961): show the thumbnail preview in live (#407)
Browse files Browse the repository at this point in the history
Don't build the default thumbnail preview for live content 

Solves FEC-10961
  • Loading branch information
yairans authored Feb 2, 2021
1 parent 6189173 commit c1ac3fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/common/utils/thumbs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import evaluate from './evaluate';
import {MediaType} from '@playkit-js/playkit-js';

export const DEFAULT_THUMBS_WIDTH: number = 164;
export const DEFAULT_THUMBS_SLICES: number = 100;
Expand All @@ -16,7 +17,8 @@ const TEMPLATE: string = '{{thumbnailUrl}}/width/{{width}}/vid_slices/{{slices}}
*/
export function getThumbSlicesUrl(mediaConfig: KPMediaConfig, seekbarConfig?: SeekbarConfig): string {
const mediaConfigPoster = mediaConfig.sources && mediaConfig.sources.poster;
if (typeof mediaConfigPoster === 'string') {
const isVod = mediaConfig.sources && mediaConfig.sources.type === MediaType.VOD;
if (typeof mediaConfigPoster === 'string' && isVod) {
if (THUMBNAIL_REGEX.test(mediaConfigPoster)) {
try {
const model: Object = {
Expand Down
9 changes: 8 additions & 1 deletion test/src/common/utils/thumbs.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {getThumbSlicesUrl} from '../../../../src/common/utils/thumbs';
import {MediaType} from '@playkit-js/playkit-js';

describe('getThumbSlicesUrl', function () {
const fakeData = {
sources: {
poster: '//my-thumb-service.com/p/1/thumbnail/entry_id/2/version/3'
poster: '//my-thumb-service.com/p/1/thumbnail/entry_id/2/version/3',
type: MediaType.VOD
},
session: {
ks: 'my-ks'
Expand Down Expand Up @@ -32,4 +34,9 @@ describe('getThumbSlicesUrl', function () {
fakeData.sources.poster = '//my-thumb-service.com/p/1/entry_id/2/version/3';
getThumbSlicesUrl(fakeData, fakeUIConfig).should.equals(``);
});

it('should get empty thumbnail slices url for live content', function () {
fakeData.sources.type = MediaType.LIVE;
getThumbSlicesUrl(fakeData, fakeUIConfig).should.equals(``);
});
});

0 comments on commit c1ac3fe

Please sign in to comment.