Skip to content

Commit

Permalink
Reset render cache when target size changes
Browse files Browse the repository at this point in the history
Cherry-picked from: jellyfin@5430cc9
  • Loading branch information
JustAMan authored and dmitrylyzo committed Oct 6, 2021
1 parent ad1a0a3 commit 3be4c2b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/subtitles-octopus.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ var SubtitlesOctopus = function (options) {
self.setVideo = function (video) {
self.video = video;
if (self.video) {
// hack, for testing
if (self.renderAhead > 0) {
window.requestAnimationFrame(oneshotRender);
tryRequestOneshot();
Expand Down Expand Up @@ -265,6 +264,8 @@ var SubtitlesOctopus = function (options) {
}

function tryRequestOneshot(currentTime) {
if (!self.renderAhead || self.renderAhead <= 0) return;

if (typeof currentTime === 'undefined') {
if (!self.video) return;
currentTime = self.video.currentTime + self.timeOffset;
Expand Down Expand Up @@ -590,6 +591,7 @@ var SubtitlesOctopus = function (options) {
width: self.canvas.width,
height: self.canvas.height
});
resetRenderAheadCache();
}
};

Expand Down Expand Up @@ -625,19 +627,22 @@ var SubtitlesOctopus = function (options) {
target: 'set-track-by-url',
url: url
});
resetRenderAheadCache();
};

self.setTrack = function (content) {
self.worker.postMessage({
target: 'set-track',
content: content
});
resetRenderAheadCache();
};

self.freeTrack = function (content) {
self.worker.postMessage({
target: 'free-track'
});
resetRenderAheadCache();
};


Expand Down

0 comments on commit 3be4c2b

Please sign in to comment.