@@ -4,7 +4,8 @@ import type {
44 IKPlayerOptions ,
55 SourceOptions ,
66 RemoteTextTrackOptions ,
7- AutoGeneratedTextTrackOptions
7+ AutoGeneratedTextTrackOptions ,
8+ Transformation
89} from '@imagekit/video-player' ;
910import type Player from 'video.js/dist/types/player' ;
1011
@@ -58,10 +59,11 @@ function buildPlayerConfig(
5859 imagekitId : string ,
5960 srcUrl : string ,
6061 features : string [ ] ,
61- maxWords ?: number ,
62+ maxChars ?: number ,
6263 wordHighlight ?: boolean ,
6364 translationLangs ?: Array < { label ?: string ; langCode : string } > ,
64- signerUrl ?: string
65+ signerUrl ?: string ,
66+ transformation ?: Transformation [ ]
6567) : { playerOptions : IKPlayerOptions ; srcConfig : SourceOptions } {
6668 // Build player options
6769 const playerOptions : IKPlayerOptions = {
@@ -107,6 +109,10 @@ function buildPlayerConfig(
107109 src : srcUrl ,
108110 } ;
109111
112+ if ( transformation && transformation . length > 0 ) {
113+ srcConfig . transformation = transformation ;
114+ }
115+
110116 if ( features . includes ( 'chapters' ) ) {
111117 srcConfig . chapters = true ;
112118 }
@@ -121,8 +127,8 @@ function buildPlayerConfig(
121127 autoGenerate : true ,
122128 } ;
123129
124- if ( maxWords !== undefined && maxWords > 0 ) {
125- subtitleConfig . maxWordsPerLine = maxWords ;
130+ if ( maxChars !== undefined && maxChars > 0 ) {
131+ subtitleConfig . maxChars = maxChars ;
126132 }
127133 if ( wordHighlight ) {
128134 subtitleConfig . highlightWords = true ;
@@ -173,19 +179,21 @@ function generateCode(
173179 imagekitId : string ,
174180 srcUrl : string ,
175181 features : string [ ] ,
176- maxWords ?: number ,
182+ maxChars ?: number ,
177183 wordHighlight ?: boolean ,
178184 translationLangs ?: Array < { label ?: string ; langCode : string } > ,
179- signerUrl ?: string
185+ signerUrl ?: string ,
186+ transformation ?: Transformation [ ]
180187) : string {
181188 const { playerOptions, srcConfig } = buildPlayerConfig (
182189 imagekitId ,
183190 srcUrl ,
184191 features ,
185- maxWords ,
192+ maxChars ,
186193 wordHighlight ,
187194 translationLangs ,
188- signerUrl
195+ signerUrl ,
196+ transformation
189197 ) ;
190198
191199 // Keep video.js options in one place so displayed code always matches runtime config
@@ -244,8 +252,8 @@ function updatePlayer() {
244252 }
245253
246254 // Get subtitle options
247- const maxWordsInput = document . getElementById ( 'max-words ' ) as HTMLInputElement ;
248- const maxWords = maxWordsInput ?. value ? parseInt ( maxWordsInput . value , 10 ) : undefined ;
255+ const maxCharsInput = document . getElementById ( 'max-chars ' ) as HTMLInputElement ;
256+ const maxChars = maxCharsInput ?. value ? parseInt ( maxCharsInput . value , 10 ) : undefined ;
249257 const wordHighlight = ( document . getElementById ( 'word-highlight' ) as HTMLInputElement ) ?. checked || false ;
250258
251259 // Get translation languages from the list
@@ -267,19 +275,37 @@ function updatePlayer() {
267275 const signerUrlInput = document . getElementById ( 'signer-url' ) as HTMLInputElement ;
268276 const signerUrl = enableSigner && signerUrlInput ?. value . trim ( ) ? signerUrlInput . value . trim ( ) : undefined ;
269277
278+ // Get transformation
279+ const transformationInput = ( document . getElementById ( 'transformation' ) as HTMLInputElement ) ?. value . trim ( ) || '' ;
280+ let transformation : Transformation [ ] | undefined = undefined ;
281+ if ( transformationInput ) {
282+ try {
283+ const parsed = JSON . parse ( transformationInput ) ;
284+ if ( Array . isArray ( parsed ) ) {
285+ transformation = parsed ;
286+ } else {
287+ console . warn ( 'Transformation must be a JSON array' ) ;
288+ }
289+ } catch ( e ) {
290+ alert ( 'Invalid transformation JSON. Please check the format.' ) ;
291+ return ;
292+ }
293+ }
294+
270295 // Build configuration using shared function
271296 const { playerOptions, srcConfig } = buildPlayerConfig (
272297 imagekitId ,
273298 srcUrl ,
274299 features ,
275- maxWords ,
300+ maxChars ,
276301 wordHighlight ,
277302 translationLangsForConfig ,
278- signerUrl
303+ signerUrl ,
304+ transformation
279305 ) ;
280306
281307 // Generate and display code
282- const code = generateCode ( imagekitId , srcUrl , features , maxWords , wordHighlight , translationLangsForConfig , signerUrl ) ;
308+ const code = generateCode ( imagekitId , srcUrl , features , maxChars , wordHighlight , translationLangsForConfig , signerUrl , transformation ) ;
283309 document . getElementById ( 'code-display' ) ! . textContent = code ;
284310
285311 // Get the video element before disposing
0 commit comments