video pixi v5+
video pixi v5+
by Bouh
HTML
<script src="https://pixijs.io/pixi-filters/tools/demo/index.js"></script>
<script src="https://pixijs.download/v5.2.1/pixi.js"></script>
JavaScript
//video lastest pixi v5.2.1
var renderer = new PIXI.autoDetectRenderer(800, 600, { transparent: true });
document.body.appendChild(renderer.view);
// create the root of the scene graph
var stage = new PIXI.Container();
// create a video texture from a path
var texture = PIXI.Texture.from('https://resources.gdevelop-app.com/examples/video-player/The-Daily-Dweebs-By-Blender-Foundation-Short.mp4');
// create a new Sprite using the video texture (yes it's that easy)
var videoSprite = new PIXI.Sprite(texture);
videoSprite._texture.baseTexture.resource.source.preload = "auto";
videoSprite._texture.baseTexture.resource.source.autoload = true;
videoSprite._texture.baseTexture.resource.autoPlay = true;
videoSprite.width = renderer.width;
videoSprite.height = renderer.height;
stage.addChild(videoSprite);
animate();
function animate(){
// render the stage
renderer.render(stage);
requestAnimationFrame(animate);
}