Am loading a video in threejs and am using video texture for that.
Here’s how am doing that. →
const UIPopups = new Popups();
const videoElement1 = UIPopups.createVideoElement(
"./public/videos/video-intro.mp4",
true,
false,
false,
"auto"
);
const videoTexture = new THREE.VideoTexture(videoElement1);
videoTexture.colorSpace = THREE.SRGBColorSpace;
const spriteMaterial = new THREE.SpriteMaterial({ map: videoTexture });
const sprite = new THREE.Sprite(spriteMaterial);
scene.add(sprite);
createVideoElement(
src,
playsInline,
controls,
muted,
preload = "auto",
loop = false
) {
const video = document.createElement("video");
video.src = `${src}`;
video.playsInline = playsInline;
video.controls = controls;
video.muted = muted;
video.preload = preload;
video.loop = loop;
video.load();
return video;
}
The issue is related to buffering, I want that complete video should be downloaded first and then it should be played. Am using eventlisteners like loadedmetadata and loadeddata to check whether video loaded or not. But this only loads some part of video. And after reaching it again start loading automatically and play when loaded. I want that first it should load complete video, And only after that it should play.
How can i do so ?
If not possible directly provide me an alternative like other platforms does like youtube, If youtube was not able to play at high quality it reduces the quality and runs it in low quality.
Provide me some guidance if anyone knows how to fix it?