-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set ui seek bar config via kaltura player. For now it's done only internally with default params. After the refactor of kaltura player we will expose it to user config. Added a mini-service for thumbnail handling which can be extended easily.
- Loading branch information
Dan Ziv
committed
Nov 23, 2017
1 parent
26d1127
commit 304bc0a
Showing
5 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// @flow | ||
import evaluate from './evaluate' | ||
|
||
export const DEFAULT_THUMBS_WIDTH: number = 164; | ||
export const DEFAULT_THUMBS_SLICES: number = 100; | ||
const TEMPLATE: string = '{{thumbnailUrl}}/width/{{width}}/vid_slices/{{slices}}/ks/{{ks}}'; | ||
|
||
/** | ||
* Builds thumbnail slices url for the ui. | ||
* @param {Object} data - The prover data. | ||
* @param {Object} uiConfig - The ui config. | ||
* @returns {string} - The thumbnail slices url. | ||
*/ | ||
export function getThumbSlicesUrl(data: Object, uiConfig: Object = {}): string { | ||
try { | ||
const model: Object = { | ||
thumbnailUrl: data.metadata.poster, | ||
ks: data.session.ks, | ||
width: uiConfig.thumbsWidth || DEFAULT_THUMBS_WIDTH, | ||
slices: uiConfig.thumbsSlices || DEFAULT_THUMBS_SLICES, | ||
}; | ||
return evaluate(TEMPLATE, model); | ||
} catch (e) { | ||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {getThumbSlicesUrl} from '../../../src/utils/thumbs' | ||
|
||
describe('getThumbSlicesUrl', function () { | ||
const fakeData = { | ||
metadata: { | ||
poster: "//my-thumb-service.com/p/1/entry_id/2/version/3" | ||
}, | ||
session: { | ||
ks: "my-ks" | ||
} | ||
}; | ||
|
||
const fakeUIConfig = { | ||
thumbsSlices: 200, | ||
thumbsWidth: 100 | ||
}; | ||
|
||
it('should get thumbnail slices url with default params', function () { | ||
getThumbSlicesUrl(fakeData).should.equals( | ||
`${fakeData.metadata.poster}/width/164/vid_slices/100/ks/${fakeData.session.ks}` | ||
); | ||
}); | ||
|
||
it('should get thumbnail slices url with the custom params', function () { | ||
getThumbSlicesUrl(fakeData, fakeUIConfig).should.equals( | ||
`${fakeData.metadata.poster}/width/100/vid_slices/200/ks/${fakeData.session.ks}` | ||
); | ||
}); | ||
}); |