@@ -5277,12 +5277,10 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
5277
5277
const duration = reference . trueEndTime - reference . startTime ;
5278
5278
for ( let i = 0 ; i < numThumbnails ; i ++ ) {
5279
5279
const sampleTime = reference . startTime + duration * i / numThumbnails ;
5280
- const thumbnail =
5281
- this . getThumbnailsByStream_ (
5282
- /** @type {shaka.extern.Stream } */ ( imageStream ) , sampleTime ) ;
5283
- if ( thumbnail ) {
5284
- thumbnails . push ( thumbnail ) ;
5285
- }
5280
+ const thumbnail = this . getThumbnailByReference_ ( reference ,
5281
+ /** @type {shaka.extern.Stream } */ ( imageStream ) , sampleTime ,
5282
+ dimensions ) ;
5283
+ thumbnails . push ( thumbnail ) ;
5286
5284
}
5287
5285
}
5288
5286
} ) ;
@@ -5334,7 +5332,18 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
5334
5332
if ( ! imageStream ) {
5335
5333
return null ;
5336
5334
}
5337
- return this . getThumbnailsByStream_ ( imageStream , time ) ;
5335
+ const referencePosition = imageStream . segmentIndex . find ( time ) ;
5336
+ if ( referencePosition == null ) {
5337
+ return null ;
5338
+ }
5339
+ const reference = imageStream . segmentIndex . get ( referencePosition ) ;
5340
+ const dimensions = this . parseTilesLayout_ (
5341
+ reference . getTilesLayout ( ) || imageStream . tilesLayout ) ;
5342
+ if ( ! dimensions ) {
5343
+ return null ;
5344
+ }
5345
+ return this . getThumbnailByReference_ ( reference , imageStream , time ,
5346
+ dimensions ) ;
5338
5347
}
5339
5348
5340
5349
/**
@@ -5373,24 +5382,16 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
5373
5382
}
5374
5383
5375
5384
/**
5376
- * Return a Thumbnail object from a image stream and time .
5385
+ * Return a Thumbnail object from a reference .
5377
5386
*
5387
+ * @param {shaka.media.SegmentReference } reference
5378
5388
* @param {shaka.extern.Stream } imageStream
5379
5389
* @param {number } time
5380
- * @return {?shaka.extern.Thumbnail }
5390
+ * @param {{columns: number, rows: number} } dimensions
5391
+ * @return {!shaka.extern.Thumbnail }
5381
5392
* @private
5382
5393
*/
5383
- getThumbnailsByStream_ ( imageStream , time ) {
5384
- const referencePosition = imageStream . segmentIndex . find ( time ) ;
5385
- if ( referencePosition == null ) {
5386
- return null ;
5387
- }
5388
- const reference = imageStream . segmentIndex . get ( referencePosition ) ;
5389
- const dimensions = this . parseTilesLayout_ (
5390
- reference . getTilesLayout ( ) || imageStream . tilesLayout ) ;
5391
- if ( ! dimensions ) {
5392
- return null ;
5393
- }
5394
+ getThumbnailByReference_ ( reference , imageStream , time , dimensions ) {
5394
5395
const fullImageWidth = imageStream . width || 0 ;
5395
5396
const fullImageHeight = imageStream . height || 0 ;
5396
5397
let width = fullImageWidth / dimensions . columns ;
0 commit comments