Skip to content

Commit

Permalink
perf: Improve performance of addThumbnailsTrack (#6067)
Browse files Browse the repository at this point in the history
Fixes #6065
  • Loading branch information
avelad committed Jan 11, 2024
1 parent 8ff5b59 commit 3a14047
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/player.js
Expand Up @@ -4860,21 +4860,27 @@ shaka.Player = class extends shaka.util.FakeEventTarget {

const references = [];
for (const cue of cues) {
const imageUri = shaka.util.ManifestParserUtils.resolveUris(
[uri], [cue.payload])[0];
let uris = null;
const getUris = () => {
if (uris == null) {
uris = shaka.util.ManifestParserUtils.resolveUris(
[uri], [cue.payload]);
}
return uris || [];
};
const reference = new shaka.media.SegmentReference(
cue.startTime,
cue.endTime,
() => [imageUri],
getUris,
/* startByte= */ 0,
/* endByte= */ null,
/* initSegmentReference= */ null,
/* timestampOffset= */ 0,
/* appendWindowStart= */ 0,
/* appendWindowEnd= */ Infinity,
);
if (imageUri.includes('#xywh')) {
const spriteInfo = imageUri.split('#xywh=')[1].split(',');
if (cue.payload.includes('#xywh')) {
const spriteInfo = cue.payload.split('#xywh=')[1].split(',');
if (spriteInfo.length === 4) {
reference.setThumbnailSprite({
height: parseInt(spriteInfo[3], 10),
Expand Down

0 comments on commit 3a14047

Please sign in to comment.