Skip to content

Commit

Permalink
Ensure video playback aggressivly
Browse files Browse the repository at this point in the history
  • Loading branch information
Wladislav ヴラド Artsimovich committed Feb 28, 2024
1 parent 666cd5b commit 0a0dc94
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions posts/WebGL-LUTS-made-simple/fullscreen-tri.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,23 @@ function setupTri(canvasId, vertexId, fragmentId, videoId, lut, lutselect, butto
}

/* Video Setup */
const video = document.getElementById(videoId);

if (video.paused) {
/* Fighting battery optimizations */
video.loop = true;
video.muted = true;
video.playsinline = true;
video.play();
}
let video = document.getElementById(videoId);

let videoTextureInitialized = false;
let lutTextureInitialized = false;

function updateTextures() {
if (!video) {
/* Fight reload issues */
video = document.getElementById(videoId);
}
if (video && video.paused && video.readyState >= 4) {
/* Fighting battery optimizations */
video.loop = true;
video.muted = true;
video.playsinline = true;
video.play();
}
if (lut && lutImg.naturalWidth && !lutTextureInitialized) {
lutTexture = setupTexture(gl, lutTexture, lutImg);
lutTextureInitialized = true;
Expand All @@ -132,7 +135,7 @@ function setupTri(canvasId, vertexId, fragmentId, videoId, lut, lutselect, butto
}
}
}

if (lutselect) {
const lutSelectElement = document.getElementById(lutselect);
if (lutSelectElement) {
Expand Down

0 comments on commit 0a0dc94

Please sign in to comment.