diff --git a/AUTHORS b/AUTHORS index 90c5870cf3..92a00cf104 100644 --- a/AUTHORS +++ b/AUTHORS @@ -49,9 +49,11 @@ Nick Desaulniers Oskar Arvidsson Patrick Cruikshank Patrick Kunka +Paul Jordaan Percy Tse Peter Nycander Philo Inc. <*@philo.com> +Prakash Robert Colantuoni Roi Lipman Roksolana Ivanyshyn @@ -69,6 +71,4 @@ uStudio Inc. <*@ustudio.com> Verizon Digital Media Services <*@verizondigitalmedia.com> Vincent Valot Wayne Morgan -Prakash - diff --git a/CONTRIBUTORS b/CONTRIBUTORS index c405fe532e..a0ae42f25e 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -23,6 +23,7 @@ # Please keep the list sorted. Aaron Vaage +Adrián Gómez Llorente Aidan Ridley Alex Jones Alvaro Velad Galvan @@ -76,8 +77,10 @@ Niklas Korz Oskar Arvidsson Patrick Cruikshank Patrick Kunka +Paul Jordaan Percy Tse Peter Nycander +Prakash Duggaraju Robert Colantuoni Rohit Makasana Roi Lipman @@ -104,6 +107,4 @@ Vasanth Polipelli Vignesh Venkatasubramanian Vincent Valot Wayne Morgan -Yohann Connell -Adrián Gómez Llorente -Prakash Duggaraju +Yohann Connell \ No newline at end of file diff --git a/lib/player.js b/lib/player.js index f539b3338d..939ed50604 100644 --- a/lib/player.js +++ b/lib/player.js @@ -3422,8 +3422,8 @@ shaka.Player = class extends shaka.util.FakeEventTarget { const segmentTime = reference.endTime - reference.startTime; const thumbnailPosition = Math.floor(thumbnailTime * totalImages / segmentTime); - positionX = (thumbnailPosition % columns) / columns * fullImageWidth; - positionY = (thumbnailPosition % rows) / rows * fullImageHeight; + positionX = (thumbnailPosition % columns) * width; + positionY = Math.floor(thumbnailPosition / columns) * height; } return { height: height, diff --git a/test/player_unit.js b/test/player_unit.js index 7a573d9f44..f8e956be64 100644 --- a/test/player_unit.js +++ b/test/player_unit.js @@ -10,6 +10,8 @@ goog.require('shaka.log'); goog.require('shaka.media.BufferingObserver'); goog.require('shaka.media.ManifestParser'); goog.require('shaka.media.PresentationTimeline'); +goog.require('shaka.media.SegmentReference'); +goog.require('shaka.media.SegmentIndex'); goog.require('shaka.test.FakeAbrManager'); goog.require('shaka.test.FakeDrmEngine'); goog.require('shaka.test.FakeManifestParser'); @@ -3510,6 +3512,61 @@ describe('Player', () => { ]); }); }); + + describe('getThumbnails', () => { + it('returns correct thumbnail position for supplied time', async () => { + const uris = () => ['thumbnail']; + const segment = new shaka.media.SegmentReference( + 0, 60, uris, 0, null, null, 0, 0, Infinity, [], + ); + const index = new shaka.media.SegmentIndex([segment]); + + manifest = shaka.test.ManifestGenerator.generate((manifest) => { + manifest.addVariant(0, (variant) => { + variant.addVideo(1); + }); + manifest.addImageStream(5, (stream) => { + stream.originalId = 'thumbnail'; + stream.width = 200; + stream.height = 150; + stream.mimeType = 'image/jpeg'; + stream.tilesLayout = '2x3'; + stream.segmentIndex = index; + }); + }); + + await player.load(fakeManifestUri, 0, fakeMimeType); + + const thumbnail0 = await player.getThumbnails(5, 0); + const thumbnail1 = await player.getThumbnails(5, 11); + const thumbnail2 = await player.getThumbnails(5, 21); + const thumbnail5 = await player.getThumbnails(5, 51); + expect(thumbnail0).toEqual(jasmine.objectContaining({ + positionX: 0, + positionY: 0, + width: 100, + height: 50, + })); + expect(thumbnail1).toEqual(jasmine.objectContaining({ + positionX: 100, + positionY: 0, + width: 100, + height: 50, + })); + expect(thumbnail2).toEqual(jasmine.objectContaining({ + positionX: 0, + positionY: 50, + width: 100, + height: 50, + })); + expect(thumbnail5).toEqual(jasmine.objectContaining({ + positionX: 100, + positionY: 100, + width: 100, + height: 50, + })); + }); + }); }); /**