From df654ec8d1a37ff549b3e6cd23c11497f7d83dd2 Mon Sep 17 00:00:00 2001 From: Alvaro Velad Date: Thu, 13 Jan 2022 07:56:14 +0100 Subject: [PATCH 1/4] Fix thumbnails issues --- externs/shaka/player.js | 8 ++++++++ lib/player.js | 2 ++ lib/util/stream_utils.js | 8 +++++++- test/player_unit.js | 8 ++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/externs/shaka/player.js b/externs/shaka/player.js index 300d9469c9..1a5dadd92f 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -1207,6 +1207,8 @@ shaka.extern.LanguageRole; /** * @typedef {{ + * imageHeight: number, + * imageWidth: number, * height: number, * positionX: number, * positionY: number, @@ -1216,6 +1218,12 @@ shaka.extern.LanguageRole; * width: number * }} * + * @property {number} imageHeight + * The image height in px. The image height could be different to height if + * the layout is different to 1x1. + * @property {number} imageWidth + * The image width in px. The image width could be different to height if + * the layout is different to 1x1. * @property {number} height * The thumbnail height in px. * @property {number} positionX diff --git a/lib/player.js b/lib/player.js index 634b381cda..cbcaed70a0 100644 --- a/lib/player.js +++ b/lib/player.js @@ -3637,6 +3637,8 @@ shaka.Player = class extends shaka.util.FakeEventTarget { positionY = Math.floor(thumbnailPosition / columns) * height; } return { + imageHeight: fullImageHeight, + imageWidth: fullImageWidth, height: height, positionX: positionX, positionY: positionY, diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index ca32535840..f0ef6ad52f 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -994,7 +994,13 @@ shaka.util.StreamUtils = class { // The stream width and height represent the size of the entire thumbnail // sheet, so divide by the layout. - const reference = stream.segmentIndex.get(0); + let reference = null; + // Note: segmentIndex is built by default for HLS, but not for DASH, but + // in DASH this information comes at the stream level and not at the + // segment level. + if (stream.segmentIndex) { + reference = stream.segmentIndex.get(0); + } let layout = stream.tilesLayout; if (reference) { layout = reference.getTilesLayout() || layout; diff --git a/test/player_unit.js b/test/player_unit.js index b4775be97d..69b5e62220 100644 --- a/test/player_unit.js +++ b/test/player_unit.js @@ -3544,24 +3544,32 @@ describe('Player', () => { const thumbnail2 = await player.getThumbnails(5, 21); const thumbnail5 = await player.getThumbnails(5, 51); expect(thumbnail0).toEqual(jasmine.objectContaining({ + imageHeight: 150, + imageWidth: 200, positionX: 0, positionY: 0, width: 100, height: 50, })); expect(thumbnail1).toEqual(jasmine.objectContaining({ + imageHeight: 150, + imageWidth: 200, positionX: 100, positionY: 0, width: 100, height: 50, })); expect(thumbnail2).toEqual(jasmine.objectContaining({ + imageHeight: 150, + imageWidth: 200, positionX: 0, positionY: 50, width: 100, height: 50, })); expect(thumbnail5).toEqual(jasmine.objectContaining({ + imageHeight: 150, + imageWidth: 200, positionX: 100, positionY: 100, width: 100, From afccc0211154797167f18157b7e57efcfb7e962a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 13 Jan 2022 20:56:44 +0100 Subject: [PATCH 2/4] Fix typo --- externs/shaka/player.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externs/shaka/player.js b/externs/shaka/player.js index 1a5dadd92f..6345523850 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -1222,7 +1222,7 @@ shaka.extern.LanguageRole; * The image height in px. The image height could be different to height if * the layout is different to 1x1. * @property {number} imageWidth - * The image width in px. The image width could be different to height if + * The image width in px. The image width could be different to width if * the layout is different to 1x1. * @property {number} height * The thumbnail height in px. From c3e94cf6231d106141cc807c2bd955869ffdf42f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Thu, 13 Jan 2022 22:05:07 +0100 Subject: [PATCH 3/4] Update stream_utils.js --- lib/util/stream_utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index f0ef6ad52f..de165986f8 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -1041,7 +1041,7 @@ shaka.util.StreamUtils = class { channelsCount: null, audioSamplingRate: null, spatialAudio: false, - tilesLayout: stream.tilesLayout || null, + tilesLayout: layout, audioBandwidth: null, videoBandwidth: null, originalVideoId: null, From 47ede2a609af006defaaa9edc952c60bbb76c575 Mon Sep 17 00:00:00 2001 From: Alvaro Velad Date: Thu, 13 Jan 2022 22:42:30 +0100 Subject: [PATCH 4/4] Fix lint error --- lib/util/stream_utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/stream_utils.js b/lib/util/stream_utils.js index de165986f8..438c13ec83 100644 --- a/lib/util/stream_utils.js +++ b/lib/util/stream_utils.js @@ -1041,7 +1041,7 @@ shaka.util.StreamUtils = class { channelsCount: null, audioSamplingRate: null, spatialAudio: false, - tilesLayout: layout, + tilesLayout: layout || null, audioBandwidth: null, videoBandwidth: null, originalVideoId: null,